]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/telemetry: check get_metadata return val 33096/head
authorYaarit Hatuka <yaarit@redhat.com>
Mon, 3 Feb 2020 19:19:39 +0000 (14:19 -0500)
committerKonstantin Shalygin <k0ste@k0ste.ru>
Thu, 6 Feb 2020 03:06:40 +0000 (10:06 +0700)
get_metada() returns 'None' when requesting a missing service, hence
trying to access its content fails. Added a check for osd and mgr
get_metadata() calls.

Fixes: https://tracker.ceph.com/issues/43642
Signed-off-by: Yaarit Hatuka <yaarit@redhat.com>
(cherry picked from commit 9e7a0cbb6f12840217b8f854ed516e44ca8c831e)

src/pybind/mgr/telemetry/module.py

index df0accf57881c46203271f044a6adff49730a022..22ca7cf2c2defa5ae79a8d28f6f9c9a771ed9327 100644 (file)
@@ -184,7 +184,11 @@ class Module(MgrModule):
             metadata[key] = defaultdict(int)
 
         for osd in osd_map['osds']:
-            for k, v in self.get_metadata('osd', str(osd['osd'])).items():
+            res = self.get_metadata('osd', str(osd['osd'])).items()
+            if res is None:
+                self.log.debug('Could not get metadata for osd.%s' % str(osd['osd']))
+                continue
+            for k, v in res:
                 if k not in keys:
                     continue
 
@@ -201,7 +205,11 @@ class Module(MgrModule):
             metadata[key] = defaultdict(int)
 
         for mon in mon_map['mons']:
-            for k, v in self.get_metadata('mon', mon['name']).items():
+            res = self.get_metadata('mon', mon['name']).items()
+            if res is None:
+                self.log.debug('Could not get metadata for mon.%s' % (mon['name']))
+                continue
+            for k, v in res:
                 if k not in keys:
                     continue