From 4edb03cea6526ee1858a5e528bdffc4e8bec8a96 Mon Sep 17 00:00:00 2001 From: Alessio Pragliola Date: Thu, 31 Oct 2024 19:53:12 +0100 Subject: [PATCH] fix: added a filter to evicted pods Signed-off-by: Alessio Pragliola --- pkg/feature/conditions.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/feature/conditions.go b/pkg/feature/conditions.go index 9a9373ba130..5490fcac048 100644 --- a/pkg/feature/conditions.go +++ b/pkg/feature/conditions.go @@ -64,14 +64,16 @@ func WaitForPodsToBeReady(namespace string) Action { return false, err } + pods := podList.DeepCopy() + pods.Items = filterEvictedPods(podList.Items) readyPods := 0 - totalPods := len(podList.Items) + totalPods := len(pods.Items) if totalPods == 0 { // We want to wait for "something", so make sure we have "something" before we claim success. return false, nil } - for _, pod := range podList.Items { + for _, pod := range pods.Items { podReady := true // Consider a "PodSucceeded" as ready, since these will never will // be in Ready condition (i.e. Jobs that already completed). @@ -102,6 +104,18 @@ func WaitForPodsToBeReady(namespace string) Action { } } +func filterEvictedPods(pods []corev1.Pod) []corev1.Pod { + var filteredPods []corev1.Pod + + for _, pod := range pods { + if pod.Status.Phase != corev1.PodFailed || pod.Status.Reason != "Evicted" { + filteredPods = append(filteredPods, pod) + } + } + + return filteredPods +} + func WaitForResourceToBeCreated(namespace string, gvk schema.GroupVersionKind) Action { return func(ctx context.Context, cli client.Client, f *Feature) error { f.Log.Info("waiting for resource to be created", "namespace", namespace, "resource", gvk)