-
Notifications
You must be signed in to change notification settings - Fork 38.9k
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
Add Schedulings Profiles to kubescheduler.config.k8s.io/v1alpha2 #88087
Conversation
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. |
7dba86c
to
71a5c2f
Compare
/hold for the parent PR |
71a5c2f
to
0dccc0b
Compare
pkg/scheduler/apis/config/types.go
Outdated
// SchedulerName is name of the scheduler, used to select which pods | ||
// will be processed by this profile, based on pod's "spec.SchedulerName". |
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.
Name is name of the profile ...
func validateCommonQueueSort(path *field.Path, profiles []config.KubeSchedulerProfile) field.ErrorList { | ||
allErrs := field.ErrorList{} | ||
var canon *config.PluginSet | ||
if profiles[0].Plugins != nil { |
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.
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.
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 is my thinking as well. I left a TODO here anyways.
d93ade2
to
60237ed
Compare
60237ed
to
8cf0d2f
Compare
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.
looks good to me
For api review
/cc @liggitt
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.
Some nits.
|
||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
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.
An idiomatic alias is metav1.
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
allErrs := field.ErrorList{} | ||
var canon *config.PluginSet | ||
if profiles[0].Plugins != nil { | ||
canon = profiles[0].Plugins.QueueSort |
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.
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]
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.
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.
838a475
to
2afc7ab
Compare
@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. |
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.
in the meantime, fail if more than one is specified so we don't leave master in a should-not-ship state?
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.
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
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 definitely needs to be documented in the user guide for this... that is not intuitive
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.
Will do.
} else { | ||
profile.Plugins = nil | ||
} | ||
profile.PluginConfig = *(*[]config.PluginConfig)(unsafe.Pointer(&in.PluginConfig)) |
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.
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) |
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.
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?
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.
Yes, this gives a more comprehensible error :)
Done
2afc7ab
to
22071ad
Compare
/hold for squash |
Anything else to add? Note that the implementation PR is already up for review #88285 |
/priority important-soon |
/approve API change lgtm. @ahg-g can lgtm. |
[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 |
@alculquicondor please squash |
Signed-off-by: Aldo Culquicondor <acondor@google.com>
22071ad
to
9e71741
Compare
Rebased and squashed |
/lgtm |
/retest |
/unhold |
/hold cancel |
/retest |
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?:
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: