-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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 incorrect call to 'bind' in scheduler #50028
Fix incorrect call to 'bind' in scheduler #50028
Conversation
Hi @julia-stripe. 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 |
/retest |
From the original issue description, it is a serial regression for 1.7 release, and we should patch it. I marked this pr for cherrypick-candidate. @julia-stripe Looks like there are two prs (this one and #49661) addressing the same issue. I didn't see much difference from both prs. Could you please close one? |
The pr looks good to me based on the problem described, and I prefer someone from @kubernetes/sig-scheduling-pr-reviews to take a look too. @bsalamat |
/assign |
if err != nil { | ||
return | ||
} | ||
|
||
// bind the pod to its host asynchronously (we can do this b/c of the assumption step above). | ||
go func() { | ||
err := sched.bind(pod, &v1.Binding{ | ||
ObjectMeta: metav1.ObjectMeta{Namespace: pod.Namespace, Name: pod.Name, UID: pod.UID}, | ||
err := sched.bind(&assumedPod, &v1.Binding{ |
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.
Isn't this the same as before.
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.
we used pod directly before the fix; and it was assumedPod before the refactor.
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's not the same - assume() method above is modifying the given 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.
I meant this piece of code is logically the same in this PR.
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.
Is sched.assume()
going to modify assumedPod
?
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.
@bsalamat I don't understand this question. Yes it is modifying. Yes it is what we are trying to achieve.
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.
Thanks, @wojtek-t! I don't know why I missed it. I guess github UI still confuses me.
@@ -264,15 +263,16 @@ func (sched *Scheduler) scheduleOne() { | |||
|
|||
// Tell the cache to assume that a pod now is running on a given node, even though it hasn't been bound yet. | |||
// This allows us to keep scheduling without waiting on binding to occur. | |||
err = sched.assume(pod, suggestedHost) | |||
assumedPod := *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.
Why you make a copy here? seems you moved the copy from inside the assume func here.
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.
we should not use obj from cache directly.
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.
Basically we need to make a copy somewhere and @k82cn suggested it would be more clear if we made the copy outside of the assume function. (which I agree with)
/cc @aveshagarwal |
Thanks a lot for this PR. I added some minor nits but this overall looks good to me. |
/retest |
@julia-stripe - please squash commits and I will approve. |
b65bb0a
to
d584bf4
Compare
done! |
/retest |
/lgtm /retest |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, julia-stripe, wojtek-t Associated issue: 49314 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 |
/retest Review the full test history for this PR. |
1 similar comment
/retest Review the full test history for this PR. |
Automatic merge from submit-queue |
Thanks a lot, @julia-stripe for debugging this issue and the fix! |
+1 |
BTW I assume we should cherrypick this into 1.7, right? |
Ah, @dchen1107 had already marked this as cherypick-candidate. |
Yes - this will be cherrypicked to 1.7. I will take care of it. |
Cherrypick in #50240 |
Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
I previously submitted #49661 -- I'm not sure if that PR is too big or what, but this is an attempt at a smaller PR that makes progress on the same issue and is easier to review.
What this PR does / why we need it:
In this refactor (ecb962e6585#diff-67f2b61521299ca8d8687b0933bbfb19R223) the scheduler code was refactored into separate
bind
andassume
functions. When that happened,bind
was called withpod
as an argument. The argument tobind
should be the assumed pod, not the original pod. Evidence thatassumedPod
is the correct argument bind and notpod
:kubernetes/plugin/pkg/scheduler/scheduler.go
Lines 229 to 234 in 80f26fa
assumed
in the function signature forbind
, even though it's not called with the assumed pod as an argument).This is an issue (and causes #49314, where pods that fail to bind to a node get stuck indefinitely) in the following scenario:
bind
callsForgetPod
with thepod
argumentForgetPod
is expecting the assumed pod as an argument (because that's what's in the scheduler cache), it fails with an error likescheduler cache ForgetPod failed: pod test-677550-rc-edit-namespace/nginx-jvn09 state was assumed on a different node
In this PR I've fixed the call to
bind
and modified the tests to make sure thatForgetPod
gets called with the correct argument (the assumed pod) when binding fails.Which issue this PR fixes: fixes #49314
Special notes for your reviewer:
Release note: