Skip to content

Commit

Permalink
mgr/cephadm: move RemoveUtil into OSDRemovalQueue
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Wagner <[email protected]>
  • Loading branch information
sebastian-philipp committed Jan 14, 2021
1 parent af52ba4 commit df16b86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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}"

Expand All @@ -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}'

Expand Down
5 changes: 3 additions & 2 deletions src/pybind/mgr/cephadm/services/osd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -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]
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/cephadm/tests/test_cephadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit df16b86

Please sign in to comment.