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
Conversation
@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 The 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. |
/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)) |
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 be better to move these under ValidateNodeResourcesFitArgs
?
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.
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 makes sense. The check logic has been moved to ValidateNodeResourcesFitArgs
.
8e5814e
to
ae78999
Compare
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. |
ae78999
to
d600773
Compare
/test pull-kubernetes-e2e-gce-ubuntu-containerd |
@@ -31,6 +31,12 @@ import ( | |||
"k8s.io/kubernetes/pkg/scheduler/apis/config" | |||
) | |||
|
|||
var supportedScoringStrategyType = sets.NewString( |
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.
supportedScoringStrategyTypes
or supportedScoringStrategySet
?
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.
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.
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.
This is a reference to ServiceType:
kubernetes/pkg/apis/core/validation/validation.go
Lines 4485 to 4486 in eb2f56c
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
.
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.
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.
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 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?
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, Thanks!
d600773
to
334d591
Compare
/test pull-kubernetes-e2e-gce-ubuntu-containerd |
/lgtm |
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.
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)) { |
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.
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.
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.
Thanks @ahg-g that is reasonable. I have updated the PR.
…pe field and print supported ScoringStrategyType list on error
334d591
to
107dee6
Compare
/lgtm |
kindly ping @ahg-g |
/approve |
[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 |
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:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: