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

kube-scheduler: Use default predicates/prioritizers if they are unspecified in the policy config #59363

Merged
merged 1 commit into from
Feb 7, 2018

Conversation

yguo0905
Copy link
Contributor

@yguo0905 yguo0905 commented Feb 5, 2018

What this PR does / why we need it:

The scheduler has built-in default sets of predicate/prioritizer that are applied on pod scheduling. It can also take a policy config file where predicate/prioritizer and extender settings can be specified. The current behavior is that if we want to configure an extender using the policy config, we have to also provide the default predicate/prioritizer settings. Otherwise, the empty predicate/prioritizer sets will be used.

This is inconvenient, and it's hard to keep the policy config up to date with the scheduler's defaults. This PR changes the scheduler to use the default predicate/prioritizer sets if they are unspecified in the policy config. But an empty list would bypass non-mandatory predicates/prioritizers.

This will change the behavior of a policy config that does not specify (but not empty list) predicate/prioritizer, but it's unlike someone is using such config in practice.

Special notes for your reviewer:

I think it makes sense to have this in 1.9 as well because

  • It's safe, given the scope of this change and the fact that it's very unlikely that someone is using a policy config with empty predicates/prioritizers.
  • Compared with the risk, asking users to provide the default predicate/prioritizer sets for is error-prone and may cause other issues.

Release note:

kube-scheduler: Use default predicates/prioritizers if they are unspecified in the policy config

/sig scheduling
/assign @bsalamat
/cc @vishh

@k8s-ci-robot k8s-ci-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 5, 2018
@k8s-ci-robot k8s-ci-robot requested a review from vishh February 5, 2018 19:03
@k8s-ci-robot k8s-ci-robot added 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 5, 2018
for _, predicate := range policy.Predicates {
glog.V(2).Infof("Registering predicate: %s", predicate.Name)
predicateKeys.Insert(RegisterCustomFitPredicate(predicate))
if len(policy.Predicates) == 0 {
Copy link
Member

@bsalamat bsalamat Feb 5, 2018

Choose a reason for hiding this comment

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

Can you change it to use defaults only when the predicates and/or priorities are not provided? We would like to keep the possibility of bypassing all predicate or priority functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

// Test configures a scheduler from a policy that does not contain any
// predicates or priorities.
// The predicates or priorities from DefaultProvider will be used.
func TestCreateFromConfigWithEmptyPredicatesAndPriorities(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

We need an integration test to cover all the logic, including the decoding of policy config. Coding an integration test is similar. Please see this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 6, 2018
@yguo0905
Copy link
Contributor Author

yguo0905 commented Feb 6, 2018

/retest

Copy link
Member

@bsalamat bsalamat left a comment

Choose a reason for hiding this comment

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

Thanks, @yguo0905!

/lgtm

@@ -541,3 +513,23 @@ func TestSkipPodUpdate(t *testing.T) {
}
}
}

func newConfigFactory(client *clientset.Clientset, hardPodAffinitySymmetricWeight int32) scheduler.Configurator {
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for adding this!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bsalamat, yguo0905

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your 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 6, 2018
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 59394, 58769, 59423, 59363, 59245). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 4b01601 into kubernetes:master Feb 7, 2018
@yguo0905 yguo0905 deleted the sched-config branch February 7, 2018 17:59
rohitagarwal003 added a commit to rohitagarwal003/kubernetes that referenced this pull request Apr 6, 2018
We now use default predicates/priorities if they are unspecified in the policy
config (kubernetes#59363).

The other example in ./scheduler-policy-config.json shows how to use priorities
and predicates.

Let's use this example to show how to use extenders. When you are using
extenders you don't necessarily want to mess with priorities and predicates
(kubernetes#45188).
rohitagarwal003 added a commit to rohitagarwal003/examples that referenced this pull request Apr 9, 2018
We now use default predicates/priorities if they are unspecified in the policy
config (kubernetes/kubernetes#59363).

The other example in ./scheduler-policy-config.json shows how to use priorities
and predicates.

Let's use this example to show how to use extenders. When you are using
extenders you don't necessarily want to mess with priorities and predicates
(kubernetes/kubernetes#45188).
rohitagarwal003 added a commit to rohitagarwal003/examples that referenced this pull request Apr 9, 2018
We now use default predicates/priorities if they are unspecified in the policy
config (kubernetes/kubernetes#59363).

The other example in ./scheduler-policy-config.json shows how to use priorities
and predicates.

Let's use this example to show how to use extenders. When you are using
extenders you don't necessarily want to mess with priorities and predicates
(kubernetes/kubernetes#45188).

Also remove duplicate file.
joukojoutomies pushed a commit to joukojoutomies/eksdemo that referenced this pull request Dec 19, 2018
We now use default predicates/priorities if they are unspecified in the policy
config (kubernetes/kubernetes#59363).

The other example in ./scheduler-policy-config.json shows how to use priorities
and predicates.

Let's use this example to show how to use extenders. When you are using
extenders you don't necessarily want to mess with priorities and predicates
(kubernetes/kubernetes#45188).

Also remove duplicate file.
talblubClouby96 added a commit to talblubClouby96/examples that referenced this pull request Aug 2, 2024
We now use default predicates/priorities if they are unspecified in the policy
config (kubernetes/kubernetes#59363).

The other example in ./scheduler-policy-config.json shows how to use priorities
and predicates.

Let's use this example to show how to use extenders. When you are using
extenders you don't necessarily want to mess with priorities and predicates
(kubernetes/kubernetes#45188).

Also remove duplicate file.
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants