From 132590edb67ed57ca0a314a33f50696272725671 Mon Sep 17 00:00:00 2001 From: Daniel-Pivonka Date: Fri, 18 Dec 2020 10:51:31 -0500 Subject: [PATCH] mgr/cephadm: fix bug in orch apply osd --dry-run where empty table printed Signed-off-by: Daniel-Pivonka (cherry picked from commit 459fa5777d400d5aa9eb7d4fe520369d47c775b9) --- src/pybind/mgr/cephadm/module.py | 4 ++-- src/pybind/mgr/orchestrator/module.py | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 21108220add22..31e2fb84a2ea5 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1683,9 +1683,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 b4a6b5f1e884a..7d9812a2e53d3 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -71,14 +71,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)} #################### @@ -91,7 +103,7 @@ OSDSPEC PREVIEWS ################ {osd_table} """ - return tables + return tables def preview_table_osd(data): @@ -706,7 +718,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) @@ -733,7 +745,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) -- 2.47.3