From df16b86c7b6e1c11d35de4290a9e164962b4d057 Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 8 Jan 2021 12:41:05 +0100 Subject: [PATCH] mgr/cephadm: move RemoveUtil into OSDRemovalQueue Signed-off-by: Sebastian Wagner --- src/pybind/mgr/cephadm/module.py | 5 ++--- src/pybind/mgr/cephadm/services/osd.py | 5 +++-- src/pybind/mgr/cephadm/tests/test_cephadm.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 204d74bdd68e7..9608c9b50d492 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -390,7 +390,6 @@ def __init__(self, *args: Any, **kwargs: Any): self.cache = HostCache(self) self.cache.load() - self.rm_util = RemoveUtil(self) self.to_remove_osds = OSDRemovalQueue(self) self.to_remove_osds.load_from_store() @@ -2223,7 +2222,7 @@ def remove_osds(self, osd_ids: List[str], hostname=daemon.hostname, fullname=daemon.name(), process_started_at=datetime_now(), - remove_util=self.rm_util)) + remove_util=self.to_remove_osds.rm_util)) except NotFoundError: return f"Unable to find OSDs: {osd_ids}" @@ -2240,7 +2239,7 @@ def stop_remove_osds(self, osd_ids: List[str]) -> str: for osd_id in osd_ids: try: self.to_remove_osds.rm(OSD(osd_id=int(osd_id), - remove_util=self.rm_util)) + remove_util=self.to_remove_osds.rm_util)) except (NotFoundError, KeyError): return f'Unable to find OSD in the queue: {osd_id}' diff --git a/src/pybind/mgr/cephadm/services/osd.py b/src/pybind/mgr/cephadm/services/osd.py index 0b4abcb791390..2ad15873f0a41 100644 --- a/src/pybind/mgr/cephadm/services/osd.py +++ b/src/pybind/mgr/cephadm/services/osd.py @@ -600,6 +600,7 @@ class OSDRemovalQueue(object): def __init__(self, mgr: "CephadmOrchestrator") -> None: self.mgr: "CephadmOrchestrator" = mgr self.osds: Set[OSD] = set() + self.rm_util = RemoveUtil(mgr) def process_removal_queue(self) -> None: """ @@ -615,7 +616,7 @@ def process_removal_queue(self) -> None: f"for removal: {self.all_osds()}") # find osds that are ok-to-stop and not yet draining - ok_to_stop_osds = self.mgr.rm_util.find_osd_stop_threshold(self.idling_osds()) + ok_to_stop_osds = self.rm_util.find_osd_stop_threshold(self.idling_osds()) if ok_to_stop_osds: # start draining those _ = [osd.start_draining() for osd in ok_to_stop_osds] @@ -678,7 +679,7 @@ def load_from_store(self) -> None: for k, v in self.mgr.get_store_prefix('osd_remove_queue').items(): for osd in json.loads(v): logger.debug(f"Loading osd ->{osd} from store") - osd_obj = OSD.from_json(osd, rm_util=self.mgr.rm_util) + osd_obj = OSD.from_json(osd, rm_util=self.rm_util) if osd_obj is not None: self.osds.add(osd_obj) diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index d06b410b17bc0..ee62093bf2886 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -513,7 +513,7 @@ def test_remove_osds(self, cephadm_module): hostname='test', fullname='osd.0', process_started_at=datetime_now(), - remove_util=cephadm_module.rm_util + remove_util=cephadm_module.to_remove_osds.rm_util )) cephadm_module.to_remove_osds.process_removal_queue() assert cephadm_module.to_remove_osds == OSDRemovalQueue(cephadm_module)