From 497703cf62735efe10b17f16b1de0efff9779b55 Mon Sep 17 00:00:00 2001 From: Adam King Date: Wed, 3 Mar 2021 12:24:57 -0500 Subject: [PATCH] mgr/cephadm: add container digests of mgr that deployed daemon to unit.meta For use in upgrade. It's useful to see if daemon was deployed by mgr running same container digest as container we are upgrading to. Signed-off-by: Adam King (cherry picked from commit baa95a7a13ceef0292f163af6c7c7c74d8a21420) --- src/pybind/mgr/cephadm/module.py | 5 +++++ src/pybind/mgr/cephadm/serve.py | 2 ++ src/pybind/mgr/cephadm/tests/test_cephadm.py | 2 +- src/pybind/mgr/orchestrator/_interface.py | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 4ee7c043d99d1..072db303bdf19 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1757,6 +1757,11 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, def daemon_is_self(self, daemon_type: str, daemon_id: str) -> bool: return daemon_type == 'mgr' and daemon_id == self.get_mgr_id() + def get_active_mgr_digests(self) -> List[str]: + digests = self.mgr_service.get_active_daemon( + self.cache.get_daemons_by_type('mgr')).container_image_digests + return digests if digests else [] + def _schedule_daemon_action(self, daemon_name: str, action: str) -> str: dd = self.cache.get_daemon(daemon_name) assert dd.daemon_type is not None diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 0364709e4ec55..824f674807523 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -279,6 +279,7 @@ class CephadmServe: sd.memory_request = d.get('memory_request') sd.memory_limit = d.get('memory_limit') sd._service_name = d.get('service_name') + sd.deployed_by = d.get('deployed_by') sd.version = d.get('version') sd.ports = d.get('ports') sd.ip = d.get('ip') @@ -883,6 +884,7 @@ class CephadmServe: 'service_name': daemon_spec.service_name, 'ports': daemon_spec.ports, 'ip': daemon_spec.ip, + 'deployed_by': self.mgr.get_active_mgr_digests(), }), '--config-json', '-', ] + daemon_spec.extra_args, diff --git a/src/pybind/mgr/cephadm/tests/test_cephadm.py b/src/pybind/mgr/cephadm/tests/test_cephadm.py index 2b396c8547e7e..2bf645de61964 100644 --- a/src/pybind/mgr/cephadm/tests/test_cephadm.py +++ b/src/pybind/mgr/cephadm/tests/test_cephadm.py @@ -289,7 +289,7 @@ class TestCephadm(object): _run_cephadm.assert_called_with( 'test', 'mon.test', 'deploy', [ '--name', 'mon.test', - '--meta-json', '{"service_name": "mon", "ports": [], "ip": null}', + '--meta-json', '{"service_name": "mon", "ports": [], "ip": null, "deployed_by": []}', '--config-json', '-', '--reconfig', ], diff --git a/src/pybind/mgr/orchestrator/_interface.py b/src/pybind/mgr/orchestrator/_interface.py index 167553af6ebbe..dec6b0ad5d9a6 100644 --- a/src/pybind/mgr/orchestrator/_interface.py +++ b/src/pybind/mgr/orchestrator/_interface.py @@ -793,6 +793,7 @@ class DaemonDescription(object): service_name: Optional[str] = None, ports: Optional[List[int]] = None, ip: Optional[str] = None, + deployed_by: Optional[List[str]] = None, ) -> None: # Host is at the same granularity as InventoryHost @@ -847,6 +848,8 @@ class DaemonDescription(object): self.ports: Optional[List[int]] = ports self.ip: Optional[str] = ip + + self.deployed_by = deployed_by self.is_active = is_active -- 2.39.5