mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #69355 from bsalamat/perc_validation
Add validation for percentage-of-nodes-to-score of the scheduler config
This commit is contained in:
commit
fe379ec945
@ -44,6 +44,10 @@ func ValidateKubeSchedulerConfiguration(cc *config.KubeSchedulerConfiguration) f
|
|||||||
if cc.BindTimeoutSeconds == nil {
|
if cc.BindTimeoutSeconds == nil {
|
||||||
allErrs = append(allErrs, field.Required(field.NewPath("bindTimeoutSeconds"), ""))
|
allErrs = append(allErrs, field.Required(field.NewPath("bindTimeoutSeconds"), ""))
|
||||||
}
|
}
|
||||||
|
if cc.PercentageOfNodesToScore < 0 || cc.PercentageOfNodesToScore > 100 {
|
||||||
|
allErrs = append(allErrs, field.Invalid(field.NewPath("percentageOfNodesToScore"),
|
||||||
|
cc.PercentageOfNodesToScore, "not in valid range 0-100"))
|
||||||
|
}
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
BindTimeoutSeconds: &testTimeout,
|
BindTimeoutSeconds: &testTimeout,
|
||||||
|
PercentageOfNodesToScore: 35,
|
||||||
}
|
}
|
||||||
|
|
||||||
HardPodAffinitySymmetricWeightGt100 := validConfig.DeepCopy()
|
HardPodAffinitySymmetricWeightGt100 := validConfig.DeepCopy()
|
||||||
@ -92,6 +93,9 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
|
|||||||
bindTimeoutUnset := validConfig.DeepCopy()
|
bindTimeoutUnset := validConfig.DeepCopy()
|
||||||
bindTimeoutUnset.BindTimeoutSeconds = nil
|
bindTimeoutUnset.BindTimeoutSeconds = nil
|
||||||
|
|
||||||
|
percentageOfNodesToScore101 := validConfig.DeepCopy()
|
||||||
|
percentageOfNodesToScore101.PercentageOfNodesToScore = int32(101)
|
||||||
|
|
||||||
scenarios := map[string]struct {
|
scenarios := map[string]struct {
|
||||||
expectedToFail bool
|
expectedToFail bool
|
||||||
config *config.KubeSchedulerConfiguration
|
config *config.KubeSchedulerConfiguration
|
||||||
@ -136,6 +140,10 @@ func TestValidateKubeSchedulerConfiguration(t *testing.T) {
|
|||||||
expectedToFail: true,
|
expectedToFail: true,
|
||||||
config: bindTimeoutUnset,
|
config: bindTimeoutUnset,
|
||||||
},
|
},
|
||||||
|
"bad-percentage-of-nodes-to-score": {
|
||||||
|
expectedToFail: true,
|
||||||
|
config: percentageOfNodesToScore101,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, scenario := range scenarios {
|
for name, scenario := range scenarios {
|
||||||
|
Loading…
Reference in New Issue
Block a user