From: Redouane Kachach Date: Fri, 22 Apr 2022 13:53:34 +0000 (+0200) Subject: mgr/cephadm: Using '.ID' instead of '.Id' which is only supported by podman X-Git-Tag: v18.0.0~998^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6e7c0488389e7e8b85f0dbd6b71c8627a44b349e;p=ceph.git mgr/cephadm: Using '.ID' instead of '.Id' which is only supported by podman Signed-off-by: Redouane Kachach --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 94de89a3b246c..c61c568710438 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -2115,7 +2115,7 @@ def infer_local_ceph_image(ctx: CephadmContext, container_path: str) -> Optional [container_path, 'images', '--filter', 'label=ceph=True', '--filter', 'dangling=false', - '--format', '{{.Repository}}@{{.Digest}}|{{.Id}}|{{.Tag}}|{{.CreatedAt}}']) + '--format', '{{.Repository}}@{{.Digest}}|{{.ID}}|{{.Tag}}|{{.CreatedAt}}']) container_info = None daemon_name = ctx.name if ('name' in ctx and ctx.name and '.' in ctx.name) else None @@ -2129,10 +2129,10 @@ def infer_local_ceph_image(ctx: CephadmContext, container_path: str) -> Optional for image in out.splitlines(): if image and not image.isspace(): (digest, image_id, tag, created_date) = image.lstrip().split('|') - if container_info is not None and container_info.image_id != image_id: + if container_info is not None and image_id not in container_info.image_id: continue if digest and not digest.endswith('@'): - logger.info(f"Using ceph image with id '{image_id[:12]}' and tag '{tag}' created on {created_date}\n{digest}") + logger.info(f"Using ceph image with id '{image_id}' and tag '{tag}' created on {created_date}\n{digest}") return digest return None diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index 3ebd81081e08e..c514befb08082 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -361,18 +361,18 @@ class TestCephAdm(object): '514e6a882f6e74806a5856468489eeff8d7106095557578da96935e4d0ba4d9d', '2022-04-19 13:45:20.97146228 +0000 UTC', '') - out = '''quay.ceph.io/ceph-ci/ceph@sha256:87f200536bb887b36b959e887d5984dd7a3f008a23aa1f283ab55d48b22c6185|dad864ee21e98e69f4029d1e417aa085001566be0d322fbc75bc6f29b0050c01|master|2022-03-23 16:29:19 +0000 UTC - quay.ceph.io/ceph-ci/ceph@sha256:b50b130fcda2a19f8507ddde3435bb4722266956e1858ac395c838bc1dcf1c0e|514e6a882f6e74806a5856468489eeff8d7106095557578da96935e4d0ba4d9d|pacific|2022-03-23 15:58:34 +0000 UTC - docker.io/ceph/ceph@sha256:939a46c06b334e094901560c8346de33c00309e3e3968a2db240eb4897c6a508|666bbfa87e8df05702d6172cae11dd7bc48efb1d94f1b9e492952f19647199a4|v15.2.5|2020-09-16 14:15:15 +0000 UTC''' + out = '''quay.ceph.io/ceph-ci/ceph@sha256:87f200536bb887b36b959e887d5984dd7a3f008a23aa1f283ab55d48b22c6185|dad864ee21e9|master|2022-03-23 16:29:19 +0000 UTC + quay.ceph.io/ceph-ci/ceph@sha256:b50b130fcda2a19f8507ddde3435bb4722266956e1858ac395c838bc1dcf1c0e|514e6a882f6e|pacific|2022-03-23 15:58:34 +0000 UTC + docker.io/ceph/ceph@sha256:939a46c06b334e094901560c8346de33c00309e3e3968a2db240eb4897c6a508|666bbfa87e8d|v15.2.5|2020-09-16 14:15:15 +0000 UTC''' with mock.patch('cephadm.call_throws', return_value=(out, '', '')): with mock.patch('cephadm.get_container_info', return_value=cinfo): image = cd.infer_local_ceph_image(ctx, ctx.container_engine) assert image == 'quay.ceph.io/ceph-ci/ceph@sha256:b50b130fcda2a19f8507ddde3435bb4722266956e1858ac395c838bc1dcf1c0e' # make sure first valid image is used when no container_info is found - out = '''quay.ceph.io/ceph-ci/ceph@sha256:87f200536bb887b36b959e887d5984dd7a3f008a23aa1f283ab55d48b22c6185|dad864ee21e98e69f4029d1e417aa085001566be0d322fbc75bc6f29b0050c01|master|2022-03-23 16:29:19 +0000 UTC - quay.ceph.io/ceph-ci/ceph@sha256:b50b130fcda2a19f8507ddde3435bb4722266956e1858ac395c838bc1dcf1c0e|514e6a882f6e74806a5856468489eeff8d7106095557578da96935e4d0ba4d9d|pacific|2022-03-23 15:58:34 +0000 UTC - docker.io/ceph/ceph@sha256:939a46c06b334e094901560c8346de33c00309e3e3968a2db240eb4897c6a508|666bbfa87e8df05702d6172cae11dd7bc48efb1d94f1b9e492952f19647199a4|v15.2.5|2020-09-16 14:15:15 +0000 UTC''' + out = '''quay.ceph.io/ceph-ci/ceph@sha256:87f200536bb887b36b959e887d5984dd7a3f008a23aa1f283ab55d48b22c6185|dad864ee21e9|master|2022-03-23 16:29:19 +0000 UTC + quay.ceph.io/ceph-ci/ceph@sha256:b50b130fcda2a19f8507ddde3435bb4722266956e1858ac395c838bc1dcf1c0e|514e6a882f6e|pacific|2022-03-23 15:58:34 +0000 UTC + docker.io/ceph/ceph@sha256:939a46c06b334e094901560c8346de33c00309e3e3968a2db240eb4897c6a508|666bbfa87e8d|v15.2.5|2020-09-16 14:15:15 +0000 UTC''' with mock.patch('cephadm.call_throws', return_value=(out, '', '')): with mock.patch('cephadm.get_container_info', return_value=None): image = cd.infer_local_ceph_image(ctx, ctx.container_engine) @@ -381,7 +381,7 @@ class TestCephAdm(object): # make sure images without digest are discarded (no container_info is found) out = '''quay.ceph.io/ceph-ci/ceph@||| docker.io/ceph/ceph@||| - docker.io/ceph/ceph@sha256:939a46c06b334e094901560c8346de33c00309e3e3968a2db240eb4897c6a508|666bbfa87e8df05702d6172cae11dd7bc48efb1d94f1b9e492952f19647199a4|v15.2.5|2020-09-16 14:15:15 +0000 UTC''' + docker.io/ceph/ceph@sha256:939a46c06b334e094901560c8346de33c00309e3e3968a2db240eb4897c6a508|666bbfa87e8d|v15.2.5|2020-09-16 14:15:15 +0000 UTC''' with mock.patch('cephadm.call_throws', return_value=(out, '', '')): with mock.patch('cephadm.get_container_info', return_value=None): image = cd.infer_local_ceph_image(ctx, ctx.container_engine)