]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: skip OSD output if missing from CRUSH devices
authorJohn Spray <john.spray@redhat.com>
Wed, 28 Feb 2018 14:03:42 +0000 (14:03 +0000)
committerBoris Ranto <branto@redhat.com>
Thu, 19 Apr 2018 17:47:48 +0000 (19:47 +0200)
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>
(cherry picked from commit e8e5bffbb0842cc9c41bb64e7e9b5c6e2898fc0c)

src/pybind/mgr/prometheus/module.py

index 129c75d7835a96ba28793c67ee6b4a8b940e69bf..7c7241c5d111b7902c6c22ac51bdb5d0a1e8fbbe 100644 (file)
@@ -449,12 +449,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: