From c0fa9493c1063329539648e75f6d094165da581b Mon Sep 17 00:00:00 2001 From: Alessio Pragliola <83355398+Al-Pragliola@users.noreply.github.com> Date: Thu, 14 Nov 2024 07:21:50 +0100 Subject: [PATCH] fix: added a filter to evicted pods when checking for ready status (#1334) * fix: added a filter to evicted pods Signed-off-by: Alessio Pragliola --------- Signed-off-by: Alessio Pragliola (cherry picked from commit e589680f54bedd6c5170a110bceef8fd73879805) --- pkg/feature/conditions.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/feature/conditions.go b/pkg/feature/conditions.go index 9a9373ba130..7b27196dd1a 100644 --- a/pkg/feature/conditions.go +++ b/pkg/feature/conditions.go @@ -64,6 +64,7 @@ func WaitForPodsToBeReady(namespace string) Action { return false, err } + podList.Items = filterEvictedPods(podList.Items) readyPods := 0 totalPods := len(podList.Items) @@ -102,6 +103,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)