From: Sage Weil Date: Mon, 15 Mar 2021 19:34:13 +0000 (-0400) Subject: mgr/cephadm: fix redeploy when daemons have ip:port X-Git-Tag: v16.2.0~73^2~27 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=456608579d6482170bdffab37142cf15b56b54c0;p=ceph.git mgr/cephadm: fix redeploy when daemons have ip:port The _daemon_action() method can be called directly by upgrade and by the 'orch daemon ' commands. When this happens, construct a CephadmDaemonDeploySpec from the DaemonDescription that incldes the metadata we assigned when teh service was created: the IP and port(s). This fixes upgrade and the CLI. Signed-off-by: Sage Weil (cherry picked from commit 91490385d61b37c2e463e3d80dd873724f55d63a) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index d2618b40d0744..b712f3a388a55 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1685,29 +1685,22 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, for dd in dds ] - def _daemon_action(self, daemon_type: str, daemon_id: str, host: str, action: str, image: Optional[str] = None) -> str: - dd = DaemonDescription( - hostname=host, - daemon_type=daemon_type, - daemon_id=daemon_id - ) - daemon_spec: CephadmDaemonDeploySpec = CephadmDaemonDeploySpec( - host=host, - daemon_id=daemon_id, - daemon_type=daemon_type, - service_name=dd.service_name(), - ) - - self._daemon_action_set_image(action, image, daemon_type, daemon_id) - - if action == 'redeploy' and self.daemon_is_self(daemon_type, daemon_id): + def _daemon_action(self, + daemon_spec: CephadmDaemonDeploySpec, + action: str, + image: Optional[str] = None) -> str: + self._daemon_action_set_image(action, image, daemon_spec.daemon_type, + daemon_spec.daemon_id) + + if action == 'redeploy' and self.daemon_is_self(daemon_spec.daemon_type, + daemon_spec.daemon_id): self.mgr_service.fail_over() return '' # unreachable if action == 'redeploy' or action == 'reconfig': - if daemon_type != 'osd': + if daemon_spec.daemon_type != 'osd': daemon_spec = self.cephadm_services[daemon_type_to_service( - daemon_type)].prepare_create(daemon_spec) + daemon_spec.daemon_type)].prepare_create(daemon_spec) return CephadmServe(self)._create_daemon(daemon_spec, reconfig=(action == 'reconfig')) actions = { @@ -1719,10 +1712,10 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule, for a in actions[action]: try: out, err, code = CephadmServe(self)._run_cephadm( - host, name, 'unit', + daemon_spec.host, name, 'unit', ['--name', name, a]) except Exception: - self.log.exception(f'`{host}: cephadm unit {name} {a}` failed') + self.log.exception(f'`{daemon_spec.host}: cephadm unit {name} {a}` failed') self.cache.invalidate_host_daemons(daemon_spec.host) msg = "{} {} from host '{}'".format(action, name, daemon_spec.host) self.events.for_daemon(name, 'INFO', msg) diff --git a/src/pybind/mgr/cephadm/serve.py b/src/pybind/mgr/cephadm/serve.py index 05761118f25f3..e7c28acb04139 100644 --- a/src/pybind/mgr/cephadm/serve.py +++ b/src/pybind/mgr/cephadm/serve.py @@ -709,12 +709,8 @@ class CephadmServe: and action == 'reconfig': action = 'redeploy' try: - self.mgr._daemon_action( - daemon_type=dd.daemon_type, - daemon_id=dd.daemon_id, - host=dd.hostname, - action=action - ) + daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(dd) + self.mgr._daemon_action(daemon_spec, action=action) self.mgr.cache.rm_scheduled_daemon_action(dd.hostname, dd.name()) except OrchestratorError as e: self.mgr.events.from_orch_error(e) diff --git a/src/pybind/mgr/cephadm/services/cephadmservice.py b/src/pybind/mgr/cephadm/services/cephadmservice.py index b7de0a488d6ac..46c5f8ef895da 100644 --- a/src/pybind/mgr/cephadm/services/cephadmservice.py +++ b/src/pybind/mgr/cephadm/services/cephadmservice.py @@ -76,6 +76,20 @@ class CephadmDaemonDeploySpec: return files + @staticmethod + def from_daemon_description(dd: DaemonDescription) -> 'CephadmDaemonDeploySpec': + assert dd.hostname + assert dd.daemon_id + assert dd.daemon_type + return CephadmDaemonDeploySpec( + host=dd.hostname, + daemon_id=dd.daemon_id, + daemon_type=dd.daemon_type, + service_name=dd.service_name(), + ip=dd.ip, + ports=dd.ports, + ) + def to_daemon_description(self, status: DaemonDescriptionStatus, status_desc: str) -> DaemonDescription: return DaemonDescription( daemon_type=self.daemon_type, diff --git a/src/pybind/mgr/cephadm/upgrade.py b/src/pybind/mgr/cephadm/upgrade.py index fddabac286727..cb47af306747a 100644 --- a/src/pybind/mgr/cephadm/upgrade.py +++ b/src/pybind/mgr/cephadm/upgrade.py @@ -6,6 +6,7 @@ from typing import TYPE_CHECKING, Optional, Dict, List, Tuple import orchestrator from cephadm.serve import CephadmServe +from cephadm.services.cephadmservice import CephadmDaemonDeploySpec from cephadm.utils import ceph_release_to_major, name_to_config_section, CEPH_UPGRADE_ORDER from orchestrator import OrchestratorError, DaemonDescription, daemon_type_to_service @@ -566,10 +567,9 @@ class CephadmUpgrade: logger.info('Upgrade: Updating %s.%s' % (d.daemon_type, d.daemon_id)) try: + daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(d) self.mgr._daemon_action( - d.daemon_type, - d.daemon_id, - d.hostname, + daemon_spec, 'redeploy', image=target_image )