]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Read ceph version from "io.ceph.version" label if set 32982/head
authorKristoffer Grönlund <kgronlund@suse.com>
Wed, 29 Jan 2020 13:40:37 +0000 (14:40 +0100)
committerKristoffer Grönlund <kgronlund@suse.com>
Fri, 31 Jan 2020 09:10:03 +0000 (10:10 +0100)
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 <kgronlund@suse.com>
src/cephadm/cephadm

index f2a6c9884fcfe970e767291dd332401376fb0a50..8bc6529c82cac1e83ead294e086f189618d87b5c 100755 (executable)
@@ -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