|
15 | 15 | CATALOG_TYPE, |
16 | 16 | DEFAULT_CATALOG_FILE, |
17 | 17 | ) |
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 |
19 | 19 |
|
20 | 20 | LOGGER = get_logger(name=__name__) |
21 | 21 |
|
@@ -49,24 +49,31 @@ def validate_model_catalog_enabled(pod: Pod) -> bool: |
49 | 49 | return False |
50 | 50 |
|
51 | 51 |
|
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): |
53 | 53 | model_catalog_pods = get_model_catalog_pod(client=client, model_registry_namespace=model_registry_namespace) |
54 | 54 | # We can wait for the pods to reflect updated catalog, however, deleting them ensures the updated config is |
55 | 55 | # applied immediately. |
56 | 56 | for pod in model_catalog_pods: |
57 | 57 | pod.delete() |
58 | 58 | # 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 | + ) |
61 | 63 |
|
62 | 64 |
|
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: |
65 | 73 | pods = get_model_catalog_pod(client=client, model_registry_namespace=model_registry_namespace) |
66 | 74 | if pods: |
67 | | - pods[0].wait_for_status(status=Pod.Status.RUNNING) |
68 | 75 | return True |
69 | | - return False |
| 76 | + raise PodNotFound("Model catalog pod not found") |
70 | 77 |
|
71 | 78 |
|
72 | 79 | def validate_model_catalog_resource(kind: Any, admin_client: DynamicClient, namespace: str) -> None: |
|
0 commit comments