Skip to content

Commit

Permalink
fix: added a filter to evicted pods
Browse files Browse the repository at this point in the history
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
  • Loading branch information
Al-Pragliola committed Oct 31, 2024
1 parent 87c87ab commit 4edb03c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions pkg/feature/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ func WaitForPodsToBeReady(namespace string) Action {
return false, err
}

pods := podList.DeepCopy()
pods.Items = filterEvictedPods(podList.Items)

Check warning on line 68 in pkg/feature/conditions.go

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L67-L68

Added lines #L67 - L68 were not covered by tests
readyPods := 0
totalPods := len(podList.Items)
totalPods := len(pods.Items)

Check warning on line 70 in pkg/feature/conditions.go

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L70

Added line #L70 was not covered by tests

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 {

Check warning on line 76 in pkg/feature/conditions.go

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L76

Added line #L76 was not covered by tests
podReady := true
// Consider a "PodSucceeded" as ready, since these will never will
// be in Ready condition (i.e. Jobs that already completed).
Expand Down Expand Up @@ -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)
}

Check warning on line 113 in pkg/feature/conditions.go

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L107-L113

Added lines #L107 - L113 were not covered by tests
}

return filteredPods

Check warning on line 116 in pkg/feature/conditions.go

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L116

Added line #L116 was not covered by tests
}

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)
Expand Down

0 comments on commit 4edb03c

Please sign in to comment.