From: Michael Fritch Date: Wed, 4 Nov 2020 18:48:09 +0000 (-0700) Subject: mgr/cephadm: improve logging during JSONDecodeError X-Git-Tag: v16.1.0~353^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d4c9d5e680cb17379940a1ceaa038c6224b9b039;p=ceph-ci.git mgr/cephadm: improve logging during JSONDecodeError improve logging around JSONDecodeErrors that can occur during a cephadm image pull, load of the extra_ceph_conf, and parsing the cluster health status Fixes: https://tracker.ceph.com/issues/48120 Signed-off-by: Michael Fritch --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index fe10fbb74cb..fd70945e63a 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -928,7 +928,8 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, try: j = json.loads(data) except ValueError: - self.log.exception('unable to laod extra_ceph_conf') + msg = 'Unable to load extra_ceph_conf: Cannot decode JSON' + self.log.exception('%s: \'%s\'', msg, data) return CephadmOrchestrator.ExtraCephConf('', None) return CephadmOrchestrator.ExtraCephConf(j['conf'], str_to_datetime(j['last_modified'])) @@ -2122,8 +2123,8 @@ To check that the host is reachable: self.log.debug(f'image {image_name} -> {r}') return r except (ValueError, KeyError) as _: - msg = 'Failed to pull %s on %s: %s' % (image_name, host, '\n'.join(out)) - self.log.exception(msg) + msg = 'Failed to pull %s on %s: Cannot decode JSON' % (image_name, host) + self.log.exception('%s: \'%s\'' % (msg, '\n'.join(out))) raise OrchestratorError(msg) @trivial_completion diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py index 4c3d595010f..03a28fbd9ef 100644 --- a/src/pybind/mgr/cephadm/utils.py +++ b/src/pybind/mgr/cephadm/utils.py @@ -78,7 +78,9 @@ def get_cluster_health(mgr: 'CephadmOrchestrator') -> str: }) try: j = json.loads(out) - except Exception as e: + except ValueError: + msg = 'Failed to parse health status: Cannot decode JSON' + logger.exception('%s: \'%s\'' % (msg, out)) raise OrchestratorError('failed to parse health status') return j['status']