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 <adking@redhat.com>
(cherry picked from commit
287bd34eec09815602700747c62e0a709e6e5ff0)