-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Update existing node lease with retry. #81663
Update existing node lease with retry. #81663
Conversation
Hi @jfbai. 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 Once the patch is verified, the new status will be reflected by the 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. |
/cc @alejandrox1 PTAL, thanks a lot. :) |
@jfbai: GitHub didn't allow me to request PR reviews from the following users: answer1991. Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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. |
@answer1991 PTAL, thanks a lot. :) |
pkg/kubelet/nodelease/controller.go
Outdated
return | ||
} else { |
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.
remove else - in if branch there is return anyway.
/ok-to-test |
12e71b5
to
16b2951
Compare
/retest |
16b2951
to
d5e0b66
Compare
When I write my PR#81174, I seriously think about if we need use retry update here. I think it's not necessary. If update lease failed, there are following situations:
func (c *controller) retryUpdateLease(base *coordinationv1.Lease) error {
for i := 0; i < maxUpdateRetries; i++ {
.....
if apierrors.IsConflict(err) {
base, _ = c.backoffEnsureLease()
continue
}
So, please think again if we need retry update here. |
d5e0b66
to
7773662
Compare
/lgtm |
@jfbai - this matches exactly what I wrote above :) |
According to the API Convention,
|
Actually, clientset
If cause transient errors or 5xx errors, I think it's better to fallback to |
Actually we have not did this change. In this case, if once failed to update with the latest lease, just fallback to |
Please think about my comments agent. |
In my experience, If API Server side can not find the Object, client call Update will receive 404. |
@answer1991 Thanks for you explanation, but lease client is a restInterface,
and the and the retry logic will only automatically handle
So, I think |
@answer1991 |
Yes, you are right,
Update: My mistake, I have not got to know how apiserver handles
then I observed the lease is created. |
@wojtek-t Sorry for bugging you, we needs your suggestion about this change. |
ping @wojtek-t to take another look, thanks a lot. |
We actually handle 429 in client:
It's defined per resource type: Going back to original question - I don't have strong opinion either way. This PR doesn't harm, but it also doesn't gain us much (though the code is a bit more consistent too). I will let @answer1991 to also reply before canceling hold. |
@wojtek-t It is very appreciated to explain the details, thanks a lot. |
@@ -98,12 +98,10 @@ func (c *controller) sync() { | |||
// If at some point other agents will also be frequently updating the Lease object, this | |||
// can result in performance degradation, because we will end up with calling additional | |||
// GET/PUT - at this point this whole "if" should be removed. | |||
lease, err := c.leaseClient.Update(c.newLease(c.latestLease)) | |||
err := c.retryUpdateLease(c.newLease(c.latestLease)) |
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.
if err := c.retryUpdateLease(c.newLease(c.latestLease)); err == nil {
return
}
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.
In this case, the err
would be undefined in the klog.
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.
For logging purposes below - I agree.
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.
ok, LTGM
I add comments, otherwise LGTM. |
@answer1991 Thanks a lot. :) |
/hold cancel |
I remembered why I did not use re-try Update there... There is another situation: 409. If the kubelet cached Lease is updated by other agent or controller(for now, it seems no agent will do that), then re-try Update will totally failed no matter how times kubelet re-try. For this situation, re-try will be worse. So, we need handle 409 response in method |
/hold |
My mistake, handled. |
/hold cancel |
/test pull-kubernetes-integration |
/test pull-kubernetes-bazel-test |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Retry update latest lease early when failure happens rather than walk to
backoffEnsureLease
which will callGET
anyway.Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
None.
Does this PR introduce a user-facing change?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig node