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

custom plugin config should take precedence over default plugin config #99582

Merged
merged 1 commit into from
Jul 7, 2021

Conversation

chendave
Copy link
Member

@chendave chendave commented Mar 1, 2021

Signed-off-by: Dave Chen dave.chen@arm.com

What type of PR is this?

Add one of the following kinds:
/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #99580

Special notes for your reviewer:

Does this PR introduce a user-facing change?

kube-scheduler: a plugin enabled in a v1beta2 configuration file takes precedence over the default configuration for that plugin; this simplifies enabling default plugins with custom configuration without needing to explicitly disable those default plugins.

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


@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/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 1, 2021
@k8s-ci-robot
Copy link
Contributor

@chendave: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Mar 1, 2021
@chendave
Copy link
Member Author

chendave commented Mar 1, 2021

/sig scheduling

@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 1, 2021
@chendave
Copy link
Member Author

chendave commented Mar 1, 2021

/cc @Huang-Wei @ahg-g @alculquicondor

pkg/scheduler/apis/config/types.go Outdated Show resolved Hide resolved

var enabledPlugins []Plugin
if !disabledPlugins.Has("*") {
for _, defaultEnabledPlugin := range defaultPluginSet.Enabled {
if disabledPlugins.Has(defaultEnabledPlugin.Name) {
// custom plugin config will take precedence over default plugin config
if disabledPlugins.Has(defaultEnabledPlugin.Name) || enabledCustomPlugin.Has(defaultEnabledPlugin.Name) {
Copy link
Member

Choose a reason for hiding this comment

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

(a bit off the topic)

@alculquicondor no matter with or w/o this PR, a lightweight customized plugin may be placed in the end, am I understanding right?

@chendave
Copy link
Member Author

chendave commented Mar 8, 2021

@alculquicondor @Huang-Wei , I managed to reserve both the order of default and custom plugins.

Current code implementation and testcase, "InsertBeforeAllPlugins" for example, show me that the overwrite of the default plugin config is allowed, so this PR intends to release us from explicitly disable the default plugins and then re-enable it again, which sound like a hack to me, this will help reduce the surprise to end user.

@chendave
Copy link
Member Author

chendave commented Mar 8, 2021

/retest

@chendave
Copy link
Member Author

/remove-kind bug
/kind feature

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Mar 15, 2021
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 13, 2021
@chendave
Copy link
Member Author

/remove-lifecycle stale

@chendave
Copy link
Member Author

chendave commented Jul 6, 2021

/retest

Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

Since you are changing the interpretation of PluginSet.Enabled, you need to update the documentation for the field in k8s.io/kube-scheduler/config/v1beta2/types.go

for _, disabledPlugin := range customPluginSet.Disabled {
disabledPlugins.Insert(disabledPlugin.Name)
}

for index, enabledPlugin := range customPluginSet.Enabled {
enabledCustomPlugins[enabledPlugin.Name] = pluginIndex{index, enabledPlugin}
Copy link
Member

Choose a reason for hiding this comment

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

only the first repetition?

Copy link
Member Author

Choose a reason for hiding this comment

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

true, seems like we'd better to validate this config to avoid the case of repetition, will fix it in my next day!

Copy link
Member

Choose a reason for hiding this comment

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

recall that code freeze is on Thursday

Copy link
Member Author

Choose a reason for hiding this comment

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

because mergePlugins is done before the validation, so the repetition here is still possible, I'd suggest to just log something here or revert to the original version, only the last repetition will be valid for either way.
I am a little lost here, do you have any suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

You can keep it like this, it doesn't really matter because more than one repetition will fail later.

Fix the types.go though


// The default plugin is explicitly re-configured, update the default plugin accordingly.
if customPlugin, ok := enabledCustomPlugins[defaultEnabledPlugin.Name]; ok {
klog.InfoS("Defaut plugin is explicitly re-configured, will be overridden.", "plugin", defaultEnabledPlugin.Name)
Copy link
Member

Choose a reason for hiding this comment

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

use present tense: overriding

@alculquicondor
Copy link
Member

You probably need to run make update

@chendave
Copy link
Member Author

chendave commented Jul 6, 2021

You probably need to run make update

I did, nothing was changed.

@chendave
Copy link
Member Author

chendave commented Jul 6, 2021

only run make generated_files which I think should be enough.

@alculquicondor
Copy link
Member

/approve
/lgtm

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

/label api-review
/retest

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Jul 6, 2021
@liggitt
Copy link
Member

liggitt commented Jul 6, 2021

does this fix only apply to v1beta2 configs? if so, should that be noted in the release note?

@liggitt
Copy link
Member

liggitt commented Jul 6, 2021

My understanding is that this makes config files work which would previously fail validation (because they didn't explicitly disable the default plugin they wanted to explicitly enable), and would have no impact on config files which were previously working. Is that correct?

@liggitt liggitt added this to In progress in API Reviews Jul 6, 2021
@liggitt liggitt self-assigned this Jul 6, 2021
@liggitt liggitt added this to the v1.22 milestone Jul 6, 2021
@chendave
Copy link
Member Author

chendave commented Jul 6, 2021

does this fix only apply to v1beta2 configs? if so, should that be noted in the release note?

Just updated

@chendave
Copy link
Member Author

chendave commented Jul 6, 2021

My understanding is that this makes config files work which would previously fail validation (because they didn't explicitly disable the default plugin they wanted to explicitly enable), and would have no impact on config files which were previously working. Is that correct?

yes, no impact on the previous config file, this PR does some enhancement only if the default plugin is not disabled by *, and thus more flexible for end-user to config, and avoid unnecessary failure if there is no config confliction with default plugin (could be overridden).

@liggitt
Copy link
Member

liggitt commented Jul 7, 2021

/approve

for API bits

@liggitt liggitt moved this from In progress to API review completed, 1.22 in API Reviews Jul 7, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alculquicondor, chendave, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
Status: API review completed, 1.22
Development

Successfully merging this pull request may close these issues.

scheduler failed to start due to the custom plugin config in scheduler config file
6 participants