From: Michael Fritch Date: Tue, 22 Jun 2021 22:42:47 +0000 (-0600) Subject: cephadm: infer fsid from ceph.conf X-Git-Tag: v17.1.0~1355^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e35271adfcfd64ca19aee58b334eb1aaf3855ef4;p=ceph.git cephadm: infer fsid from ceph.conf Fixes: https://tracker.ceph.com/issues/51328 Signed-off-by: Michael Fritch --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 6d8e0a2f913d..3ce939bec434 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -1647,13 +1647,19 @@ def infer_fsid(func): """ If we only find a single fsid in /var/lib/ceph/*, use that """ + @infer_config @wraps(func) def _infer_fsid(ctx: CephadmContext): if ctx.fsid: logger.debug('Using specified fsid: %s' % ctx.fsid) return func(ctx) - fsids_set = set() + fsids = set() + + cp = read_config(ctx.config) + if cp.has_option('global', 'fsid'): + fsids.add(cp.get('global', 'fsid')) + daemon_list = list_daemons(ctx, detail=False) for daemon in daemon_list: if not is_fsid(daemon['fsid']): @@ -1661,11 +1667,11 @@ def infer_fsid(func): continue elif 'name' not in ctx or not ctx.name: # ctx.name not specified - fsids_set.add(daemon['fsid']) + fsids.add(daemon['fsid']) elif daemon['name'] == ctx.name: # ctx.name is a match - fsids_set.add(daemon['fsid']) - fsids = sorted(fsids_set) + fsids.add(daemon['fsid']) + fsids = sorted(fsids) if not fsids: # some commands do not always require an fsid @@ -4455,24 +4461,15 @@ def command_run(ctx): ################################## -def fsid_conf_mismatch(ctx): - # type: (CephadmContext) -> bool - (config, _) = get_config_and_keyring(ctx) - if config: - for c in config.split('\n'): - if 'fsid = ' in c.strip(): - if 'fsid = ' + ctx.fsid != c.strip(): - return True - return False - - @infer_fsid @infer_config @infer_image def command_shell(ctx): # type: (CephadmContext) -> int - if fsid_conf_mismatch(ctx): - raise Error('fsid does not match ceph conf') + cp = read_config(ctx.config) + if cp.has_option('global', 'fsid') and \ + cp.get('global', 'fsid') != ctx.fsid: + raise Error('fsid does not match ceph.conf') if ctx.fsid: make_log_dir(ctx, ctx.fsid)