Skip to content

Commit

Permalink
mgr/cephadm: OSDRemovalQueue: remove some trivial wrappers
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 df16b86 commit 1f39532
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
13 changes: 2 additions & 11 deletions src/pybind/mgr/cephadm/services/osd.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,13 @@ def process_removal_queue(self) -> None:
# self could change while this is processing (osds get added from the CLI)
# The new set is: 'an intersection of all osds that are still not empty/removed (new_queue) and
# osds that were added while this method was executed'
self.intersection_update(new_queue)
self.osds.intersection_update(new_queue)
self.save_to_store()

def cleanup(self) -> None:
# OSDs can always be cleaned up manually. This ensures that we run on existing OSDs
for osd in self.not_in_cluster():
self.remove(osd)
self.osds.remove(osd)

def save_to_store(self) -> None:
osd_queue = [osd.to_json() for osd in self.all_osds()]
Expand Down Expand Up @@ -721,15 +721,6 @@ def rm(self, osd: "OSD") -> None:
logger.debug(f"Could not find {osd} in queue.")
raise KeyError

def remove(self, osd: OSD) -> None:
self.osds.remove(osd)

def add(self, osd: OSD) -> None:
self.osds.add(osd)

def intersection_update(self, other: Set[OSD]) -> None:
self.osds.intersection_update(other)

def __eq__(self, other: Any) -> bool:
if not isinstance(other, OSDRemovalQueue):
return False
Expand Down
6 changes: 3 additions & 3 deletions src/pybind/mgr/cephadm/tests/test_osd_removal.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_load(self, cephadm_module, rm_util):
cephadm_module.to_remove_osds.load_from_store()

expected = OSDRemovalQueue(cephadm_module)
expected.add(OSD(osd_id=35, remove_util=rm_util, draining=True))
expected.osds.add(OSD(osd_id=35, remove_util=rm_util, draining=True))
assert cephadm_module.to_remove_osds == expected


Expand Down Expand Up @@ -220,7 +220,7 @@ class TestOSDRemovalQueue:
def test_queue_size(self, osd_obj):
q = OSDRemovalQueue(mock.Mock())
assert q.queue_size() == 0
q.add(osd_obj)
q.osds.add(osd_obj)
assert q.queue_size() == 1

@mock.patch("cephadm.services.osd.OSD.start")
Expand All @@ -242,6 +242,6 @@ def test_rm_raise(self, exist, stop, osd_obj):
@mock.patch("cephadm.services.osd.OSD.exists")
def test_rm(self, exist, stop, osd_obj):
q = OSDRemovalQueue(mock.Mock())
q.add(osd_obj)
q.osds.add(osd_obj)
q.rm(osd_obj)
osd_obj.stop.assert_called_once()

0 comments on commit 1f39532

Please sign in to comment.