mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
validate ipvs scheduler
This commit is contained in:
@@ -38,6 +38,7 @@ func Validate(config *componentconfig.KubeProxyConfiguration) field.ErrorList {
|
||||
allErrs = append(allErrs, validateKubeProxyConntrackConfiguration(config.Conntrack, newPath.Child("KubeProxyConntrackConfiguration"))...)
|
||||
allErrs = append(allErrs, validateProxyMode(config.Mode, newPath.Child("Mode"))...)
|
||||
allErrs = append(allErrs, validateClientConnectionConfiguration(config.ClientConnection, newPath.Child("ClientConnection"))...)
|
||||
allErrs = append(allErrs, validateIPVSSchedulerMethod(config.IPVS.Scheduler, newPath.Child("KubeProxyIPVSConfiguration").Child("Scheduler"))...)
|
||||
|
||||
if config.OOMScoreAdj != nil && (*config.OOMScoreAdj < -1000 || *config.OOMScoreAdj > 1000) {
|
||||
allErrs = append(allErrs, field.Invalid(newPath.Child("OOMScoreAdj"), *config.OOMScoreAdj, "must be within the range [-1000, 1000]"))
|
||||
@@ -156,3 +157,33 @@ func validateHostPort(input string, fldPath *field.Path) field.ErrorList {
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateIPVSSchedulerMethod(scheduler string, fldPath *field.Path) field.ErrorList {
|
||||
supportedMethod := []string{
|
||||
string(componentconfig.RoundRobin),
|
||||
string(componentconfig.WeightedRoundRobin),
|
||||
string(componentconfig.LeastConnection),
|
||||
string(componentconfig.WeightedLeastConnection),
|
||||
string(componentconfig.LocalityBasedLeastConnection),
|
||||
string(componentconfig.LocalityBasedLeastConnectionWithReplication),
|
||||
string(componentconfig.SourceHashing),
|
||||
string(componentconfig.DestinationHashing),
|
||||
string(componentconfig.ShortestExpectedDelay),
|
||||
string(componentconfig.NeverQueue),
|
||||
"",
|
||||
}
|
||||
allErrs := field.ErrorList{}
|
||||
var found bool
|
||||
for i := range supportedMethod {
|
||||
if scheduler == supportedMethod[i] {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
// Not found
|
||||
if !found {
|
||||
errMsg := fmt.Sprintf("must be in %v, blank means the default algorithm method (currently rr)", supportedMethod)
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("Scheduler"), string(scheduler), errMsg))
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user