]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/influx: use "N/A" for unknown hostname
authorKefu Chai <kchai@redhat.com>
Mon, 22 Feb 2021 05:53:42 +0000 (13:53 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 25 Feb 2021 07:54:12 +0000 (15:54 +0800)
in theory, there is chance that get_metadata() returns None, so let use
"N/A" in this case.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/influx/module.py

index 5d0682a8b88acbc123a52dbd0e84f56313b3530c..52179aac71856f9077366e6b04129f0edd9cc32a 100644 (file)
@@ -239,6 +239,10 @@ class Module(MgrModule):
         for daemon, counters in self.get_all_perf_counters().items():
             svc_type, svc_id = daemon.split(".", 1)
             metadata = self.get_metadata(svc_type, svc_id)
+            if metadata is not None:
+                hostname = metadata['hostname']
+            else:
+                hostname = 'N/A'
 
             for path, counter_info in counters.items():
                 if counter_info['type'] & self.PERFCOUNTER_HISTOGRAM:
@@ -251,7 +255,7 @@ class Module(MgrModule):
                     "tags": {
                         "ceph_daemon": daemon,
                         "type_instance": path,
-                        "host": metadata['hostname'],
+                        "host": hostname,
                         "fsid": self.get_fsid()
                     },
                     "time": now,