From e449d1e905340deb937c16a8f109667fc5ad45fb Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 22 Feb 2021 13:53:42 +0800 Subject: [PATCH] mgr/influx: use "N/A" for unknown hostname in theory, there is chance that get_metadata() returns None, so let use "N/A" in this case. Signed-off-by: Kefu Chai (cherry picked from commit e457ca50011f70cf01a62323998af233a484f338) --- src/pybind/mgr/influx/module.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/influx/module.py b/src/pybind/mgr/influx/module.py index 14c79d3fe74c..62833f2d0f2c 100644 --- a/src/pybind/mgr/influx/module.py +++ b/src/pybind/mgr/influx/module.py @@ -254,6 +254,10 @@ class Module(MgrModule): for daemon, counters in six.iteritems(self.get_all_perf_counters()): 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: @@ -266,7 +270,7 @@ class Module(MgrModule): "tags": { "ceph_daemon": daemon, "type_instance": path, - "host": metadata['hostname'], + "host": hostname, "fsid": self.get_fsid() }, "time": now, -- 2.47.3