-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add filter to remove deleted pods #153
Conversation
@pims It certainly was. Thank you! I'm curious as to what the pod phase is in such cases, still "Running"? |
chaoskube/chaoskube.go
Outdated
@@ -368,6 +369,18 @@ func filterByPhase(pods []v1.Pod, phase v1.PodPhase) []v1.Pod { | |||
return filteredList | |||
} | |||
|
|||
// filterDeletedPods removes pod which have a non nil DeletionTimestamp | |||
func filterDeletedPods(pods []v1.Pod) []v1.Pod { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename this to filterTerminatingPods
.
filtered := filterDeletedPods(pods) | ||
suite.Equal(len(filtered), 1) | ||
suite.Equal(pods[0].Name, "running") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@linki yes, in this case the pode phase is still |
67ac04f
to
2e65fa5
Compare
@pims Thanks! |
The
filterByPhase
function:does not filter out lingering pods in "terminating state", which is not a real PodPhase, but a state computed from the presence of a
DeletionTimestamp
: https://sourcegraph.com/github.com/kubernetes/kubernetes@v1.12.7/-/blob/pkg/printers/internalversion/printers.go#L640-642Any lingering pod in this state keeps on being selected by ChaosKube for termination.
If it is fair to assume that filtering by phase was meant to only select active pods and that deleted pods should not be included, this PR should address the issue.