-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
don't recreate a mirror pod for static pod when node gets deleted #48339
don't recreate a mirror pod for static pod when node gets deleted #48339
Conversation
Hi @dixudx. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/ok-to-test |
I get why this PR may be needed, but it's a bit strange to check whether the node exists in the code. If in the future, kubelet always tries to re-register itself (#9085), this change would not be useful. |
@yujuhong If the kubelet keeps re-registering itself no matter what happened, then it cannot get drained and deleted any more. |
You can still drain the regular pods without a problem. As for the static pods, they are actually running on the node with or without the mirror pods. Deleting the mirror pods means nothing to the actual state on the node. |
ping @tallclair @vishh PTAL. Any comments on @yujuhong's suggestions. |
cc @kubernetes/sig-node-pr-reviews PTAL |
/assign @tallclair @vishh From @yujuhong
This PR would help fix #48213 from @antoineco. Current PTAL. Thanks. |
@dixudx We're subject to code freeze for v1.8 which means only v1.8 bugs can be merged. |
@luxas Yes, this is a bug but not that critical. |
Ok, then lets defer this to later |
pkg/kubelet/kubelet.go
Outdated
@@ -1597,7 +1597,14 @@ func (kl *Kubelet) syncPod(o syncPodOptions) error { | |||
if err := kl.podManager.DeleteMirrorPod(podFullName); err != nil { | |||
glog.Errorf("Failed deleting mirror pod %q: %v", format.Pod(mirrorPod), err) | |||
} else { | |||
deleted = true | |||
opts := metav1.GetOptions{} | |||
_, err := kl.kubeClient.Core().Nodes().Get(string(kl.nodeName), opts) |
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.
I feel like this check should go next to the CreateMirrorPod
call, instead of here?
Also, is there not a cached version of this? Doesn't the Kubelet know whether it is registered as a node with the API server?
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.
I feel like this check should go next to the
CreateMirrorPod
call, instead of here?
It should be here. Because we are going to delete static pods for deleted nodes, not create them.
Also, is there not a cached version of this? Doesn't the Kubelet know whether it is registered as a node with the API server?
We cannot identify from the cached version whether the node has been deleted from API server.
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.
It should be here. Because we are going to delete static pods for deleted nodes, not create them.
I don't understand this comment. The pod has been deleted, it seems weird to lie that it hasn't. Furthermore, if syncpod is called again it will be recreated since this block will be skipped.
We cannot identify from the cached version whether the node has been deleted from API server.
Use kl.GetNode()
. Also do we need to check the DeletionTimestamp
?
/cc @yujuhong
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.
@tallclair Make sense. Will update it. Thanks.
92583fe
to
46a194f
Compare
pkg/kubelet/kubelet.go
Outdated
glog.V(3).Infof("Creating a mirror pod for static pod %q", format.Pod(pod)) | ||
if err := kl.podManager.CreateMirrorPod(pod); err != nil { | ||
glog.Errorf("Failed creating a mirror pod for %q: %v", format.Pod(pod), err) | ||
if _, err := kl.GetNode(); err != nil { |
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.
Do we need to check the deletion timestamp?
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.
Yes, we should support the graceful deletion. Will add it. Thanks for pointing out.
pkg/kubelet/kubelet.go
Outdated
if _, err := kl.GetNode(); err != nil { | ||
glog.V(3).Infof("No need to create a mirror pod, since node %q has been removed from the cluster", kl.nodeName) | ||
} else { | ||
glog.V(3).Infof("Creating a mirror pod for static pod %q", format.Pod(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.
nit: I think this and the above message should be V(4)
46a194f
to
53c7601
Compare
ping @tallclair @yujuhong Updated. PTAL. Thanks |
pkg/kubelet/kubelet.go
Outdated
if err != nil { | ||
glog.V(4).Infof("No need to create a mirror pod, since node %q has been removed from the cluster", kl.nodeName) | ||
} | ||
if err == nil && node.DeletionTimestamp == nil { |
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.
make this an else if
rather than checking err
twice.
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.
Actually, I would move the deletion check to the above if, and just make this the else condition. I.e.
if err != nil || node.DeletionTimestamp != nil {
...
} else {
...
}
53c7601
to
32199cb
Compare
@tallclair Updated. PTAL. Thanks |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dixudx, tallclair Associated issue: 48213 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue (batch tested with PRs 53135, 52512, 48339). If you want to cherry-pick this change to another branch, please follow the instructions here. |
What this PR does / why we need it:
Currently
kubelet
will try to recreate a mirror pod for static pod when node gets deleted.Which issue this PR fixes : fixes #48213
Special notes for your reviewer:
Release note: