if not osd.exists:
continue
- self.mgr._remove_daemon(osd.fullname, osd.nodename)
- logger.info(f"Successfully removed OSD <{osd.osd_id}> on {osd.nodename}")
+ self.mgr._remove_daemon(osd.fullname, osd.hostname)
+ logger.info(f"Successfully removed OSD <{osd.osd_id}> on {osd.hostname}")
logger.debug(f"Removing {osd.osd_id} from the queue.")
# self.mgr.to_remove_osds could change while this is processing (osds get added from the CLI)
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(json.loads(osd), ctx=self)
+ osd_obj = OSD.from_json(osd, ctx=self)
self.mgr.to_remove_osds.add(osd_obj)
# If we wait for the osd to be drained
self.force = force
# The name of the node
- self.nodename = hostname
+ self.hostname = hostname
# The full name of the osd
self.fullname = fullname
out['stopped'] = self.stopped
out['replace'] = self.replace
out['force'] = self.force
- out['nodename'] = self.nodename # type: ignore
+ out['hostname'] = self.hostname # type: ignore
for k in ['drain_started_at', 'drain_stopped_at', 'drain_done_at', 'process_started_at']:
if getattr(self, k):
if inp.get(date_field):
inp.update({date_field: datetime.strptime(inp.get(date_field, ''), DATEFMT)})
inp.update({'remove_util': ctx})
+ if 'nodename' in inp:
+ hostname = inp.pop('nodename')
+ inp['hostname'] = hostname
return cls(**inp)
def __hash__(self):
return self.osd_id == other.osd_id
def __repr__(self) -> str:
- return f"<OSD>(osd_id={self.osd_id}, is_draining={self.is_draining})"
+ return f"<OSD>(osd_id={self.osd_id}, draining={self.draining})"
class OSDQueue(Set):
+import json
+
from cephadm.services.osd import RemoveUtil, OSDQueue, OSD
import pytest
-from .fixtures import rm_util, osd_obj
+from .fixtures import rm_util, osd_obj, cephadm_module
from tests import mock
from datetime import datetime
rm_util._run_mon_cmd.assert_called_with(
{'prefix': 'osd purge-actual', 'id': 1, 'yes_i_really_mean_it': True})
+ def test_load(self, cephadm_module):
+ data = json.dumps([
+ {
+ "osd_id": 35,
+ "started": True,
+ "draining": True,
+ "stopped": False,
+ "replace": False,
+ "force": False,
+ "nodename": "node2",
+ "drain_started_at": "2020-09-14T11:41:53.960463",
+ "drain_stopped_at": None,
+ "drain_done_at": None,
+ "process_started_at": "2020-09-14T11:41:52.245832"
+ }
+ ])
+ 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)})'
+
class TestOSD:
table.left_padding_width = 0
table.right_padding_width = 2
for osd in sorted(report, key=lambda o: o.osd_id):
- table.add_row([osd.osd_id, osd.nodename, osd.drain_status_human(),
+ table.add_row([osd.osd_id, osd.hostname, osd.drain_status_human(),
osd.get_pg_count(), osd.replace, osd.replace, osd.drain_started_at])
out = table.get_string()