]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: improve logging during JSONDecodeError
authorMichael Fritch <mfritch@suse.com>
Wed, 4 Nov 2020 18:48:09 +0000 (11:48 -0700)
committerSebastian Wagner <sebastian.wagner@suse.com>
Thu, 7 Jan 2021 12:02:21 +0000 (13:02 +0100)
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>
(cherry picked from commit d4c9d5e680cb17379940a1ceaa038c6224b9b039)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/utils.py

index 3918da2ff283c364219a7b5189121f59e7f51036..465a1dca1609f2ada17735f36355f50807b6b76c 100644 (file)
@@ -943,7 +943,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']))
 
@@ -2137,8 +2138,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']