From: Daniel-Pivonka Date: Fri, 18 Dec 2020 15:51:31 +0000 (-0500) Subject: mgr/cephadm: fix bug in orch apply osd --dry-run where empty table printed X-Git-Tag: v16.1.0~166^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=459fa5777d400d5aa9eb7d4fe520369d47c775b9;p=ceph.git mgr/cephadm: fix bug in orch apply osd --dry-run where empty table printed Signed-off-by: Daniel-Pivonka --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 1286f8815ac4..3da7cf3d7527 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1793,9 +1793,9 @@ To check that the host is reachable: if not matching_hosts: return {'n/a': [{'error': True, 'message': 'No OSDSpec or matching hosts found.'}]} - # Is any host still loading previews + # Is any host still loading previews or still in the queue to be previewed pending_hosts = {h for h in self.cache.loading_osdspec_preview if h in matching_hosts} - if pending_hosts: + if pending_hosts or any(item in self.cache.osdspec_previews_refresh_queue for item in matching_hosts): # Report 'pending' when any of the matching hosts is still loading previews (flag is True) return {'n/a': [{'error': True, 'message': 'Preview data is being generated.. ' diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index 8a89a13a69fe..347f5ac83673 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -70,14 +70,26 @@ def to_format(what, format: str, many: bool, cls): raise OrchestratorError(f'unsupported format type: {format}') -def generate_preview_tables(data): +def generate_preview_tables(data, osd_only=False): error = [x.get('error') for x in data if x.get('error')] if error: return json.dumps(error) warning = [x.get('warning') for x in data if x.get('warning')] osd_table = preview_table_osd(data) service_table = preview_table_services(data) - tables = f""" + + if osd_only: + tables = f""" +{''.join(warning)} + +################ +OSDSPEC PREVIEWS +################ +{osd_table} +""" + return tables + else: + tables = f""" {''.join(warning)} #################### @@ -90,7 +102,7 @@ OSDSPEC PREVIEWS ################ {osd_table} """ - return tables + return tables def preview_table_osd(data): @@ -703,7 +715,7 @@ Examples: raise_if_exception(completion) data = completion.result if format == 'plain': - out = preview_table_osd(data) + out = generate_preview_tables(data, True) else: out = to_format(data, format, many=True, cls=None) return HandleCommandResult(stdout=out) @@ -730,7 +742,7 @@ Examples: self._orchestrator_wait([completion]) data = completion.result if format == 'plain': - out = preview_table_osd(data) + out = generate_preview_tables(data , True) else: out = to_format(data, format, many=True, cls=None) return HandleCommandResult(stdout=out)