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 all commits
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
13 changes: 13 additions & 0 deletions pkg/feature/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
return false, err
}

podList.Items = filterEvictedPods(podList.Items)

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

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L67

Added line #L67 was not covered by tests
readyPods := 0
totalPods := len(podList.Items)

Expand Down Expand Up @@ -102,6 +103,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 112 in pkg/feature/conditions.go

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L106-L112

Added lines #L106 - L112 were not covered by tests
}

return filteredPods

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

View check run for this annotation

Codecov / codecov/patch

pkg/feature/conditions.go#L115

Added line #L115 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