Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Fix incorrect call to 'bind' in scheduler #50028
Conversation
k8s-merge-robot
assigned
dchen1107 and
thockin
Aug 2, 2017
k8s-merge-robot
added
the
size/M
label
Aug 2, 2017
k8s-ci-robot
added
the
cncf-cla: yes
label
Aug 2, 2017
k8s-merge-robot
added
the
release-note-label-needed
label
Aug 2, 2017
|
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. |
k8s-ci-robot
added
the
needs-ok-to-test
label
Aug 2, 2017
julia-stripe
referenced this pull request
Aug 2, 2017
Closed
Fix pods stuck in Pending state forever #49661
|
/ok-to-test |
k8s-ci-robot
removed
the
needs-ok-to-test
label
Aug 2, 2017
|
/retest |
dchen1107
referenced this pull request
Aug 3, 2017
Closed
Pod that failed to bind, stuck in Pending state forever #49314
|
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? |
dchen1107
added
cherrypick-candidate
release-note
and removed
release-note-label-needed
labels
Aug 3, 2017
dchen1107
added this to the v1.7 milestone
Aug 3, 2017
|
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 |
k8s-ci-robot
added
the
sig/scheduling
label
Aug 3, 2017
|
/assign |
k8s-ci-robot
assigned
k82cn
Aug 3, 2017
| 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{ |
k82cn
Aug 3, 2017
Member
we used pod directly before the fix; and it was assumedPod before the refactor.
wojtek-t
Aug 3, 2017
Member
@bsalamat I don't understand this question. Yes it is modifying. Yes it is what we are trying to achieve.
bsalamat
Aug 3, 2017
Contributor
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 |
wanghaoran1988
Aug 3, 2017
Contributor
Why you make a copy here? seems you moved the copy from inside the assume func here.
julia-stripe
Aug 3, 2017
Contributor
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 |
k8s-ci-robot
requested a review
from
aveshagarwal
Aug 3, 2017
davidopp
assigned
davidopp
and unassigned
thockin
Aug 3, 2017
|
Thanks a lot for this PR. I added some minor nits but this overall looks good to me. |
| @@ -185,14 +185,13 @@ func (sched *Scheduler) schedule(pod *v1.Pod) (string, error) { | ||
| } | ||
| // assume signals to the cache that a pod is already in the cache, so that binding can be asnychronous. | ||
| -func (sched *Scheduler) assume(pod *v1.Pod, host string) error { | ||
| +func (sched *Scheduler) assume(assumed *v1.Pod, host string) error { |
wojtek-t
Aug 3, 2017
Member
Please add an explicit comment that assumed pod is being modified by this function.
| @@ -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 | ||
| + err = sched.assume(&assumedPod, suggestedHost) |
wojtek-t
Aug 3, 2017
Member
Please add a comment that assume() is modifying the pod here (by setting the suggestHost to it).
| 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{ |
|
@wojtek-t I've added the comments you requested! |
|
/lgtm |
k8s-ci-robot
assigned
bsalamat
Aug 3, 2017
k8s-ci-robot
added
the
lgtm
label
Aug 3, 2017
|
/retest |
|
@julia-stripe - please squash commits and I will approve. |
|
done! |
k8s-merge-robot
removed
the
lgtm
label
Aug 3, 2017
|
/retest |
|
/lgtm /retest |
k8s-ci-robot
assigned
wojtek-t
Aug 4, 2017
k8s-ci-robot
added
the
lgtm
label
Aug 4, 2017
|
[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 |
k8s-merge-robot
added
the
approved
label
Aug 4, 2017
fejta-bot
commented
Aug 4, 2017
|
/retest Review the full test history for this PR. |
fejta-bot
commented
Aug 4, 2017
|
/retest Review the full test history for this PR. |
|
Automatic merge from submit-queue |
k8s-merge-robot
merged commit 898b1b3
into
kubernetes:master
Aug 4, 2017
9 of 10 checks passed
|
Thanks a lot, @julia-stripe for debugging this issue and the fix! |
|
+1 |
julia-stripe
deleted the
julia-stripe:fix-incorrect-scheduler-bind-call
branch
Aug 4, 2017
|
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. |
wojtek-t
referenced this pull request
Aug 7, 2017
Merged
Automated cherry pick of #50028 #50106 upstream release 1.7 #50240
wojtek-t
added
the
cherrypick-approved
label
Aug 7, 2017
|
Cherrypick in #50240 |
added a commit
that referenced
this pull request
Aug 7, 2017
k8s-cherrypick-bot
commented
Aug 7, 2017
|
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. |
julia-stripe commentedAug 2, 2017
•
Edited 1 time
-
wojtek-t
Aug 2, 2017
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 (ecb962e#diff-67f2b61521299ca8d8687b0933bbfb19R223) the scheduler code was refactored into separate
bindandassumefunctions. When that happened,bindwas called withpodas an argument. The argument tobindshould be the assumed pod, not the original pod. Evidence thatassumedPodis the correct argument bind and notpod:kubernetes/plugin/pkg/scheduler/scheduler.go
Lines 229 to 234 in 80f26fa
assumedin 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:
bindcallsForgetPodwith thepodargumentForgetPodis 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 nodeIn this PR I've fixed the call to
bindand modified the tests to make sure thatForgetPodgets 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: