From ad3f576dde1fdc64a94d50f648052f42f5338fef Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sat, 26 Nov 2022 08:39:54 +0000 Subject: [PATCH] mgr/cephadm: allow _run_cephadm_json to be silent on error Signed-off-by: Mykola Golub --- src/pybind/mgr/cephadm/serve.py | 4 +++- src/pybind/mgr/cephadm/tests/test_cephadm.py | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 364f8324dc0..264dcfb2da4 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -1380,12 +1380,14 @@ class CephadmServe: command: str, args: List[str], no_fsid: Optional[bool] = False, + error_ok: Optional[bool] = False, image: Optional[str] = "", log_output: Optional[bool] = True, ) -> Any: try: out, err, code = await self._run_cephadm( - host, entity, command, args, no_fsid=no_fsid, image=image, log_output=log_output) + host, entity, command, args, no_fsid=no_fsid, error_ok=error_ok, + image=image, log_output=log_output) if code: raise OrchestratorError(f'host {host} `cephadm {command}` returned {code}: {err}') except Exception as e: diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 0d8f3201ab1..a64180e8a5c 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -876,9 +876,9 @@ class TestCephadm(object): env_vars=['CEPH_VOLUME_OSDSPEC_AFFINITY=foo'], error_ok=True, stdin='{"config": "", "keyring": ""}') _run_cephadm.assert_any_call( - 'test', 'osd', 'ceph-volume', ['--', 'lvm', 'list', '--format', 'json'], image='', no_fsid=False, log_output=True) + 'test', 'osd', 'ceph-volume', ['--', 'lvm', 'list', '--format', 'json'], image='', no_fsid=False, error_ok=False, log_output=True) _run_cephadm.assert_any_call( - 'test', 'osd', 'ceph-volume', ['--', 'raw', 'list', '--format', 'json'], image='', no_fsid=False, log_output=True) + 'test', 'osd', 'ceph-volume', ['--', 'raw', 'list', '--format', 'json'], image='', no_fsid=False, error_ok=False, log_output=True) @mock.patch("cephadm.serve.CephadmServe._run_cephadm") def test_apply_osd_save_non_collocated(self, _run_cephadm, cephadm_module: CephadmOrchestrator): @@ -918,9 +918,9 @@ class TestCephadm(object): env_vars=['CEPH_VOLUME_OSDSPEC_AFFINITY=noncollocated'], error_ok=True, stdin='{"config": "", "keyring": ""}') _run_cephadm.assert_any_call( - 'test', 'osd', 'ceph-volume', ['--', 'lvm', 'list', '--format', 'json'], image='', no_fsid=False, log_output=True) + 'test', 'osd', 'ceph-volume', ['--', 'lvm', 'list', '--format', 'json'], image='', no_fsid=False, error_ok=False, log_output=True) _run_cephadm.assert_any_call( - 'test', 'osd', 'ceph-volume', ['--', 'raw', 'list', '--format', 'json'], image='', no_fsid=False, log_output=True) + 'test', 'osd', 'ceph-volume', ['--', 'raw', 'list', '--format', 'json'], image='', no_fsid=False, error_ok=False, log_output=True) @mock.patch("cephadm.serve.CephadmServe._run_cephadm", _run_cephadm('{}')) @mock.patch("cephadm.module.SpecStore.save") -- 2.39.5