-
Notifications
You must be signed in to change notification settings - Fork 532
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
add podGroup backoff time for coscheduling #559
Conversation
Hi @KunWuLuan. Thanks for your PR. I'm waiting for a kubernetes-sigs 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. |
/ok-to-test |
/test all |
@@ -485,7 +485,7 @@ func TestTopologyCachePluginWithoutUpdates(t *testing.T) { | |||
checkPod = podIsPending | |||
} | |||
|
|||
err = checkPod(1*time.Second, 20, cs, p.pod.Namespace, p.pod.Name) |
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'd expect to see a new (sub-)integration test to simulate what was described in the original issue.
Otherwise, I'd postpone the impl. to next release.
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.
Have added a new integration test for the case
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. But even without introducing the backoff, the integration test seems to be also passing.
weih@m1max:~/go/src/sigs.k8s.io/scheduler-plugins|master⚡ ⇒ go test ./test/integration/... -run TestPodgroupBackoff -count 1
ok sigs.k8s.io/scheduler-plugins/test/integration 27.100s
weih@m1max:~/go/src/sigs.k8s.io/scheduler-plugins|master⚡ ⇒ gst
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: test/integration/coscheduling_test.go
Could you update the test to pass and only pass with the backoff changes? in other words, the test is expected to fail on master.
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.
No problem
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
d721c00
to
3588a53
Compare
pkg/coscheduling/coscheduling.go
Outdated
pods, err := cs.frameworkHandler.SharedInformerFactory().Core().V1().Pods().Lister().Pods(pod.Namespace).List( | ||
labels.SelectorFromSet(labels.Set{v1alpha1.PodGroupLabel: util.GetPodGroupLabel(pod)}), | ||
) | ||
if err == nil && len(pods) >= int(pg.Spec.MinMember) { |
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.
can we remove the check here? (given assigned
< pg.Spec.MinMember per L150)
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.
bump.
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 think we can not remove the check here.
assigned < pg.Spec.MinMember
check whether the gang has been satisfied and len(pods) >= int(pg.Spec.MinMember)
check whether there is enough pods to schedule.
When the first pod come, scheduler may list not all pods. We will reject the first pod in preFilter
scheduler-plugins/pkg/coscheduling/core/core.go
Lines 153 to 156 in 6ef6f63
if len(pods) < int(pg.Spec.MinMember) { | |
return fmt.Errorf("pre-filter pod %v cannot find enough sibling pods, "+ | |
"current pods number: %v, minMember of group: %v", pod.Name, len(pods), pg.Spec.MinMember) | |
} |
But we should not add this pod group to Backoff. If we add this pod group to Backoff, all following pods will be rejected.
pkg/coscheduling/coscheduling.go
Outdated
@@ -71,6 +72,7 @@ func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error) | |||
podInformer := handle.SharedInformerFactory().Core().V1().Pods() | |||
|
|||
scheduleTimeDuration := time.Duration(args.PermitWaitingTimeSeconds) * time.Second | |||
pgBackoff := time.Duration(args.PodGroupBackoffTime) * time.Second |
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.
Can you check if it's 0/nil here, and if yes, don't instantiate pgBackoff. So that we can check if pgBackoff is nil at L172 and only proceed get pods when it's not nil:
var pgBackoff ...
if args.PodGroupBackoffTime != 0 { ... }
func (pgMgr *PodGroupManager) AddToPodGroupBackoff(pgName string) { | ||
pgMgr.podGroupBackoff.Add(pgName, nil, 10*time.Second) | ||
func (pgMgr *PodGroupManager) BackoffPodGroup(pgName string, backoff time.Duration) { | ||
if backoff == time.Duration(0) { |
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.
commented elsewhere: IMO we should return as early as possible.
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 can check whether cs.pgBackoff != nil
outside, It's already done
pkg/coscheduling/coscheduling.go
Outdated
pods, err := cs.frameworkHandler.SharedInformerFactory().Core().V1().Pods().Lister().Pods(pod.Namespace).List( | ||
labels.SelectorFromSet(labels.Set{v1alpha1.PodGroupLabel: util.GetPodGroupLabel(pod)}), | ||
) | ||
if err == nil && len(pods) >= int(pg.Spec.MinMember) { |
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.
bump.
apis/config/scheme/scheme_test.go
Outdated
@@ -1022,6 +1024,7 @@ profiles: | |||
apiVersion: kubescheduler.config.k8s.io/v1 | |||
kind: CoschedulingArgs | |||
permitWaitingTimeSeconds: 10 | |||
podGroupBackoffTime: 0 |
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'd expect without explicitly specifying it, UT would also pass. Could you check if you want to add explicit defaulting logic? (convert nil from versioned args to 0 in internal args)
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.
podGroupBackoffTime: 0
means we will not backoff pod groups.
I think maybe we don't have to add explicit defaulting logic, because by default nil will be convert to 0
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.
That's correct. The previous comment was more about "how it behaves without explicitly setting the argument", and hence I'd like to see this UT passes w/o specifying it to 0.
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, I added a test for the case
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.
sry for confusing, I misread - this is the test for encode.
could you apply this diff - we want to test both defaulting logic (in decode), and encode for non-default logic: https://gist.github.com/Huang-Wei/d86f188b4e85b48ad4e3e4aa4bd427da
One comment ^^ and #559 (comment) |
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.
Final comments. (you can resolve them along with squashing into two commits: one for core changes, the other for code generation). Thanks.
apis/config/scheme/scheme_test.go
Outdated
@@ -1022,6 +1024,7 @@ profiles: | |||
apiVersion: kubescheduler.config.k8s.io/v1 | |||
kind: CoschedulingArgs | |||
permitWaitingTimeSeconds: 10 | |||
podGroupBackoffTime: 0 |
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.
sry for confusing, I misread - this is the test for encode.
could you apply this diff - we want to test both defaulting logic (in decode), and encode for non-default logic: https://gist.github.com/Huang-Wei/d86f188b4e85b48ad4e3e4aa4bd427da
No problem, but in this diff, we set default backoff time to 60, not to 0, if there is not any args in profile, is this same with our expectation? |
Signed-off-by: KunWuLuan <kunwuluan@gmail.com>
That was "PermitWaitingTimeSeconds" :) not backoff time. PermitWaitingTimeSeconds defaults to 60 as-is; Backoff time defaults to 0. The logic is accurate. |
Added release note. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Huang-Wei, KunWuLuan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adding a backoff in co-scheduling (#429 (comment)) helps to avoid infinite scheduling loop.