From 94e96357e6ca04bcc6b7f243fe2aa1acc40f953c Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Fri, 25 Jun 2021 17:21:49 +0200 Subject: [PATCH] cephadm: Fix normalize_image_digest for local registries Cause they typically don't have dots in it. Signed-off-by: Sebastian Wagner (cherry picked from commit 8ef5657cf6aa3558a20516cfa1a793dfba513db4) - conflict with adjacent test for the journald logging, which was not backported --- src/cephadm/cephadm | 2 +- src/cephadm/tests/test_cephadm.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index b2a87b8f48e94..92bb8d6178237 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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 diff --git a/src/cephadm/tests/test_cephadm.py b/src/cephadm/tests/test_cephadm.py index e9aece8b2282f..42853fb6b377e 100644 --- a/src/cephadm/tests/test_cephadm.py +++ b/src/cephadm/tests/test_cephadm.py @@ -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 -- 2.39.5