From: Kristoffer Grönlund Date: Wed, 29 Jan 2020 13:40:37 +0000 (+0100) Subject: cephadm: Read ceph version from "io.ceph.version" label if set X-Git-Tag: v15.1.1~543^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=412e122b410b20322c1f3471a3916b5760535756;p=ceph.git cephadm: Read ceph version from "io.ceph.version" label if set Having to run `ceph -v` in the container image to read the ceph version number is expensive and slow. Instead, look for a label (proposed: "io.ceph.version") on the container image and use the value of that label if present. See: https://github.com/ceph/ceph-container/issues/1508 See: https://tracker.ceph.com/issues/43678 Signed-off-by: Kristoffer Grönlund --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index f2a6c9884fcf..8bc6529c82ca 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2218,18 +2218,19 @@ def list_daemons(detail=True, legacy_dir=None): out, err, code = call( [ container_path, 'inspect', - '--format', '{{.Id}},{{.Config.Image}},{{%s}}' % image_field, + '--format', '{{.Id}},{{.Config.Image}},{{%s}},{{index .Config.Labels "io.ceph.version"}}' % image_field, 'ceph-%s-%s' % (fsid, j) ], verbose_on_failure=False) if not code: - (container_id, image_name, image_id) = out.strip().split(',') + (container_id, image_name, image_id, version) = out.strip().split(',') image_id = normalize_container_id(image_id) - out, err, code = call( - [container_path, 'exec', container_id, - 'ceph', '-v']) - if not code and out.startswith('ceph version '): - version = out.split(' ')[2] + 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] i['container_id'] = container_id i['container_image_name'] = image_name i['container_image_id'] = image_id