mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 13:29:11 +01:00
Merge pull request #1158 from a7i/fix-plugin-arg-copy-release-1.27
fix plugin arg conversion when using multiple profiles with same plugin
This commit is contained in:
@@ -88,7 +88,7 @@ func convertToInternalPluginConfigArgs(out *api.DeschedulerPolicy) error {
|
|||||||
func Convert_v1alpha2_PluginConfig_To_api_PluginConfig(in *PluginConfig, out *api.PluginConfig, s conversion.Scope) error {
|
func Convert_v1alpha2_PluginConfig_To_api_PluginConfig(in *PluginConfig, out *api.PluginConfig, s conversion.Scope) error {
|
||||||
out.Name = in.Name
|
out.Name = in.Name
|
||||||
if _, ok := pluginregistry.PluginRegistry[in.Name]; ok {
|
if _, ok := pluginregistry.PluginRegistry[in.Name]; ok {
|
||||||
out.Args = pluginregistry.PluginRegistry[in.Name].PluginArgInstance
|
out.Args = pluginregistry.PluginRegistry[in.Name].PluginArgInstance.DeepCopyObject()
|
||||||
if in.Args.Raw != nil {
|
if in.Args.Raw != nil {
|
||||||
_, _, err := Codecs.UniversalDecoder().Decode(in.Args.Raw, nil, out.Args)
|
_, _, err := Codecs.UniversalDecoder().Decode(in.Args.Raw, nil, out.Args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
@@ -133,29 +135,22 @@ func setDefaultEvictor(profile api.DeschedulerProfile, client clientset.Interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
func validateDeschedulerConfiguration(in api.DeschedulerPolicy, registry pluginregistry.Registry) error {
|
func validateDeschedulerConfiguration(in api.DeschedulerPolicy, registry pluginregistry.Registry) error {
|
||||||
var errorsInProfiles error
|
var errorsInProfiles []error
|
||||||
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 = append(errorsInProfiles, fmt.Errorf("in profile %s: plugin %s in pluginConfig not registered", profile.Name, pluginConfig.Name))
|
||||||
errorsInProfiles = fmt.Errorf("%w: %s", errorsInProfiles, fmt.Sprintf("in profile %s: plugin %s in pluginConfig not registered", profile.Name, pluginConfig.Name))
|
continue
|
||||||
continue
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pluginUtilities := registry[pluginConfig.Name]
|
pluginUtilities := registry[pluginConfig.Name]
|
||||||
if pluginUtilities.PluginArgValidator == nil {
|
if pluginUtilities.PluginArgValidator == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
err := pluginUtilities.PluginArgValidator(pluginConfig.Args)
|
if err := pluginUtilities.PluginArgValidator(pluginConfig.Args); err != nil {
|
||||||
if err != nil {
|
errorsInProfiles = append(errorsInProfiles, fmt.Errorf("in profile %s: %s", profile.Name, err.Error()))
|
||||||
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()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errorsInProfiles
|
return utilerrors.NewAggregate(errorsInProfiles)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -985,7 +985,7 @@ func TestValidateDeschedulerConfiguration(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
result: fmt.Errorf("in profile RemoveFailedPods: only one of Include/Exclude namespaces can be set: in profile RemovePodsViolatingTopologySpreadConstraint: only one of Include/Exclude namespaces can be set"),
|
result: fmt.Errorf("[in profile RemoveFailedPods: only one of Include/Exclude namespaces can be set, in profile RemovePodsViolatingTopologySpreadConstraint: only one of Include/Exclude namespaces can be set]"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user