Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added a filter to evicted pods when checking for ready status #1334

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
return false, err
}

pods := podList.DeepCopy()
zdtsw marked this conversation as resolved.
Show resolved Hide resolved
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 filterEvictedPods(pods []corev1.Pod) []corev1.Pod {
var filteredPods []corev1.Pod

for _, pod := range pods {
if pod.Status.Phase != corev1.PodFailed || pod.Status.Reason != "Evicted" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isnt if pod.Status.Phase != corev1.PodFailed { enough
or your evicted pod was in non-Failed phase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the pod was in Failed state, but do we want to filter out all pods in failed state? it might be that some of these are an after-effect of the apply we do from our side, as opposed to the ones that failed because of eviction

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so basically the logic is to filter out
pod is in Failed status with a reason of Evicted
if !(pod.Status.Phase == corev1.PodFailed && pod.Status.Reason == "Evicted") { // TO KEEP ...}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, exactly

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