]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: fix redeploy when daemons have ip:port
authorSage Weil <sage@newdream.net>
Mon, 15 Mar 2021 19:34:13 +0000 (15:34 -0400)
committerSage Weil <sage@newdream.net>
Wed, 17 Mar 2021 21:24:32 +0000 (16:24 -0500)
The _daemon_action() method can be called directly by upgrade and by
the 'orch daemon <action> <name>' 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 <sage@newdream.net>
(cherry picked from commit 91490385d61b37c2e463e3d80dd873724f55d63a)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/serve.py
src/pybind/mgr/cephadm/services/cephadmservice.py
src/pybind/mgr/cephadm/upgrade.py

index d2618b40d07440bf4d620ec19499d11335361d42..b712f3a388a55b04a628afae69a1a3cd8e416dba 100644 (file)
@@ -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)
index 05761118f25f3cb9680bb4d30dc0157dddde9bab..e7c28acb041397e3cc3ede172d189a8a6f932110 100644 (file)
@@ -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)
index b7de0a488d6ac321a635e2b5301c9a784168cdbb..46c5f8ef895dacd7ff9169f5502da90cf4f29d4b 100644 (file)
@@ -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,
index fddabac28672763eefe1b58f4203c86afd25370c..cb47af306747a80b6c25ed63d7a5e8c8a4434e26 100644 (file)
@@ -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
                     )