From: Sebastian Wagner Date: Wed, 8 Sep 2021 14:23:32 +0000 (+0200) Subject: mgr/cephadm: check_for_moved_osds: Add OrchEvent X-Git-Tag: v17.1.0~421^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=25d27fb6c1bd3520564e624965fa3b6f81a21ac0;p=ceph-ci.git mgr/cephadm: check_for_moved_osds: Add OrchEvent Signed-off-by: Sebastian Wagner --- diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 274fa6bb5fb..0bab2b80049 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -534,6 +534,8 @@ class CephadmServe: assert e.hostname try: self._remove_daemon(e.name(), e.hostname) + self.mgr.events.for_daemon( + e.name(), 'INFO', f"Removed duplicated daemon on host '{e.hostname}'") except OrchestratorError as ex: self.mgr.events.from_orch_error(ex) logger.exception(f'failed to remove duplicated daemon {e}') diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index be8f3aad059..9e3e4f91ab6 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -20,7 +20,7 @@ from ceph.deployment.drive_selection.selector import DriveSelection from ceph.deployment.inventory import Devices, Device from ceph.utils import datetime_to_str, datetime_now from orchestrator import DaemonDescription, InventoryHost, \ - HostSpec, OrchestratorError, DaemonDescriptionStatus + HostSpec, OrchestratorError, DaemonDescriptionStatus, OrchestratorEvent from tests import mock from .fixtures import wait, _run_cephadm, match_glob, with_host, \ with_cephadm_module, with_service, _deploy_cephadm_binary @@ -920,6 +920,15 @@ class TestCephadm(object): assert len(cephadm_module.cache.get_daemons()) == 1 + assert cephadm_module.events.get_for_daemon('osd.1') == [ + OrchestratorEvent(mock.ANY, 'daemon', 'osd.1', 'INFO', + "Deployed osd.1 on host 'host1'"), + OrchestratorEvent(mock.ANY, 'daemon', 'osd.1', 'INFO', + "Deployed osd.1 on host 'host2'"), + OrchestratorEvent(mock.ANY, 'daemon', 'osd.1', 'INFO', + "Removed duplicated daemon on host 'host2'"), + ] + @pytest.mark.parametrize( "spec", [ diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index abc25a53fd8..8a36deebb1a 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -1366,6 +1366,9 @@ class OrchestratorEvent: return self.created == other.created and self.kind == other.kind \ and self.subject == other.subject and self.message == other.message + def __repr__(self) -> str: + return f'OrchestratorEvent.from_json({self.to_json()!r})' + def _mk_orch_methods(cls: Any) -> Any: # Needs to be defined outside of for.