From: Sage Weil Date: Fri, 6 Mar 2020 03:24:53 +0000 (-0600) Subject: mgr/cephadm: do not specify --image arg for non-ceph daemons; fix upgrade X-Git-Tag: v15.1.1~83^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=725990f9d35c5aac8d94aa6c9518101908da1ea4;p=ceph.git mgr/cephadm: do not specify --image arg for non-ceph daemons; fix upgrade 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 --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 6771a44edfb..1390eef4a7c 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -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