mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #106169 from kerthcet/bug/shape-can-be-empty-in-scoring-stragety
ScoringStrategy RequestedToCapacityRatio's shape should not be empty
This commit is contained in:
commit
d9f06f9e18
@ -306,7 +306,7 @@ func ValidateNodeResourcesFitArgs(path *field.Path, args *config.NodeResourcesFi
|
|||||||
|
|
||||||
if args.ScoringStrategy != nil {
|
if args.ScoringStrategy != nil {
|
||||||
allErrs = append(allErrs, validateResources(args.ScoringStrategy.Resources, path.Child("resources"))...)
|
allErrs = append(allErrs, validateResources(args.ScoringStrategy.Resources, path.Child("resources"))...)
|
||||||
if args.ScoringStrategy.RequestedToCapacityRatio != nil && len(args.ScoringStrategy.RequestedToCapacityRatio.Shape) > 0 {
|
if args.ScoringStrategy.RequestedToCapacityRatio != nil {
|
||||||
allErrs = append(allErrs, validateFunctionShape(args.ScoringStrategy.RequestedToCapacityRatio.Shape, path.Child("shape"))...)
|
allErrs = append(allErrs, validateFunctionShape(args.ScoringStrategy.RequestedToCapacityRatio.Shape, path.Child("shape"))...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -947,6 +947,12 @@ func TestValidateMostAllocatedScoringStrategy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestValidateRequestedToCapacityRatioScoringStrategy(t *testing.T) {
|
func TestValidateRequestedToCapacityRatioScoringStrategy(t *testing.T) {
|
||||||
|
defaultShape := []config.UtilizationShapePoint{
|
||||||
|
{
|
||||||
|
Utilization: 30,
|
||||||
|
Score: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
resources []config.ResourceSpec
|
resources []config.ResourceSpec
|
||||||
@ -954,7 +960,18 @@ func TestValidateRequestedToCapacityRatioScoringStrategy(t *testing.T) {
|
|||||||
wantErrs field.ErrorList
|
wantErrs field.ErrorList
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "weight greater than max",
|
name: "no shapes",
|
||||||
|
shapes: nil,
|
||||||
|
wantErrs: field.ErrorList{
|
||||||
|
{
|
||||||
|
Type: field.ErrorTypeRequired,
|
||||||
|
Field: "shape",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "weight greater than max",
|
||||||
|
shapes: defaultShape,
|
||||||
resources: []config.ResourceSpec{
|
resources: []config.ResourceSpec{
|
||||||
{
|
{
|
||||||
Name: "cpu",
|
Name: "cpu",
|
||||||
@ -969,7 +986,8 @@ func TestValidateRequestedToCapacityRatioScoringStrategy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "weight less than min",
|
name: "weight less than min",
|
||||||
|
shapes: defaultShape,
|
||||||
resources: []config.ResourceSpec{
|
resources: []config.ResourceSpec{
|
||||||
{
|
{
|
||||||
Name: "cpu",
|
Name: "cpu",
|
||||||
@ -984,13 +1002,8 @@ func TestValidateRequestedToCapacityRatioScoringStrategy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "valid shapes",
|
name: "valid shapes",
|
||||||
shapes: []config.UtilizationShapePoint{
|
shapes: defaultShape,
|
||||||
{
|
|
||||||
Utilization: 30,
|
|
||||||
Score: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
wantErrs: nil,
|
wantErrs: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user