6
6
deploy_operator ,
7
7
load_yaml_from_file ,
8
8
)
9
- from k8sutil import (
10
- wait_for_condition ,
11
- ignore_if_doesnt_exist ,
12
- ignore_if_already_exists ,
13
- )
9
+ import k8s_conditions
14
10
from dockerutil import build_and_push_image
15
11
from typing import Dict , Optional
16
12
from dev_config import load_config
@@ -51,28 +47,28 @@ def _prepare_testrunner_environment():
51
47
_delete_testrunner_pod ()
52
48
53
49
print ("Creating Role" )
54
- ignore_if_already_exists (
50
+ k8s_conditions . ignore_if_already_exists (
55
51
lambda : rbacv1 .create_namespaced_role (
56
52
dev_config .namespace , _load_testrunner_role ()
57
53
)
58
54
)
59
55
60
56
print ("Creating Role Binding" )
61
- ignore_if_already_exists (
57
+ k8s_conditions . ignore_if_already_exists (
62
58
lambda : rbacv1 .create_namespaced_role_binding (
63
59
dev_config .namespace , _load_testrunner_role_binding ()
64
60
)
65
61
)
66
62
67
63
print ("Creating Cluster Role Binding" )
68
- ignore_if_already_exists (
64
+ k8s_conditions . ignore_if_already_exists (
69
65
lambda : rbacv1 .create_cluster_role_binding (
70
66
_load_testrunner_cluster_role_binding ()
71
67
)
72
68
)
73
69
74
70
print ("Creating ServiceAccount" )
75
- ignore_if_already_exists (
71
+ k8s_conditions . ignore_if_already_exists (
76
72
lambda : corev1 .create_namespaced_service_account (
77
73
dev_config .namespace , _load_testrunner_service_account ()
78
74
)
@@ -97,7 +93,7 @@ def create_kube_config():
97
93
metadata = client .V1ObjectMeta (name = "kube-config" ), data = data
98
94
)
99
95
100
- ignore_if_already_exists (
96
+ k8s_conditions . ignore_if_already_exists (
101
97
lambda : corev1 .create_namespaced_config_map ("default" , config_map )
102
98
)
103
99
@@ -131,7 +127,7 @@ def _delete_testrunner_pod() -> None:
131
127
"""
132
128
dev_config = load_config ()
133
129
corev1 = client .CoreV1Api ()
134
- ignore_if_doesnt_exist (
130
+ k8s_conditions . ignore_if_doesnt_exist (
135
131
lambda : corev1 .delete_namespaced_pod (TEST_RUNNER_NAME , dev_config .namespace )
136
132
)
137
133
@@ -144,7 +140,7 @@ def create_test_runner_pod(test: str):
144
140
corev1 = client .CoreV1Api ()
145
141
pod_body = _get_testrunner_pod_body (test )
146
142
147
- if not wait_for_condition (
143
+ if not k8s_conditions . wait (
148
144
lambda : corev1 .list_namespaced_pod (
149
145
dev_config .namespace , field_selector = f"metadata.name=={ TEST_RUNNER_NAME } "
150
146
),
@@ -162,7 +158,7 @@ def create_test_runner_pod(test: str):
162
158
163
159
def wait_for_pod_to_be_running (corev1 , name , namespace ):
164
160
print ("Waiting for pod to be running" )
165
- if not wait_for_condition (
161
+ if not k8s_conditions . wait (
166
162
lambda : corev1 .read_namespaced_pod (name , namespace ),
167
163
lambda pod : pod .status .phase == "Running" ,
168
164
sleep_time = 5 ,
0 commit comments