]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: improve logging during JSONDecodeError
authorMichael Fritch <mfritch@suse.com>
Wed, 4 Nov 2020 18:48:09 +0000 (11:48 -0700)
committerMichael Fritch <mfritch@suse.com>
Thu, 19 Nov 2020 16:42:01 +0000 (09:42 -0700)
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 <mfritch@suse.com>
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/utils.py

index fe10fbb74cbb5b790ebc095143528cdb8d11e3d3..fd70945e63a77b734a6f7686418ae3887cc9386c 100644 (file)
@@ -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
index 4c3d595010fd7725c6000abb42eebe3f76ca8544..03a28fbd9efe38a5326a5202b558522395c67ddb 100644 (file)
@@ -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']