mgr/cephadm: move RemoveUtil into OSDRemovalQueue

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
This commit is contained in:
Sebastian Wagner 2021-01-08 12:41:05 +01:00
parent af52ba47a1
commit df16b86c7b
3 changed files with 6 additions and 6 deletions

View File

@ -390,7 +390,6 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
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 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
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 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
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}'

View File

@ -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 @@ class OSDRemovalQueue(object):
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 @@ class OSDRemovalQueue(object):
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)

View File

@ -513,7 +513,7 @@ class TestCephadm(object):
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)