in modules/python/clients/kubernetes_client.py [0:0]
def wait_for_pods_ready(self, pod_count, operation_timeout_in_minutes, namespace="default", label_selector=None):
"""
Waits for a specific number of pods with a given label to be ready within a specified timeout.
Raises an exception if the expected number of pods are not ready within the timeout.
:param label_selector: The label to filter pods.
:param pod_count: The expected number of pods to be ready.
:param operation_timeout_in_minutes: The timeout in minutes to wait for the pods to be ready.
:param namespace: The namespace to filter pods.
:return: None
"""
pods = []
timeout = time.time() + (operation_timeout_in_minutes * 60)
logger.info(f"Validating {pod_count} pods with label {label_selector} are ready.")
while time.time() < timeout:
pods = self.get_ready_pods_by_namespace(namespace=namespace, label_selector=label_selector)
if len(pods) == pod_count:
return pods
logger.info(f"Waiting for {pod_count} pods to be ready.")
time.sleep(10)
if len(pods) != pod_count:
raise Exception(f"Only {len(pods)} pods are ready, expected {pod_count} pods!")
return pods