Skip to content
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 support for multiple scheduling profiles #88285

Merged

Conversation

alculquicondor
Copy link
Member

@alculquicondor alculquicondor commented Feb 18, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

kube-scheduler can run with more than one profile. Given a pod, the profile is selected by using .spec.SchedulerName.
Profiles should have different scheduler names. They should have the same queue sort plugin configuration.

Which issue(s) this PR fixes:

Part of #85737, kubernetes/enhancements#1451

Special notes for your reviewer:

This PR builds on top of #88087, so you can review from the commit titled: Support multiple scheduling profiles in a single scheduler

For convenience, I split this PR in 2 commits, which will be squashed after the review.

  • implementation and tests for new package.
  • fixes for existing tests.

A follow up PR will add unit and integration tests to exercise the multiple profiles.

Does this PR introduce a user-facing change?:

kube-scheduler can run more than one scheduling profile. Given a pod, the profile is selected by using its `.spec.SchedulerName`.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/kubernetes/enhancements/blob/master/keps/sig-scheduling/20200114-multi-scheduling-profiles.md

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Feb 18, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 18, 2020
@alculquicondor alculquicondor force-pushed the multiprofiles-runtime branch 2 times, most recently from 5f08ebd to f7464c4 Compare February 18, 2020 22:58
@fejta-bot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

pkg/scheduler/apis/config/testing/compatibility_test.go Outdated Show resolved Hide resolved
pkg/scheduler/factory_test.go Outdated Show resolved Hide resolved
pkg/scheduler/factory_test.go Outdated Show resolved Hide resolved
pkg/scheduler/factory_test.go Outdated Show resolved Hide resolved
pkg/scheduler/scheduler_test.go Outdated Show resolved Hide resolved
@@ -591,7 +598,7 @@ func TestSchedulerFailedSchedulingReasons(t *testing.T) {

// queuedPodStore: pods queued before processing.
// scache: scheduler cache that might contain assumed pods.
func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache internalcache.Cache, informerFactory informers.SharedInformerFactory, recorder events.EventRecorder, fakeVolumeBinder *volumebinder.VolumeBinder, fns ...st.RegisterPluginFunc) (*Scheduler, chan *v1.Binding, chan error) {
func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache internalcache.Cache, informerFactory informers.SharedInformerFactory, broadcaster events.EventBroadcaster, fakeVolumeBinder *volumebinder.VolumeBinder, fns ...st.RegisterPluginFunc) (*Scheduler, chan *v1.Binding, chan error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing it as an argument, I would create the EventBroadcaster inside the function and return it (since a couple of tests require it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that there are the same amount of tests that use it than tests that don't.
I prefer to keep it as is for now given that the PR is quite big already.

pkg/scheduler/factory.go Outdated Show resolved Hide resolved
pkg/scheduler/profile/profile.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the sig/apps Categorizes an issue or PR as relevant to SIG Apps. label Feb 19, 2020
@alculquicondor
Copy link
Member Author

/retest

@alculquicondor
Copy link
Member Author

/assign @Huang-Wei for a second pass

It looks like the api-review is almost done

Copy link
Member

@Huang-Wei Huang-Wei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments.

pkg/scheduler/core/generic_scheduler.go Outdated Show resolved Hide resolved
cmd/kube-scheduler/app/server.go Show resolved Hide resolved
cmd/kube-scheduler/app/server.go Outdated Show resolved Hide resolved
Comment on lines +184 to +187
prof := &c.profiles[i]
plugins := &schedulerapi.Plugins{}
plugins.Append(defaultPlugins)
plugins.Apply(prof.Plugins)
prof.Plugins = plugins
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these 5 lines can be extracted into a function to avoid duplication (with L304~L308)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind too much. They are slightly different and createFromConfig should go away soon when we remove policy support.

pkg/scheduler/core/generic_scheduler.go Outdated Show resolved Hide resolved
pkg/scheduler/scheduler.go Show resolved Hide resolved
@alculquicondor
Copy link
Member Author

/priority important-soon

/hold for #88087

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 21, 2020
@alculquicondor
Copy link
Member Author

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 25, 2020
@alculquicondor
Copy link
Member Author

alculquicondor commented Feb 25, 2020

/assign @msau42
for test

@k8s-ci-robot
Copy link
Contributor

@alculquicondor: GitHub didn't allow me to assign the following users: for, test.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @msau42 for test

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.

Copy link
Member

@ahg-g ahg-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me.

@@ -215,7 +197,9 @@ func WithPodMaxBackoffSeconds(podMaxBackoffSeconds int64) Option {
}

var defaultSchedulerOptions = schedulerOptions{
schedulerName: v1.DefaultSchedulerName,
profiles: []schedulerapi.KubeSchedulerProfile{
{SchedulerName: v1.DefaultSchedulerName},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment clarifying that the default provider plugins is used by default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Aldo Culquicondor <acondor@google.com>
@ahg-g
Copy link
Member

ahg-g commented Feb 25, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 25, 2020
@alculquicondor
Copy link
Member Author

/retest

@msau42
Copy link
Member

msau42 commented Feb 25, 2020

/approve
for test

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, msau42

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2020
@alculquicondor
Copy link
Member Author

/retest

1 similar comment
@alculquicondor
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit f7c37d3 into kubernetes:master Feb 26, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants