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
Kubelet: filter out terminated pods in SyncPods #7301
Conversation
This fixes #7250 Note that this PR handles most cases, but not all:
I think it's reasonable to assume that containers should only be garbage collected after a reasonable amount of time. As for the restart, we'd need a checkpoint of kubelet to handle that smoothly. One upside of this PR is that kubelet would stop wasting resources on terminated pods (examining containers, generating statuses and sending them to the apiserver). It would also avoid (potential) post-mortem status modifications. |
passed e2e |
/cc @dchen1107, @vmarmol |
// Pod phase progresses monotonically. Once a pod has reach a final state, | ||
// it should never leave irregardless of the restart policy. The statuses | ||
// of such pods should not be changed, and there is no need to sync them. | ||
pods := kl.FilterOutTerminatedPods(allPods) |
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.
Please also add TODO to explain those uncovered cases.
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.
Done.
LGTM overall except one nit. |
LGTM |
f2870a7
to
cdeaac9
Compare
LGTM and will merge once it is green. |
Once a pod reaches a terminated state (whether failed or succeeded), it should not transit out ever again. Currently, kubelet relies on examining the dead containers to verify that the container has already been run. This is fine in most cases, but if the dead containers were garbage collected, kubelet may falsely concluded that the pod has never been run. It would then try to restart all the containers. This change eliminates most of such possibilities by pre-filtering out the pods in the final states before sending updates to per-pod workers.
cdeaac9
to
b0e6926
Compare
Kubelet: filter out terminated pods in SyncPods
Once a pod reaches a terminated state (whether failed or succeeded), it should
not transit out ever again. Currently, kubelet relies on examining the dead
containers to verify that the container has already been run. This is fine
in most cases, but if the dead containers were garbage collected, kubelet may
falsely concluded that the pod has never been run. It would then try to restart
all the containers.
This change eliminates most of such possibilities by pre-filtering out the pods
in the final states before sending updates to per-pod workers.