Merge "Do not end ceph_namespace with a slash" into stable/wallaby

This commit is contained in:
Zuul
2022-06-28 13:53:48 +00:00
committed by Gerrit Code Review
2 changed files with 25 additions and 1 deletions

View File

@@ -2234,6 +2234,29 @@ class TestParseContainerImagePrepare(TestCase):
push_sub_keys)
self.assertEqual(reg_actual, reg_expected)
def test_parse_container_image_prepare_push_dest_no_slash(self):
# Cover case from https://bugs.launchpad.net/tripleo/+bug/1979554
key = 'ContainerImagePrepare'
keys = ['ceph_namespace', 'ceph_image', 'ceph_tag']
push_sub_keys = ['ceph_namespace']
reg_expected = {'ceph_image': 'ceph',
'ceph_namespace': 'foo.com',
'ceph_tag': 'latest',
'push_destination_boolean': True}
local_fake_env = self.fake_env
# Remove '/ceph' from 'quay.io:443/ceph' in local copy to
# make sure parse_container_image_prepare() can handle it
local_fake_env['parameter_defaults'][
'ContainerImagePrepare'][0]['set']['ceph_namespace'] \
= 'quay.io:443'
with tempfile.NamedTemporaryFile(mode='w') as cfgfile:
yaml.safe_dump(local_fake_env, cfgfile)
reg_actual = \
utils.parse_container_image_prepare(key, keys,
cfgfile.name,
push_sub_keys)
self.assertEqual(reg_actual, reg_expected)
def test_parse_container_image_prepare_credentials(self):
key = 'ContainerImageRegistryCredentials'
keys = ['quay.io:443/ceph']

View File

@@ -2997,7 +2997,8 @@ def parse_container_image_prepare(tht_key='ContainerImagePrepare',
# with the push_destination, since that is
# where they will be uploaded to
image = image_map[key].partition('/')[2]
image_map[key] = '/'.join((push, image))
image_map[key] = os.path.normpath(
os.path.join(push, image))
except KeyError:
raise RuntimeError(
"The expected parameter_defaults and %s are not "