def get_all_running_kubernetes_pods(kube_client: KubeClient, namespace: str) -> Iterable[V1Pod]: running = [] for pod in kubernetes_tools.get_all_pods(kube_client, namespace): if kubernetes_tools.get_pod_status( pod) == kubernetes_tools.PodStatus.RUNNING: running.append(pod) return running
def assert_kube_pods_running(kube_client: KubeClient, ) -> HealthCheckResult: statuses = [get_pod_status(pod) for pod in get_all_pods(kube_client)] running = statuses.count(PodStatus.RUNNING) pending = statuses.count(PodStatus.PENDING) failed = statuses.count(PodStatus.FAILED) healthy = running > 0 return HealthCheckResult( message=f"Pods: running: {running} pending: {pending} failed: {failed}", healthy=healthy, )