]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Fix normalize_image_digest for local registries
authorSebastian Wagner <sewagner@redhat.com>
Fri, 25 Jun 2021 15:21:49 +0000 (17:21 +0200)
committerSage Weil <sage@newdream.net>
Wed, 30 Jun 2021 15:15:02 +0000 (11:15 -0400)
Cause they typically don't have dots in it.

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
(cherry picked from commit 8ef5657cf6aa3558a20516cfa1a793dfba513db4)
 - conflict with adjacent test for the journald logging, which was not backported

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index b2a87b8f48e94ea77b88c7a196e7ec1de9771c01..92bb8d617823751002bfa69a66de8852c3708b7e 100755 (executable)
@@ -3345,7 +3345,7 @@ def normalize_image_digest(digest):
     #   quay.ceph.io/ceph/ceph -> ceph
     #   docker.io/ubuntu -> no change
     bits = digest.split('/')
-    if '.' not in bits[0] or len(bits) < 3:
+    if '.' not in bits[0] and len(bits) < 3:
         digest = DEFAULT_REGISTRY + '/' + digest
     return digest
 
index e9aece8b2282fe4e20d212af74b57678aa992c7d..42853fb6b377e9c77093b03c3338cb4d0c82ab6e 100644 (file)
@@ -515,6 +515,12 @@ docker.io/ceph/daemon-base:octopus
         image = cd._filter_last_local_ceph_image(out)
         assert image == 'docker.io/ceph/ceph:v15.2.5'
 
+    def test_normalize_image_digest(self):
+        s = 'myhostname:5000/ceph/ceph@sha256:753886ad9049004395ae990fbb9b096923b5a518b819283141ee8716ddf55ad1'
+        assert cd.normalize_image_digest(s) == s
+
+        s = 'ceph/ceph:latest'
+        assert cd.normalize_image_digest(s) == f'{cd.DEFAULT_REGISTRY}/{s}'
 
 class TestCustomContainer(unittest.TestCase):
     cc: cd.CustomContainer