Page MenuHomePhabricator

Redfish _get_dummy_response() should return empty json
Open, LowPublic


Running the rename cookbook in dry-run failed with:

DRY-RUN: ✔️ Downtimed host on Icinga/Alertmanager
DRY-RUN: Skipping Netbox name change from kubernetes2023 to wikikube-worker2001 in DRY-RUN.
DRY-RUN: ✔️ Netbox updated
DRY-RUN: Would have called patch on
DRY-RUN: Exception raised while executing cookbook sre.hosts.rename:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/spicerack/", line 250, in _run
    raw_ret =
  File "/home/ayounsi/cookbooks_testing/cookbooks/cookbooks/sre/hosts/", line 103, in run
    response = self.redfish.request('patch',
  File "/usr/lib/python3/dist-packages/requests/", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.9/json/", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.9/json/", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.9/json/", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
DRY-RUN: Exception raised while executing cookbook sre.hosts.rename rollback() (exit_code=99):
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/spicerack/", line 118, in get_server
    server = self._get_device(hostname)
  File "/usr/lib/python3/dist-packages/spicerack/", line 80, in _get_device
    raise NetboxHostNotFoundError(name)
spicerack.netbox.NetboxHostNotFoundError: wikikube-worker2001

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/spicerack/", line 285, in _run
  File "/home/ayounsi/cookbooks_testing/cookbooks/cookbooks/sre/hosts/", line 159, in rollback
    self.netbox_server = self.spicerack.netbox_server(self.new_name, read_write=True)
  File "/usr/lib/python3/dist-packages/spicerack/", line 614, in netbox_server
    return self.netbox(read_write=read_write).get_server(hostname)
  File "/usr/lib/python3/dist-packages/spicerack/", line 120, in get_server
    server = self._get_virtual_machine(hostname)
  File "/usr/lib/python3/dist-packages/spicerack/", line 102, in _get_virtual_machine
    raise NetboxHostNotFoundError
DRY-RUN: Releasing lock for key sre.hosts.rename with ID b287e923-cfde-4e63-baf7-ab63e17a6f5f
DRY-RUN: Issuing read for key /spicerack/locks/cookbooks/sre.hosts.rename with args {'timeout': 60}
DRY-RUN: Lock for key /spicerack/locks/cookbooks/sre.hosts.rename and ID b287e923-cfde-4e63-baf7-ab63e17a6f5f not found. Unable to release it. Was expired?
DRY-RUN: __COOKBOOK_STATS__:name=sre.hosts.rename,exit_code=93,duration=3.292
DRY-RUN: END (FAIL) - Cookbook sre.hosts.rename (exit_code=93) from kubernetes2023 to wikikube-worker2001

It might be difficult to have a cookbook that fully supports DRY-RUN in a relevant way.

But a minor bug that could be fixed I think is json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
probably needs to return some empty json ? so it doesn't fails with the `.json() ?

Event Timeline

ayounsi created this task.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I guess we could use something like:

>>> a = requests.Response()
>>> a.status_code = 200
>>> a.raw = BytesIO(b'{}')
>>> a.raw.decode_content = True
>>> a.json()

Not sure it could mess up with other assumptions but we could try.