canonical / pylxd

Python module for LXD
https://pylxd.readthedocs.io/en/latest/
Apache License 2.0
256 stars 135 forks source link

bugfix: fix error message printing error #576

Closed dbaldy closed 5 months ago

dbaldy commented 5 months ago

Fixes an exception raised when an error occurs, hiding the real error message:

File "/usr/lib/python3/dist-packages/pylxd/models/instance.py", line 343, in create
    client.operations.wait_for_operation(response.json()["operation"])
  File "/usr/lib/python3/dist-packages/pylxd/models/operation.py", line 57, in wait_for_operation
    operation.wait()
  File "/usr/lib/python3/dist-packages/pylxd/models/operation.py", line 94, in wait
    response = self._client.api.operations[self.id].wait.get()
  File "/usr/lib/python3/dist-packages/pylxd/client.py", line 207, in get
    self._assert_response(
  File "/usr/lib/python3/dist-packages/pylxd/client.py", line 178, in _assert_response
    raise exceptions.LXDAPIException(response)
pylxd.exceptions.LXDAPIException: <unprintable LXDAPIException object>

This for instance happens in some cases when trying to create an instance by pulling the image from a remote server with client.instance.create(config, wait=True) but for some reason the backend doesn't manage to start the instance, e.g. we receive read-only filesystem from our workers from time to time.

codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 88.23529% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 97.81%. Comparing base (118ef8d) to head (c5702a2).

Files Patch % Lines
pylxd/exceptions.py 71.42% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #576 +/- ## ========================================== + Coverage 97.77% 97.81% +0.04% ========================================== Files 32 32 Lines 3057 3073 +16 ========================================== + Hits 2989 3006 +17 + Misses 68 67 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.