Skip to content

Commit 287bd34

Browse files
committed
cephadm: have agent check for errors before json loading mgr response
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 <[email protected]>
1 parent 3453230 commit 287bd34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/cephadm/cephadm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,10 +1577,10 @@ def run(self) -> None:
15771577
data=data,
15781578
endpoint='/data',
15791579
ssl_ctx=self.ssl_ctx)
1580-
response_json = json.loads(response)
15811580
if status != 200:
15821581
logger.error(f'HTTP error {status} while querying agent endpoint: {response}')
1583-
raise RuntimeError
1582+
raise RuntimeError(f'non-200 response <{status}> from agent endpoint: {response}')
1583+
response_json = json.loads(response)
15841584
total_request_time = datetime.timedelta(seconds=(time.monotonic() - send_time)).total_seconds()
15851585
logger.info(f'Received mgr response: "{response_json["result"]}" {total_request_time} seconds after sending request.')
15861586
except Exception as e:

0 commit comments

Comments
 (0)