Navigation Menu

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

scheduler: include supported ScoringStrategyType list in error message for NodeResourcesFit plugin #111206

Merged
merged 1 commit into from Jul 30, 2022

Conversation

SataQiu
Copy link
Member

@SataQiu SataQiu commented Jul 18, 2022

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

scheduler: include supported ScoringStrategyType list in error message for NodeResourcesFit plugin

After this patch:

E0718 07:13:34.754796    9974 run.go:74] "command failed" err="initializing profiles: creating profile for scheduler name default-scheduler: initializing plugin \"NodeResourcesFit\": scoring strategy XXXX is not supported, only [LeastAllocated MostAllocated RequestedToCapacityRatio] is accepted"

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

scheduler: include supported ScoringStrategyType list in error message for NodeResourcesFit plugin

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 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 Jul 18, 2022
@k8s-ci-robot
Copy link
Contributor

@SataQiu: 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 needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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 Jul 18, 2022
@SataQiu
Copy link
Member Author

SataQiu commented Jul 18, 2022

/test pull-kubernetes-e2e-gce-ubuntu-containerd

@@ -119,7 +120,14 @@ func NewFit(plArgs runtime.Object, h framework.Handle, fts feature.Features) (fr
strategy := args.ScoringStrategy.Type
scorePlugin, exists := nodeResourceStrategyTypeMap[strategy]
if !exists {
return nil, fmt.Errorf("scoring strategy %s is not supported", strategy)
supportedScoringStrategyTypes := make([]config.ScoringStrategyType, 0, len(nodeResourceStrategyTypeMap))
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 be better to move these under ValidateNodeResourcesFitArgs?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

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 makes sense. The check logic has been moved to ValidateNodeResourcesFitArgs.

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Jul 20, 2022
@k8s-triage-robot
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.

@SataQiu
Copy link
Member Author

SataQiu commented Jul 21, 2022

/test pull-kubernetes-e2e-gce-ubuntu-containerd

@@ -31,6 +31,12 @@ import (
"k8s.io/kubernetes/pkg/scheduler/apis/config"
)

var supportedScoringStrategyType = sets.NewString(
Copy link
Member

Choose a reason for hiding this comment

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

supportedScoringStrategyTypes or supportedScoringStrategySet ?

Copy link
Member

Choose a reason for hiding this comment

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

Define a new set here may grow the maintenance costs, like when adding a new type in api package, but considering that the amount of ScoringStrategy types is quite stable, I think it's ok here.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a reference to ServiceType:

var supportedServiceType = sets.NewString(string(core.ServiceTypeClusterIP), string(core.ServiceTypeNodePort),
string(core.ServiceTypeLoadBalancer), string(core.ServiceTypeExternalName))

It is ok, if we want to use supportedScoringStrategyTypes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Define a new set here may grow the maintenance costs, like when adding a new type in api package, but considering that the amount of ScoringStrategy types is quite stable, I think it's ok here.

If a new type is added and we forget to update the supportedScoringStrategyTypes, I think the scheduler will fail to start with an unsupported type and we can easily find the issue and fix it. Our e2e tests should catch this.

Copy link
Member

@kerthcet kerthcet Jul 21, 2022

Choose a reason for hiding this comment

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

Yes if we have tests cover this when adding a new type. I mentioned this here for you used to fetch the supported types from nodeResourceStrategyTypeMap, now you defined a new variable here. I think it may because of the package circular dependency, right?

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, Thanks!

@SataQiu
Copy link
Member Author

SataQiu commented Jul 23, 2022

/test pull-kubernetes-e2e-gce-ubuntu-containerd

@kerthcet
Copy link
Member

/lgtm
/assign @ahg-g

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 23, 2022
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.

For posterity, in general this tighter validation is allowed only with a bump in CC version, but this case should be fine since we fail to instantiate the plugin down stream anyways at https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/framework/plugins/noderesources/fit.go#L120-L123

@@ -305,6 +311,9 @@ func ValidateNodeResourcesFitArgs(path *field.Path, args *config.NodeResourcesFi
}

if args.ScoringStrategy != nil {
if !supportedScoringStrategyTypes.Has(string(args.ScoringStrategy.Type)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to add context here to the path to include ScoringStrategy as a parent to the validations below.

strategyPath := path.Child("scoringStrategy")

and then use strategyPath instead of path below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @ahg-g that is reasonable. I have updated the PR.

…pe field and print supported ScoringStrategyType list on error
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 26, 2022
@SataQiu SataQiu requested review from kerthcet and ahg-g July 27, 2022 02:22
@kerthcet
Copy link
Member

/lgtm
Leave it to @ahg-g for final approval.

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

SataQiu commented Jul 30, 2022

kindly ping @ahg-g

@ahg-g
Copy link
Member

ahg-g commented Jul 30, 2022

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, SataQiu

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 Jul 30, 2022
@k8s-ci-robot k8s-ci-robot merged commit 2ae27c8 into kubernetes:master Jul 30, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone Jul 30, 2022
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants