Skip to content

Commit efc8b02

Browse files
authored
Fetch upload job image dynamically from installed rhoai version (#610)
* fix: Fetch upload job image dynamically from installed rhoai version Signed-off-by: lugi0 <lgiorgi@redhat.com> * fix: address review comments Signed-off-by: lugi0 <lgiorgi@redhat.com> * fix: use pyconfig applications namespace Signed-off-by: lugi0 <lgiorgi@redhat.com> --------- Signed-off-by: lugi0 <lgiorgi@redhat.com>
1 parent dd01ed7 commit efc8b02

File tree

3 files changed

+40
-4
lines changed

3 files changed

+40
-4
lines changed

tests/model_registry/async_job/conftest.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,20 @@
33

44
import pytest
55
from kubernetes.dynamic import DynamicClient
6+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
67
from ocp_resources.job import Job
78

89
from tests.model_registry.async_job.constants import (
910
ASYNC_JOB_ANNOTATIONS,
1011
ASYNC_JOB_LABELS,
11-
ASYNC_UPLOAD_IMAGE,
1212
ASYNC_UPLOAD_JOB_NAME,
1313
MODEL_SYNC_CONFIG,
1414
VOLUME_MOUNTS,
1515
)
1616

1717
import shortuuid
1818
from pytest import FixtureRequest
19+
from pytest_testconfig import py_config
1920

2021
from ocp_resources.namespace import Namespace
2122
from ocp_resources.pod import Pod
@@ -25,6 +26,7 @@
2526
from ocp_resources.service import Service
2627
from ocp_resources.service_account import ServiceAccount
2728
from ocp_resources.model_registry_modelregistry_opendatahub_io import ModelRegistry
29+
from ocp_resources.config_map import ConfigMap
2830
from model_registry.types import RegisteredModel
2931
from model_registry import ModelRegistry as ModelRegistryClient
3032

@@ -114,6 +116,39 @@ def oci_secret_for_async_job(
114116
yield secret
115117

116118

119+
@pytest.fixture(scope="class")
120+
def async_upload_image(admin_client: DynamicClient) -> str:
121+
"""
122+
Get the async upload image dynamically from the model-registry-operator-parameters ConfigMap.
123+
124+
This fetches the image from the cluster at runtime instead of using a hardcoded value.
125+
126+
Args:
127+
admin_client: Kubernetes client for resource access
128+
129+
Returns:
130+
str: The async upload image URL from the ConfigMap
131+
132+
Raises:
133+
KeyError: If the ConfigMap or the required key doesn't exist
134+
"""
135+
config_map = ConfigMap(
136+
client=admin_client,
137+
name="model-registry-operator-parameters",
138+
namespace=py_config["applications_namespace"],
139+
)
140+
141+
if not config_map.exists:
142+
raise ResourceNotFoundError(
143+
f"ConfigMap 'model-registry-operator-parameters' not found in namespace '{py_config['applications_namespace']}'" # noqa: E501
144+
)
145+
146+
try:
147+
return config_map.instance.data["IMAGES_JOBS_ASYNC_UPLOAD"]
148+
except KeyError as e:
149+
raise KeyError(f"Key 'IMAGES_JOBS_ASYNC_UPLOAD' not found in ConfigMap data: {e}") from e
150+
151+
117152
@pytest.fixture(scope="class")
118153
def model_sync_async_job(
119154
admin_client: DynamicClient,
@@ -125,6 +160,7 @@ def model_sync_async_job(
125160
oci_secret_for_async_job: Secret,
126161
oci_registry_host: str,
127162
mr_access_role_binding: RoleBinding,
163+
async_upload_image: str,
128164
teardown_resources: bool,
129165
) -> Generator[Job, Any, Any]:
130166
"""
@@ -146,6 +182,7 @@ def model_sync_async_job(
146182
oci_secret_for_async_job: Secret containing OCI registry credentials
147183
oci_registry_host: OCI registry hostname
148184
mr_access_role_binding: Role binding for Model Registry access
185+
async_upload_image: Container image URL for async upload job (fetched dynamically)
149186
teardown_resources: Whether to clean up resources after test
150187
151188
Returns:
@@ -210,7 +247,7 @@ def model_sync_async_job(
210247
containers=[
211248
{
212249
"name": "async-upload",
213-
"image": ASYNC_UPLOAD_IMAGE,
250+
"image": async_upload_image,
214251
"volumeMounts": volume_mounts,
215252
"env": environment_variables,
216253
}

tests/model_registry/async_job/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Job identification
22
ASYNC_UPLOAD_JOB_NAME = "model-sync-async-job"
3-
ASYNC_UPLOAD_IMAGE = "quay.io/opendatahub/model-registry-job-async-upload:v0.3.0"
43

54
# Job labels and annotations
65
ASYNC_JOB_LABELS = {

tests/model_registry/async_job/test_async_upload_e2e.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858
],
5959
indirect=True,
6060
)
61+
@pytest.mark.downstream_only
6162
class TestAsyncUploadE2E:
6263
"""RHOAIENG-32501: Test for async upload job with real MinIO, OCI registry, Connection Secrets and Model Registry"""
6364

64-
# FAILS until https://github.com/kubeflow/model-registry/pull/1499 is merged downstream
6565
@pytest.mark.dependency(name="job_creation_and_pod_spawning")
6666
def test_job_creation_and_pod_spawning(
6767
self: Self,

0 commit comments

Comments
 (0)