]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: have agent check for errors before json loading mgr response 59455/head
authorAdam King <adking@redhat.com>
Wed, 17 Apr 2024 15:36:12 +0000 (11:36 -0400)
committerAdam King <adking@redhat.com>
Tue, 27 Aug 2024 14:04:57 +0000 (10:04 -0400)
Currently, since it tries to json.loads the response
payload before checking the return code, if there was
an error it fails with

Failed to send metadata to mgr: the JSON object must be str, bytes or bytearray, not ConnectionRefusedError

which is masking the actual failure.

Also adds more context to the RuntimeError raised

Fixes: https://tracker.ceph.com/issues/65553
Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit 287bd34eec09815602700747c62e0a709e6e5ff0)

src/cephadm/cephadm.py

index 0f6257331c20ccc12c0f1aded858f9cd254bc2ae..03653f5a82efd7dc3320aff6d35c19216070a781 100755 (executable)
@@ -5125,10 +5125,10 @@ WantedBy=ceph-{fsid}.target
                                               data=data,
                                               endpoint='/data',
                                               ssl_ctx=self.ssl_ctx)
-                response_json = json.loads(response)
                 if status != 200:
                     logger.error(f'HTTP error {status} while querying agent endpoint: {response}')
-                    raise RuntimeError
+                    raise RuntimeError(f'non-200 response <{status}> from agent endpoint: {response}')
+                response_json = json.loads(response)
                 total_request_time = datetime.timedelta(seconds=(time.monotonic() - send_time)).total_seconds()
                 logger.info(f'Received mgr response: "{response_json["result"]}" {total_request_time} seconds after sending request.')
             except Exception as e: