From a66793034d653805f259d8f16fafb49234600ed3 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Tue, 17 Mar 2020 11:52:54 +0100 Subject: [PATCH] mgr/cephadm: apply_drivegroups() returns a single Completion Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/tests/test_cephadm.py | 4 ++-- src/pybind/mgr/orchestrator/_interface.py | 2 +- src/pybind/mgr/orchestrator/module.py | 9 ++++----- src/pybind/mgr/test_orchestrator/module.py | 6 +++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 63766ee432c88..c32d8f1cee277 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -125,8 +125,8 @@ class TestCephadm(object): spec = ServiceSpec.from_json(json_spec) assert isinstance(spec, DriveGroupSpec) c = cephadm_module.apply_drivegroups([spec]) + assert wait(cephadm_module, c) == ['Scheduled osd update...'] _save_spec.assert_called_with(spec) - assert wait(cephadm_module, c[0]) == 'Scheduled osd update...' @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) @mock.patch("cephadm.module.SpecStore.save") @@ -136,8 +136,8 @@ class TestCephadm(object): spec = ServiceSpec.from_json(json_spec) assert isinstance(spec, DriveGroupSpec) c = cephadm_module.apply_drivegroups([spec]) + assert wait(cephadm_module, c) == ['Scheduled osd update...'] _save_spec.assert_called_with(spec) - assert wait(cephadm_module, c[0]) == 'Scheduled osd update...' @mock.patch("cephadm.module.CephadmOrchestrator._run_cephadm", _run_cephadm('{}')) def test_create_osds(self, cephadm_module): diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 5331fdb9780a9..c03753c0dbb93 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -913,7 +913,7 @@ class Orchestrator(object): """ raise NotImplementedError() - def apply_drivegroups(self, specs: List[DriveGroupSpec]) -> Sequence[Completion]: + def apply_drivegroups(self, specs: List[DriveGroupSpec]) -> Completion: """ Update OSD cluster """ raise NotImplementedError() diff --git a/src/pybind/mgr/orchestrator/module.py b/src/pybind/mgr/orchestrator/module.py index e1355ef375ea3..a405cf42cdbd8 100644 --- a/src/pybind/mgr/orchestrator/module.py +++ b/src/pybind/mgr/orchestrator/module.py @@ -465,11 +465,10 @@ Usage: ) ] - completions = self.apply_drivegroups(dg_specs) - [self._orchestrator_wait([completion]) for completion in completions] # type: ignore - [raise_if_exception(completion) for completion in completions] # type: ignore - result_strings = [completion.result_str() for completion in completions] - return HandleCommandResult(stdout=" ".join(result_strings)) + completion = self.apply_drivegroups(dg_specs) + self._orchestrator_wait([completion]) + raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) @_cli_write_command( 'orch daemon add osd', diff --git a/src/pybind/mgr/test_orchestrator/module.py b/src/pybind/mgr/test_orchestrator/module.py index 10fa8482e6ba6..1483ca1995bc1 100644 --- a/src/pybind/mgr/test_orchestrator/module.py +++ b/src/pybind/mgr/test_orchestrator/module.py @@ -259,7 +259,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): ) def apply_drivegroups(self, specs): - # type: (List[DriveGroupSpec]) -> Sequence[TestCompletion] + # type: (List[DriveGroupSpec]) -> TestCompletion drive_group = specs[0] def run(all_hosts): # type: (List[orchestrator.HostSpec]) -> None @@ -267,12 +267,12 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator): if drive_group.placement.host_pattern: if not drive_group.placement.pattern_matches_hosts([h.hostname for h in all_hosts]): raise orchestrator.OrchestratorValidationError('failed to match') - return [self.get_hosts().then(run).then( + return self.get_hosts().then(run).then( on_complete=orchestrator.ProgressReference( message='apply_drivesgroups', mgr=self, ) - )] + ) @deferred_write("remove_daemons") def remove_daemons(self, names): -- 2.39.5