]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: skip OSD output if missing from CRUSH devices 20644/head
authorJohn Spray <john.spray@redhat.com>
Wed, 28 Feb 2018 14:03:42 +0000 (14:03 +0000)
committerJohn Spray <john.spray@redhat.com>
Mon, 5 Mar 2018 15:51:37 +0000 (10:51 -0500)
Apparently this occurs as a transient state while adding
OSDs.

Fixes: https://tracker.ceph.com/issues/23166
Signed-off-by: John Spray <john.spray@redhat.com>
src/pybind/mgr/prometheus/module.py

index 05e2bdee099a7f58cde3bae64c7e22b40b3935fb..a6dc5d1969e336f9eb09a677c56962caf5d9be74 100644 (file)
@@ -425,12 +425,27 @@ class Module(MgrModule):
                     " and metadata records for this osd".format(id_)
                 )
                 continue
-            dev_class = next((osd for osd in osd_devices if str(osd['id']) == id_))
+
+            dev_class = None
+            for osd_device in osd_devices:
+                if osd_device['id'] == id_:
+                    dev_class = osd_device.get('class', '')
+                    break
+
+            if dev_class is None:
+                self.log.info(
+                    "OSD {0} is missing from CRUSH map, skipping output".format(
+                        id_))
+                continue
+
             host_version = servers.get((id_, 'osd'), ('',''))
-            self.metrics.append('osd_metadata', 1, (c_addr,
-                                                    dev_class.get('class',''),
-                                                    id_, host_version[0],
-                                                    p_addr, host_version[1]))
+
+            self.metrics['osd_metadata'].set(1, (
+                c_addr,
+                dev_class,
+                id_, host_version[0],
+                p_addr, host_version[1]
+            ))
 
             # collect osd status
             for state in OSD_STATUS: