Merge "Fix rook ceph image override missing local registry prefix"

This commit is contained in:
Zuul
2026-04-07 21:55:07 +00:00
committed by Gerrit Code Review
2 changed files with 30 additions and 4 deletions
@@ -114,9 +114,27 @@ class UtilsTest(dbbase.ControllerHostTestCase):
return_value=f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_REPO}:'
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_TAG}')
def test_get_image_rook_ceph(self, mock_get_value_from_application):
"""Test test_get_image_rook_ceph for valid image override
"""Test get_image_rook_ceph returns image with local registry prefix
"""
expected = f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_REPO}:'\
expected = f'{constants.DOCKER_REGISTRY_SERVER}/'\
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_REPO}:'\
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_TAG}'
result = app_utils.get_image_rook_ceph()
self.assertEqual(result, expected)
mock_get_value_from_application.assert_called_once()
@mock.patch('k8sapp_openstack.utils._get_value_from_application',
return_value=f'{constants.DOCKER_REGISTRY_SERVER}/'
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_REPO}:'
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_TAG}')
def test_get_image_rook_ceph_with_registry_prefix(self,
mock_get_value_from_application):
"""Test get_image_rook_ceph does not duplicate local registry prefix
when user override already includes it
"""
expected = f'{constants.DOCKER_REGISTRY_SERVER}/'\
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_REPO}:'\
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_TAG}'
result = app_utils.get_image_rook_ceph()
@@ -2143,14 +2143,22 @@ def delete_kubernetes_resource(resource_type, resource_name):
def get_image_rook_ceph():
"""Get client image to be used for rook ceph deployments
:returns: str -- The image in the formart <repository>:tag
The returned image includes the local registry prefix to ensure
that the image is pulled from the local registry instead of
attempting to reach external registries.
:returns: str -- The image in the format
registry.local:9001/<repository>:<tag>
"""
return _get_value_from_application(
image = _get_value_from_application(
default_value=f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_REPO}:'
f'{app_constants.CEPH_ROOK_IMAGE_DEFAULT_TAG}',
chart_name=app_constants.HELM_CHART_CLIENTS,
override_name=f'images.tags.{app_constants.CEPH_ROOK_IMAGE_OVERRIDE}'
)
if not image.startswith(constants.DOCKER_REGISTRY_SERVER):
image = f'{constants.DOCKER_REGISTRY_SERVER}/{image}'
return image
def force_app_reconciliation(app_op: kube_app.AppOperator,