]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: Fix normalize_image_digest for local registries 42031/head
authorSebastian Wagner <sewagner@redhat.com>
Fri, 25 Jun 2021 15:21:49 +0000 (17:21 +0200)
committerSebastian Wagner <sewagner@redhat.com>
Fri, 25 Jun 2021 15:26:49 +0000 (17:26 +0200)
Cause they typically don't have dots in it.

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 8b77b787d2ff50901614bbf305779305452c20a0..6d8e0a2f913db269a2c2b0cec2ce2a1aae6a3bb3 100755 (executable)
@@ -3371,7 +3371,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 ee7efad82cbcd5ea02aaef3397eb15e4af70fe36..7e16a101511ab7d7bf59a23ddb4693c54aad7271 100644 (file)
@@ -535,6 +535,12 @@ docker.io/ceph/daemon-base:octopus
         ctx.container_engine = mock_docker()
         assert not cd.should_log_to_journald(ctx)
 
+    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