e2e: finish waiting for pod failover only if all pods were replaced
This commit is contained in:
parent
fdbe38fa58
commit
c1fe8485d8
|
|
@ -156,6 +156,10 @@ class K8s:
|
||||||
while not get_services():
|
while not get_services():
|
||||||
time.sleep(self.RETRY_TIMEOUT_SEC)
|
time.sleep(self.RETRY_TIMEOUT_SEC)
|
||||||
|
|
||||||
|
def count_pods_with_rolling_update_flag(self, labels, namespace='default'):
|
||||||
|
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
||||||
|
return len(list(filter(lambda x: "zalando-postgres-operator-rolling-update-required" in x.metadata.annotations, pods)))
|
||||||
|
|
||||||
def count_pods_with_label(self, labels, namespace='default'):
|
def count_pods_with_label(self, labels, namespace='default'):
|
||||||
return len(self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items)
|
return len(self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items)
|
||||||
|
|
||||||
|
|
@ -189,6 +193,7 @@ class K8s:
|
||||||
def wait_for_pod_failover(self, failover_targets, labels, namespace='default'):
|
def wait_for_pod_failover(self, failover_targets, labels, namespace='default'):
|
||||||
pod_phase = 'Failing over'
|
pod_phase = 'Failing over'
|
||||||
new_pod_node = ''
|
new_pod_node = ''
|
||||||
|
pods_with_update_flag = self.count_pods_with_rolling_update_flag(labels, namespace)
|
||||||
|
|
||||||
while (pod_phase != 'Running') or (new_pod_node not in failover_targets):
|
while (pod_phase != 'Running') or (new_pod_node not in failover_targets):
|
||||||
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
||||||
|
|
@ -196,6 +201,10 @@ class K8s:
|
||||||
new_pod_node = pods[0].spec.node_name
|
new_pod_node = pods[0].spec.node_name
|
||||||
pod_phase = pods[0].status.phase
|
pod_phase = pods[0].status.phase
|
||||||
time.sleep(self.RETRY_TIMEOUT_SEC)
|
time.sleep(self.RETRY_TIMEOUT_SEC)
|
||||||
|
|
||||||
|
while pods_with_update_flag != 0:
|
||||||
|
pods_with_update_flag = self.count_pods_with_rolling_update_flag(labels, namespace)
|
||||||
|
time.sleep(self.RETRY_TIMEOUT_SEC)
|
||||||
|
|
||||||
def wait_for_namespace_creation(self, namespace='default'):
|
def wait_for_namespace_creation(self, namespace='default'):
|
||||||
ns_found = False
|
ns_found = False
|
||||||
|
|
@ -423,6 +432,10 @@ class K8sBase:
|
||||||
while not get_services():
|
while not get_services():
|
||||||
time.sleep(self.RETRY_TIMEOUT_SEC)
|
time.sleep(self.RETRY_TIMEOUT_SEC)
|
||||||
|
|
||||||
|
def count_pods_with_rolling_update_flag(self, labels, namespace='default'):
|
||||||
|
pods = self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items
|
||||||
|
return len(list(filter(lambda x: "zalando-postgres-operator-rolling-update-required" in x.metadata.annotations, pods)))
|
||||||
|
|
||||||
def count_pods_with_label(self, labels, namespace='default'):
|
def count_pods_with_label(self, labels, namespace='default'):
|
||||||
return len(self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items)
|
return len(self.api.core_v1.list_namespaced_pod(namespace, label_selector=labels).items)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue