From: Sage Weil Date: Sat, 8 Feb 2020 17:32:58 +0000 (-0600) Subject: cephadm: fix ceph version probe X-Git-Tag: v15.1.1~491^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33136%2Fhead;p=ceph.git cephadm: fix ceph version probe docker returns '' if the label isn't present, in which case we still need to run ceph -v. Also, don't probe non-ceph (e.g., monitoring) containers. Also, only probe each image id once. Add a simple test. Signed-off-by: Sage Weil --- diff --git a/qa/workunits/cephadm/test_cephadm.sh b/qa/workunits/cephadm/test_cephadm.sh index c723e87b23f2..d82f6a7385f3 100755 --- a/qa/workunits/cephadm/test_cephadm.sh +++ b/qa/workunits/cephadm/test_cephadm.sh @@ -155,6 +155,9 @@ $CEPHADM ls | jq '.[]' | jq 'select(.name == "mon.a").fsid' \ $CEPHADM ls | jq '.[]' | jq 'select(.name == "mgr.x").fsid' \ | grep $FSID +# make sure the version is returned correctly +$CEPHADM ls | jq '.[]' | jq 'select(.name == "mon.a").version' | grep -q \\. + ## deploy # add mon.b cp $CONFIG $MONCONFIG diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 8e3fb8bb95f4..be0a2b481133 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2197,6 +2197,9 @@ def list_daemons(detail=True, legacy_dir=None): if legacy_dir is not None: data_dir = os.path.abspath(legacy_dir + data_dir) + # keep track of ceph versions we see + seen_versions = {} # type: Dict[str, Optional[str]] + # /var/lib/ceph if os.path.exists(data_dir): for i in os.listdir(data_dir): @@ -2268,12 +2271,21 @@ def list_daemons(detail=True, legacy_dir=None): if not code: (container_id, image_name, image_id, version) = out.strip().split(',') image_id = normalize_container_id(image_id) - if not version: - out, err, code = call( - [container_path, 'exec', container_id, - 'ceph', '-v']) - if not code and out.startswith('ceph version '): - version = out.split(' ')[2] + daemon_type = name.split('.', 1)[0] + if daemon_type in Ceph.daemons: + if not version or '.' not in version: + version = seen_versions.get(image_id, None) + if not version: + out, err, code = call( + [container_path, 'exec', container_id, + 'ceph', '-v']) + if not code and \ + out.startswith('ceph version '): + version = out.split(' ')[2] + seen_versions[image_id] = version + else: + # FIXME: monitoring component version? + pass i['container_id'] = container_id i['container_image_name'] = image_name i['container_image_id'] = image_id