Skip to content

Commit dcff182

Browse files
authored
Wait for MC pod before api call (#580)
1 parent b02cc25 commit dcff182

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

tests/model_registry/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ def updated_dsc_component_state_scope_session(
203203
namespace_name=py_config["applications_namespace"],
204204
number_of_consecutive_checks=6,
205205
)
206+
wait_for_pods_running(
207+
admin_client=admin_client,
208+
namespace_name=py_config["model_registry_namespace"],
209+
number_of_consecutive_checks=6,
210+
)
206211
yield dsc_resource
207212

208213
for component_name, value in component_patch.items():

tests/model_registry/model_catalog/utils.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
CATALOG_TYPE,
1616
DEFAULT_CATALOG_FILE,
1717
)
18-
from tests.model_registry.utils import get_model_catalog_pod
18+
from tests.model_registry.utils import get_model_catalog_pod, wait_for_pods_running
1919

2020
LOGGER = get_logger(name=__name__)
2121

@@ -49,24 +49,31 @@ def validate_model_catalog_enabled(pod: Pod) -> bool:
4949
return False
5050

5151

52-
def is_model_catalog_ready(client: DynamicClient, model_registry_namespace: str, consecutive_try: int = 3):
52+
def is_model_catalog_ready(client: DynamicClient, model_registry_namespace: str, consecutive_try: int = 6):
5353
model_catalog_pods = get_model_catalog_pod(client=client, model_registry_namespace=model_registry_namespace)
5454
# We can wait for the pods to reflect updated catalog, however, deleting them ensures the updated config is
5555
# applied immediately.
5656
for pod in model_catalog_pods:
5757
pod.delete()
5858
# After the deletion, we need to wait for the pod to be spinned up and get to ready state.
59-
for _ in range(consecutive_try):
60-
wait_for_model_catalog_update(client=client, model_registry_namespace=model_registry_namespace)
59+
assert wait_for_model_catalog_pod_created(client=client, model_registry_namespace=model_registry_namespace)
60+
wait_for_pods_running(
61+
admin_client=client, namespace_name=model_registry_namespace, number_of_consecutive_checks=consecutive_try
62+
)
6163

6264

63-
@retry(wait_timeout=30, sleep=5)
64-
def wait_for_model_catalog_update(client: DynamicClient, model_registry_namespace: str):
65+
class PodNotFound(Exception):
66+
"""Pod not found"""
67+
68+
pass
69+
70+
71+
@retry(wait_timeout=30, sleep=5, exceptions_dict={PodNotFound: []})
72+
def wait_for_model_catalog_pod_created(client: DynamicClient, model_registry_namespace: str) -> bool:
6573
pods = get_model_catalog_pod(client=client, model_registry_namespace=model_registry_namespace)
6674
if pods:
67-
pods[0].wait_for_status(status=Pod.Status.RUNNING)
6875
return True
69-
return False
76+
raise PodNotFound("Model catalog pod not found")
7077

7178

7279
def validate_model_catalog_resource(kind: Any, admin_client: DynamicClient, namespace: str) -> None:

0 commit comments

Comments
 (0)