Skip to content

Commit

Permalink
mgr/cephadm: rename OSDQueue -> 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 72cc819 commit e0f9983
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from .services.iscsi import IscsiService
from .services.ha_rgw import HA_RGWService
from .services.nfs import NFSService
from .services.osd import RemoveUtil, OSDQueue, OSDService, OSD, NotFoundError
from .services.osd import RemoveUtil, OSDRemovalQueue, OSDService, OSD, NotFoundError
from .services.monitoring import GrafanaService, AlertmanagerService, PrometheusService, \
NodeExporterService
from .schedule import HostAssignment
Expand Down Expand Up @@ -391,7 +391,7 @@ def __init__(self, *args: Any, **kwargs: Any):
self.cache.load()

self.rm_util = RemoveUtil(self)
self.to_remove_osds = OSDQueue()
self.to_remove_osds = OSDRemovalQueue()
self.rm_util.load_from_store()

self.spec_store = SpecStore(self)
Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/cephadm/services/osd.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def __repr__(self) -> str:
return f"<OSD>(osd_id={self.osd_id}, draining={self.draining})"


class OSDQueue(Set):
class OSDRemovalQueue(Set):

def __init__(self) -> None:
super().__init__()
Expand Down
4 changes: 2 additions & 2 deletions src/pybind/mgr/cephadm/tests/test_cephadm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ceph.deployment.drive_group import DriveGroupSpec, DeviceSelection
from cephadm.serve import CephadmServe
from cephadm.services.osd import OSD, OSDQueue
from cephadm.services.osd import OSD, OSDRemovalQueue

try:
from typing import Any, List
Expand Down Expand Up @@ -516,7 +516,7 @@ def test_remove_osds(self, cephadm_module):
remove_util=cephadm_module.rm_util
))
cephadm_module.rm_util.process_removal_queue()
assert cephadm_module.to_remove_osds == OSDQueue()
assert cephadm_module.to_remove_osds == OSDRemovalQueue()

c = cephadm_module.remove_osds_status()
out = wait(cephadm_module, c)
Expand Down
15 changes: 8 additions & 7 deletions src/pybind/mgr/cephadm/tests/test_osd_removal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from cephadm.services.osd import RemoveUtil, OSDQueue, OSD
from cephadm.services.osd import RemoveUtil, OSDRemovalQueue, OSD
import pytest
from .fixtures import rm_util, osd_obj, cephadm_module
from tests import mock
Expand Down Expand Up @@ -92,7 +92,8 @@ def test_load(self, cephadm_module):
cephadm_module.set_store('osd_remove_queue', data)
cephadm_module.rm_util.load_from_store()

assert repr(cephadm_module.to_remove_osds) == 'OSDQueue({<OSD>(osd_id=35, draining=True)})'
assert repr(
cephadm_module.to_remove_osds) == 'OSDRemovalQueue({<OSD>(osd_id=35, draining=True)})'


class TestOSD:
Expand Down Expand Up @@ -213,33 +214,33 @@ def test_drain_status_human_done(self, osd_obj):
assert osd_obj.drain_status_human() == 'done, waiting for purge'


class TestOSDQueue:
class TestOSDRemovalQueue:

def test_queue_size(self, osd_obj):
q = OSDQueue()
q = OSDRemovalQueue()
assert q.queue_size() == 0
q.add(osd_obj)
assert q.queue_size() == 1

@mock.patch("cephadm.services.osd.OSD.start")
@mock.patch("cephadm.services.osd.OSD.exists")
def test_enqueue(self, exist, start, osd_obj):
q = OSDQueue()
q = OSDRemovalQueue()
q.enqueue(osd_obj)
osd_obj.start.assert_called_once()

@mock.patch("cephadm.services.osd.OSD.stop")
@mock.patch("cephadm.services.osd.OSD.exists")
def test_rm_raise(self, exist, stop, osd_obj):
q = OSDQueue()
q = OSDRemovalQueue()
with pytest.raises(KeyError):
q.rm(osd_obj)
osd_obj.stop.assert_called_once()

@mock.patch("cephadm.services.osd.OSD.stop")
@mock.patch("cephadm.services.osd.OSD.exists")
def test_rm(self, exist, stop, osd_obj):
q = OSDQueue()
q = OSDRemovalQueue()
q.add(osd_obj)
q.rm(osd_obj)
osd_obj.stop.assert_called_once()
2 changes: 1 addition & 1 deletion src/pybind/mgr/cephadm/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RbdMirrorService, CrashService, CephadmService, AuthEntity, CephadmExporter
from cephadm.services.iscsi import IscsiService
from cephadm.services.nfs import NFSService
from cephadm.services.osd import RemoveUtil, OSDQueue, OSDService, OSD, NotFoundError
from cephadm.services.osd import RemoveUtil, OSDRemovalQueue, OSDService, OSD, NotFoundError
from cephadm.services.monitoring import GrafanaService, AlertmanagerService, PrometheusService, \
NodeExporterService

Expand Down

0 comments on commit e0f9983

Please sign in to comment.