summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Donnelly <pdonnell@redhat.com>2020-08-10 21:46:38 +0200
committerPatrick Donnelly <pdonnell@redhat.com>2020-08-10 21:46:38 +0200
commitaec63160669d3c891a7bfa0c8bfd7dfe690af0a3 (patch)
treebaa79d9078adfd071619a82c8bb75d318314f5eb /src
parentMerge pull request #36548 from votdev/fix_colors (diff)
parentmgr/mgr_module: metadata is fetched async (diff)
downloadceph-aec63160669d3c891a7bfa0c8bfd7dfe690af0a3.tar.xz
ceph-aec63160669d3c891a7bfa0c8bfd7dfe690af0a3.zip
Merge PR #35161 into master
* refs/pull/35161/head: mgr/mgr_module: metadata is fetched async mgr/status: metadata is fetched async Reviewed-by: Jan Fajerski <jfajerski@suse.com> Reviewed-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/pybind/mgr/mgr_module.py7
-rw-r--r--src/pybind/mgr/status/module.py19
2 files changed, 17 insertions, 9 deletions
diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py
index ea9e073b937..8b4c3bb82c9 100644
--- a/src/pybind/mgr/mgr_module.py
+++ b/src/pybind/mgr/mgr_module.py
@@ -1063,7 +1063,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
"""
return self._ceph_get_server(None)
- def get_metadata(self, svc_type, svc_id):
+ def get_metadata(self, svc_type, svc_id, default=None):
"""
Fetch the daemon metadata for a particular service.
@@ -1076,7 +1076,10 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
calling this
:rtype: dict, or None if no metadata found
"""
- return self._ceph_get_metadata(svc_type, svc_id)
+ metadata = self._ceph_get_metadata(svc_type, svc_id)
+ if metadata is None:
+ return default
+ return metadata
def get_daemon_status(self, svc_type, svc_id):
"""
diff --git a/src/pybind/mgr/status/module.py b/src/pybind/mgr/status/module.py
index 89dde22f9e7..4cd8c2c714f 100644
--- a/src/pybind/mgr/status/module.py
+++ b/src/pybind/mgr/status/module.py
@@ -112,8 +112,10 @@ class Module(MgrModule):
if output_format not in ('json', 'json-pretty'):
activity = "Reqs: " + mgr_util.format_dimless(rate, 5) + "/s"
- metadata = self.get_metadata('mds', info['name'])
- mds_versions[metadata.get('ceph_version', "unknown")].append(info['name'])
+ defaults = defaultdict(lambda: None, {'version' : 'unknown'})
+ metadata = self.get_metadata('mds', info['name'], default=defaults)
+ mds_versions[metadata['ceph_version']].append(info['name'])
+
if output_format in ('json', 'json-pretty'):
json_output['mdsmap'].append({
'rank': rank,
@@ -159,8 +161,9 @@ class Module(MgrModule):
if output_format not in ('json', 'json-pretty'):
activity = "Evts: " + mgr_util.format_dimless(events, 5) + "/s"
- metadata = self.get_metadata('mds', daemon_info['name'])
- mds_versions[metadata.get('ceph_version', "unknown")].append(daemon_info['name'])
+ defaults = defaultdict(lambda: None, {'version' : 'unknown'})
+ metadata = self.get_metadata('mds', daemon_info['name'], default=defaults)
+ mds_versions[metadata['ceph_version']].append(daemon_info['name'])
if output_format in ('json', 'json-pretty'):
json_output['mdsmap'].append({
@@ -232,8 +235,9 @@ class Module(MgrModule):
standby_table.left_padding_width = 0
standby_table.right_padding_width = 2
for standby in fsmap['standbys']:
- metadata = self.get_metadata('mds', standby['name'])
- mds_versions[metadata.get('ceph_version', "unknown")].append(standby['name'])
+ defaults = defaultdict(lambda: None, {'version' : 'unknown'})
+ metadata = self.get_metadata('mds', standby['name'], default=defaults)
+ mds_versions[metadata['ceph_version']].append(standby['name'])
if output_format in ('json', 'json-pretty'):
json_output['mdsmap'].append({
@@ -323,7 +327,8 @@ class Module(MgrModule):
kb_avail = 0
if osd_id in osd_stats:
- metadata = self.get_metadata('osd', "%s" % osd_id)
+ defaults = defaultdict(lambda: None, {'hostname' : ''})
+ metadata = self.get_metadata('osd', str(osd_id), default=defaults)
stats = osd_stats[osd_id]
hostname = metadata['hostname']
kb_used = stats['kb_used'] * 1024