66 deploy_operator ,
77 load_yaml_from_file ,
88)
9- from k8sutil import (
10- wait_for_condition ,
11- ignore_if_doesnt_exist ,
12- ignore_if_already_exists ,
13- )
9+ import k8s_conditions
1410from dockerutil import build_and_push_image
1511from typing import Dict , Optional
1612from dev_config import load_config
@@ -51,28 +47,28 @@ def _prepare_testrunner_environment():
5147 _delete_testrunner_pod ()
5248
5349 print ("Creating Role" )
54- ignore_if_already_exists (
50+ k8s_conditions . ignore_if_already_exists (
5551 lambda : rbacv1 .create_namespaced_role (
5652 dev_config .namespace , _load_testrunner_role ()
5753 )
5854 )
5955
6056 print ("Creating Role Binding" )
61- ignore_if_already_exists (
57+ k8s_conditions . ignore_if_already_exists (
6258 lambda : rbacv1 .create_namespaced_role_binding (
6359 dev_config .namespace , _load_testrunner_role_binding ()
6460 )
6561 )
6662
6763 print ("Creating Cluster Role Binding" )
68- ignore_if_already_exists (
64+ k8s_conditions . ignore_if_already_exists (
6965 lambda : rbacv1 .create_cluster_role_binding (
7066 _load_testrunner_cluster_role_binding ()
7167 )
7268 )
7369
7470 print ("Creating ServiceAccount" )
75- ignore_if_already_exists (
71+ k8s_conditions . ignore_if_already_exists (
7672 lambda : corev1 .create_namespaced_service_account (
7773 dev_config .namespace , _load_testrunner_service_account ()
7874 )
@@ -97,7 +93,7 @@ def create_kube_config():
9793 metadata = client .V1ObjectMeta (name = "kube-config" ), data = data
9894 )
9995
100- ignore_if_already_exists (
96+ k8s_conditions . ignore_if_already_exists (
10197 lambda : corev1 .create_namespaced_config_map ("default" , config_map )
10298 )
10399
@@ -131,7 +127,7 @@ def _delete_testrunner_pod() -> None:
131127 """
132128 dev_config = load_config ()
133129 corev1 = client .CoreV1Api ()
134- ignore_if_doesnt_exist (
130+ k8s_conditions . ignore_if_doesnt_exist (
135131 lambda : corev1 .delete_namespaced_pod (TEST_RUNNER_NAME , dev_config .namespace )
136132 )
137133
@@ -144,7 +140,7 @@ def create_test_runner_pod(test: str):
144140 corev1 = client .CoreV1Api ()
145141 pod_body = _get_testrunner_pod_body (test )
146142
147- if not wait_for_condition (
143+ if not k8s_conditions . wait (
148144 lambda : corev1 .list_namespaced_pod (
149145 dev_config .namespace , field_selector = f"metadata.name=={ TEST_RUNNER_NAME } "
150146 ),
@@ -162,7 +158,7 @@ def create_test_runner_pod(test: str):
162158
163159def wait_for_pod_to_be_running (corev1 , name , namespace ):
164160 print ("Waiting for pod to be running" )
165- if not wait_for_condition (
161+ if not k8s_conditions . wait (
166162 lambda : corev1 .read_namespaced_pod (name , namespace ),
167163 lambda pod : pod .status .phase == "Running" ,
168164 sleep_time = 5 ,
0 commit comments