mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
@@ -123,7 +123,7 @@ func setDefaultEvictor(profile api.DeschedulerProfile, client clientset.Interfac
|
|||||||
idx = 0
|
idx = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
thresholdPriority, err := utils.GetPriorityFromStrategyParams(context.TODO(), client, defaultevictorPluginConfig.Args.(*defaultevictor.DefaultEvictorArgs).PriorityThreshold)
|
thresholdPriority, err := utils.GetPriorityValueFromPriorityThreshold(context.TODO(), client, defaultevictorPluginConfig.Args.(*defaultevictor.DefaultEvictorArgs).PriorityThreshold)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Error(err, "Failed to get threshold priority from args")
|
klog.Error(err, "Failed to get threshold priority from args")
|
||||||
}
|
}
|
||||||
@@ -137,36 +137,25 @@ func validateDeschedulerConfiguration(in api.DeschedulerPolicy, registry pluginr
|
|||||||
for _, profile := range in.Profiles {
|
for _, profile := range in.Profiles {
|
||||||
for _, pluginConfig := range profile.PluginConfigs {
|
for _, pluginConfig := range profile.PluginConfigs {
|
||||||
if _, ok := registry[pluginConfig.Name]; ok {
|
if _, ok := registry[pluginConfig.Name]; ok {
|
||||||
|
if _, ok := registry[pluginConfig.Name]; !ok {
|
||||||
|
errorsInProfiles = fmt.Errorf("%w: %s", errorsInProfiles, fmt.Sprintf("in profile %s: plugin %s in pluginConfig not registered", profile.Name, pluginConfig.Name))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
pluginUtilities := registry[pluginConfig.Name]
|
pluginUtilities := registry[pluginConfig.Name]
|
||||||
if pluginUtilities.PluginArgValidator != nil {
|
if pluginUtilities.PluginArgValidator == nil {
|
||||||
err := pluginUtilities.PluginArgValidator(pluginConfig.Args)
|
continue
|
||||||
errorsInProfiles = setErrorsInProfiles(err, profile.Name, errorsInProfiles)
|
}
|
||||||
|
err := pluginUtilities.PluginArgValidator(pluginConfig.Args)
|
||||||
|
if err != nil {
|
||||||
|
if errorsInProfiles == nil {
|
||||||
|
errorsInProfiles = fmt.Errorf("in profile %s: %s", profile.Name, err.Error())
|
||||||
|
} else {
|
||||||
|
errorsInProfiles = fmt.Errorf("%w: %s", errorsInProfiles, fmt.Sprintf("in profile %s: %s", profile.Name, err.Error()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if errorsInProfiles != nil {
|
|
||||||
return errorsInProfiles
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setErrorsInProfiles(err error, profileName string, errorsInProfiles error) error {
|
|
||||||
if err != nil {
|
|
||||||
if errorsInProfiles == nil {
|
|
||||||
errorsInProfiles = fmt.Errorf("in profile %s: %s", profileName, err.Error())
|
|
||||||
} else {
|
|
||||||
errorsInProfiles = fmt.Errorf("%w: %s", errorsInProfiles, fmt.Sprintf("in profile %s: %s", profileName, err.Error()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return errorsInProfiles
|
return errorsInProfiles
|
||||||
}
|
}
|
||||||
|
|
||||||
func hasPluginConfigsWithSameName(newPluginConfig api.PluginConfig, pluginConfigs []api.PluginConfig) bool {
|
|
||||||
for _, pluginConfig := range pluginConfigs {
|
|
||||||
if newPluginConfig.Name == pluginConfig.Name {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -53,26 +53,6 @@ func GetPriorityFromPriorityClass(ctx context.Context, client clientset.Interfac
|
|||||||
return SystemCriticalPriority, nil
|
return SystemCriticalPriority, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPriorityFromStrategyParams gets priority from the given StrategyParameters.
|
|
||||||
// It will return SystemCriticalPriority by default.
|
|
||||||
func GetPriorityFromStrategyParams(ctx context.Context, client clientset.Interface, priorityThreshold *api.PriorityThreshold) (priority int32, err error) {
|
|
||||||
if priorityThreshold == nil {
|
|
||||||
return SystemCriticalPriority, nil
|
|
||||||
}
|
|
||||||
if priorityThreshold.Value != nil {
|
|
||||||
priority = *priorityThreshold.Value
|
|
||||||
} else {
|
|
||||||
priority, err = GetPriorityFromPriorityClass(ctx, client, priorityThreshold.Name)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if priority > SystemCriticalPriority {
|
|
||||||
return 0, fmt.Errorf("Priority threshold can't be greater than %d", SystemCriticalPriority)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetPriorityValueFromPriorityThreshold gets priority from the given PriorityThreshold.
|
// GetPriorityValueFromPriorityThreshold gets priority from the given PriorityThreshold.
|
||||||
// It will return SystemCriticalPriority by default.
|
// It will return SystemCriticalPriority by default.
|
||||||
func GetPriorityValueFromPriorityThreshold(ctx context.Context, client clientset.Interface, priorityThreshold *api.PriorityThreshold) (priority int32, err error) {
|
func GetPriorityValueFromPriorityThreshold(ctx context.Context, client clientset.Interface, priorityThreshold *api.PriorityThreshold) (priority int32, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user