]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: do not specify --image arg for non-ceph daemons; fix upgrade
authorSage Weil <sage@redhat.com>
Fri, 6 Mar 2020 03:24:53 +0000 (21:24 -0600)
committerSage Weil <sage@redhat.com>
Fri, 6 Mar 2020 03:28:36 +0000 (21:28 -0600)
If we are calling the cephadm script for a non-ceph daemon (prometheus,
etc), do not specify the --image argument, and do not pull it out of
the config db from sections that don't exist.

Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/cephadm/module.py

index 6771a44edfb1d2589b50c01f7ef9febc8393e372..1390eef4a7c4b5e584c0f753da32ce44a2851f15 100644 (file)
@@ -104,14 +104,19 @@ class OSDRemoval(NamedTuple):
 #  - bring over some of the protections from ceph-deploy that guard against
 #    multiple bootstrapping / initialization
 
-def _name_to_entity_name(name):
+CEPH_TYPES = ['mon', 'mgr', 'osd', 'mds', 'rbd-mirror', 'rgw', 'crash']
+
+def name_to_config_section(name):
     """
     Map from daemon names to ceph entity names (as seen in config)
     """
-    if name.startswith('rgw.') or name.startswith('rbd-mirror'):
+    daemon_type = name.split('.', 1)[0]
+    if daemon_type in ['rgw', 'rbd-mirror', 'crash']:
         return 'client.' + name
-    else:
+    elif daemon_type in ['mon', 'osd', 'mds', 'mgr', 'client']:
         return name
+    else:
+        return 'mon'
 
 def assert_valid_host(name):
     p = re.compile('^[a-zA-Z0-9-]+$')
@@ -842,7 +847,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
                     'prefix': 'config set',
                     'name': 'container_image',
                     'value': target_name,
-                    'who': daemon_type + '.' + d.daemon_id,
+                    'who': name_to_config_section(daemon_type + '.' + d.daemon_id),
                 })
                 self._daemon_action(
                     d.daemon_type,
@@ -932,7 +937,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
             ret, image, err = self.mon_command({
                 'prefix': 'config rm',
                 'name': 'container_image',
-                'who': daemon_type,
+                'who': name_to_config_section(daemon_type),
             })
 
         self.log.info('Upgrade: Complete!')
@@ -1406,6 +1411,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
                      no_fsid=False,
                      error_ok=False,
                      image=None):
+        # type: (str, Optional[str], str, List[str], Optional[str], Optional[str], bool, bool, Optional[str]) -> Tuple[List[str], List[str], int]
         """
         Run cephadm on the remote host with the given command + args
         """
@@ -1414,20 +1420,24 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule):
         conn, connr = self._get_connection(addr)
 
         try:
+            assert image or entity
             if not image:
-                # get container image
-                ret, image, err = self.mon_command({
-                    'prefix': 'config get',
-                    'who': _name_to_entity_name(entity),
-                    'key': 'container_image',
-                })
-                image = image.strip()
+                daemon_type = entity.split('.', 1)[0] # type: ignore
+                if daemon_type in CEPH_TYPES:
+                    # get container image
+                    ret, image, err = self.mon_command({
+                        'prefix': 'config get',
+                        'who': name_to_config_section(entity),
+                        'key': 'container_image',
+                    })
+                    image = image.strip() # type: ignore
             self.log.debug('%s container image %s' % (entity, image))
 
-            final_args = [
-                '--image', image,
-                command
-            ]
+            final_args = []
+            if image:
+                final_args.extend(['--image', image])
+            final_args.append(command)
+
             if not no_fsid:
                 final_args += ['--fsid', self._cluster_fsid]
             final_args += args