From: Sage Weil Date: Thu, 23 Jan 2020 19:43:58 +0000 (-0600) Subject: mgr/cephadm: get --osd-uuid deploy arg from osdmap X-Git-Tag: v15.1.0~31^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=b305796a1252374dccb7bd2d98b2224f8a8fed8f;p=ceph-ci.git mgr/cephadm: get --osd-uuid deploy arg from osdmap During the initial OSD creation, we had the osd_uuid handy. However, on reconfig/redeploy, we don't. Refactor a bit so that this is extracted from the osdmap by the _create_daemon() method. While we're at it, make the deployment case verify that the deployed OSD uuid matches the one in the osdmap. Signed-off-by: Sage Weil --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 60d6f24a0ac..c5d74910d1d 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1189,6 +1189,14 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): return blink(locs) + def get_osd_uuid_map(self): + # type: () -> Dict[str,str] + osd_map = self.get('osd_map') + r = {} + for o in osd_map['osds']: + r[str(o['osd'])] = o['uuid'] + return r + @async_completion def _create_osd(self, all_hosts_, drive_group): all_hosts = orchestrator.InventoryNode.get_host_names(all_hosts_) @@ -1242,6 +1250,7 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): self.log.debug('code %s out %s' % (code, out)) osds_elems = json.loads('\n'.join(out)) fsid = self._cluster_fsid + osd_uuid_map = self.get_osd_uuid_map() for osd_id, osds in osds_elems.items(): for osd in osds: if osd['tags']['ceph.cluster_fsid'] != fsid: @@ -1250,13 +1259,19 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): if len(list(set(devices) & set(osd['devices']))) == 0 and osd.get('lv_path') not in devices: self.log.debug('mismatched devices, skipping %s' % osd) continue + if osd_id not in osd_uuid_map: + self.log.debug('osd id %d does not exist in cluster' % osd_id) + continue + if osd_uuid_map[osd_id] != osd['tags']['ceph.osd_fsid']: + self.log.debug('mismatched osd uuid (cluster has %s, osd ' + 'has %s)' % ( + osd_uuid_map[osd_id], + osd['tags']['ceph.osd_fsid'])) + continue - # create self._create_daemon( - 'osd', str(osd_id), host, - extra_args=[ - '--osd-fsid', osd['tags']['ceph.osd_fsid'], - ]) + 'osd', osd_id, host, + osd_uuid_map=osd_uuid_map) return "Created osd(s) on host '{}'".format(host) @@ -1291,18 +1306,21 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): def _create_daemon(self, daemon_type, daemon_id, host, keyring=None, extra_args=None, extra_config=None, - reconfig=False): + reconfig=False, + osd_uuid_map=None): if not extra_args: extra_args = [] name = '%s.%s' % (daemon_type, daemon_id) # keyring if not keyring: + if daemon_type == 'mon': + ename = 'mon.' + else: + ename = '%s.%s' % (daemon_type, daemon_id) ret, keyring, err = self.mon_command({ 'prefix': 'auth get', - 'entity': '%s.%s' % str( - daemon_type, - daemon_id if daemon_type != 'mon' else ''), + 'entity': ename, }) # generate config @@ -1326,6 +1344,15 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin): 'crash_keyring': crash_keyring, }) + # osd deployments needs an --osd-uuid arg + if daemon_type == 'osd': + if not osd_uuid_map: + osd_uuid_map = self.get_osd_uuid_map() + osd_uuid = osd_uuid_map.get(daemon_id, None) + if not osd_uuid: + raise OrchestratorError('osd.%d not in osdmap' % daemon_id) + extra_args.extend(['--osd-fsid', osd_uuid]) + if reconfig: extra_args.append('--reconfig')