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 Schedulings Profiles to kubescheduler.config.k8s.io/v1alpha2 #88087

Merged
merged 1 commit into from
Feb 24, 2020

Conversation

alculquicondor
Copy link
Member

@alculquicondor alculquicondor commented Feb 12, 2020

What type of PR is this?

/kind api-change

What this PR does / why we need it:

Cluster operators can use profiles to offer different scheduling behaviors to pods. Each profile is associated to a scheduler name which pods can select through .spec.schedulerName.
If not defined, a profile is added with the name default-scheduler.

This PR only implements API changes, along with defaults, validation and conversion from v1alpha1. kube-scheduler will only use the first profile and preserve its behavior.

A follow up PR will add runtime support for the multiple profiles.

Which issue(s) this PR fixes:

Part of #87617, #85737 and kubernetes/enhancements#1451

Does this PR introduce a user-facing change?:

Add Scheduling Profiles to kubescheduler.config.k8s.io/v1alpha2

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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 12, 2020
@k8s-ci-robot k8s-ci-robot added area/test 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 12, 2020
@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.

@alculquicondor alculquicondor force-pushed the mutiprofiles-api branch 2 times, most recently from 7dba86c to 71a5c2f Compare February 12, 2020 22:01
@alculquicondor
Copy link
Member Author

/assign @ahg-g @damemi

@alculquicondor
Copy link
Member Author

/hold for the parent PR

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 12, 2020
cmd/kube-scheduler/app/options/deprecated.go Show resolved Hide resolved
cmd/kube-scheduler/app/options/deprecated.go Show resolved Hide resolved
cmd/kube-scheduler/app/options/options_test.go Outdated Show resolved Hide resolved
pkg/scheduler/apis/config/types.go Show resolved Hide resolved
Comment on lines 106 to 107
// SchedulerName is name of the scheduler, used to select which pods
// will be processed by this profile, based on pod's "spec.SchedulerName".
Copy link
Member

Choose a reason for hiding this comment

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

Name is name of the profile ...

pkg/scheduler/apis/config/v1alpha2/defaults.go Outdated Show resolved Hide resolved
pkg/scheduler/apis/config/v1alpha2/defaults.go Outdated Show resolved Hide resolved
pkg/scheduler/apis/config/validation/validation.go Outdated Show resolved Hide resolved
pkg/scheduler/apis/config/types.go Outdated Show resolved Hide resolved
func validateCommonQueueSort(path *field.Path, profiles []config.KubeSchedulerProfile) field.ErrorList {
allErrs := field.ErrorList{}
var canon *config.PluginSet
if profiles[0].Plugins != nil {
Copy link
Member

Choose a reason for hiding this comment

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

How about the PluginConfig? It should be the same for all profiles as well, but I guess this is harder to validate since we don't really know what exact QueueSort Plugin names we will end up with at this point, so perhaps we can delay this to Framework instantiation.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is my thinking as well. I left a TODO here anyways.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 14, 2020
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

For api review
/cc @liggitt

staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go Outdated Show resolved Hide resolved
pkg/scheduler/apis/config/types.go Outdated Show resolved Hide resolved
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 nits.


v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Copy link
Member

Choose a reason for hiding this comment

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

An idiomatic alias is metav1.

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

allErrs := field.ErrorList{}
var canon *config.PluginSet
if profiles[0].Plugins != nil {
canon = profiles[0].Plugins.QueueSort
Copy link
Member

Choose a reason for hiding this comment

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

Are the following cases valid?

  • some profiles are missing queuesort plugin, however, queuesort plugin is at least specified in one profile
  • the profile(s) with queuesort plugin specified is(are) not at profiles[0]

Copy link
Member Author

Choose a reason for hiding this comment

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

Ideally, this validation logic shouldn't know about valid plugin names or what's the default plugin. That means it can't deduce if two configurations are equivalent. So, we decided that the queuesort plugin specification must be strictly equal. Then, the cases you describe are considered invalid.

@alculquicondor
Copy link
Member Author

@liggitt Friendly reminder

@@ -239,7 +242,8 @@ func (o *Options) Config() (*schedulerappconfig.Config, error) {
}

coreBroadcaster := record.NewBroadcaster()
coreRecorder := coreBroadcaster.NewRecorder(scheme.Scheme, corev1.EventSource{Component: c.ComponentConfig.SchedulerName})
// TODO(#85737): Support more than one profile.
Copy link
Member

Choose a reason for hiding this comment

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

in the meantime, fail if more than one is specified so we don't leave master in a should-not-ship state?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, since this recorder is used for leader election, we can only use one name. The first profile's name makes the most sense.

I added the error in server.go

Copy link
Member

@liggitt liggitt Feb 21, 2020

Choose a reason for hiding this comment

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

that definitely needs to be documented in the user guide for this... that is not intuitive

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do.

cmd/kube-scheduler/app/options/deprecated.go Show resolved Hide resolved
pkg/scheduler/apis/config/types.go Show resolved Hide resolved
} else {
profile.Plugins = nil
}
profile.PluginConfig = *(*[]config.PluginConfig)(unsafe.Pointer(&in.PluginConfig))
Copy link
Member

Choose a reason for hiding this comment

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

Prefer allocating an array and calling Convert_v1alpha1_PluginConfig_To_config_PluginConfig. In general, leave the unsafe casting to the generated conversion code (which does generate-time checks that the types are actually equivalent)

profile := &obj.Profiles[i]
if profile.SchedulerName == nil {
// Validation ensures that only one profile uses DefaultSchedulerName.
profile.SchedulerName = pointer.StringPtr(api.DefaultSchedulerName)
Copy link
Member

Choose a reason for hiding this comment

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

would it make more sense to only apply a default name if there's a single profile, and leave it undefaulted (and make validation fail with a "required" error) if there's more than a single profile?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this gives a more comprehensible error :)
Done

staging/src/k8s.io/kube-scheduler/config/v1alpha2/types.go Outdated Show resolved Hide resolved
@alculquicondor
Copy link
Member Author

/hold for squash

@alculquicondor
Copy link
Member Author

Anything else to add? Note that the implementation PR is already up for review #88285

@alculquicondor
Copy link
Member Author

/priority important-soon

@k8s-ci-robot k8s-ci-robot added 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
@liggitt
Copy link
Member

liggitt commented Feb 21, 2020

/approve

API change lgtm. @ahg-g can lgtm.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 21, 2020
@ahg-g
Copy link
Member

ahg-g commented Feb 24, 2020

@alculquicondor please squash

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

Rebased and squashed

@ahg-g
Copy link
Member

ahg-g commented Feb 24, 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 24, 2020
@alculquicondor
Copy link
Member Author

/retest

@Huang-Wei
Copy link
Member

/unhold

@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 24, 2020
@alculquicondor
Copy link
Member Author

/hold cancel

@alculquicondor
Copy link
Member Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit f6525db into kubernetes:master Feb 24, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Feb 24, 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 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/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants