mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 14:41:10 +01:00
update deprecated sets.String to generic sets
This commit is contained in:
@@ -53,8 +53,8 @@ func WrapFilterFuncs(filters ...FilterFunc) FilterFunc {
|
|||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
filter FilterFunc
|
filter FilterFunc
|
||||||
includedNamespaces sets.String
|
includedNamespaces sets.Set[string]
|
||||||
excludedNamespaces sets.String
|
excludedNamespaces sets.Set[string]
|
||||||
labelSelector *metav1.LabelSelector
|
labelSelector *metav1.LabelSelector
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,13 +71,13 @@ func (o *Options) WithFilter(filter FilterFunc) *Options {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithNamespaces sets included namespaces
|
// WithNamespaces sets included namespaces
|
||||||
func (o *Options) WithNamespaces(namespaces sets.String) *Options {
|
func (o *Options) WithNamespaces(namespaces sets.Set[string]) *Options {
|
||||||
o.includedNamespaces = namespaces
|
o.includedNamespaces = namespaces
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithoutNamespaces sets excluded namespaces
|
// WithoutNamespaces sets excluded namespaces
|
||||||
func (o *Options) WithoutNamespaces(namespaces sets.String) *Options {
|
func (o *Options) WithoutNamespaces(namespaces sets.Set[string]) *Options {
|
||||||
o.excludedNamespaces = namespaces
|
o.excludedNamespaces = namespaces
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -282,9 +282,9 @@ func evictPods(
|
|||||||
podEvictor frameworktypes.Evictor,
|
podEvictor frameworktypes.Evictor,
|
||||||
continueEviction continueEvictionCond,
|
continueEviction continueEvictionCond,
|
||||||
) {
|
) {
|
||||||
var excludedNamespaces sets.String
|
var excludedNamespaces sets.Set[string]
|
||||||
if evictableNamespaces != nil {
|
if evictableNamespaces != nil {
|
||||||
excludedNamespaces = sets.NewString(evictableNamespaces.Exclude...)
|
excludedNamespaces = sets.New(evictableNamespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if continueEviction(nodeInfo, totalAvailableUsage) {
|
if continueEviction(nodeInfo, totalAvailableUsage) {
|
||||||
|
|||||||
@@ -49,10 +49,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type PodLifeTimeArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type PodLifeTimeArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if podLifeTimeArgs.Namespaces != nil {
|
if podLifeTimeArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(podLifeTimeArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(podLifeTimeArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(podLifeTimeArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(podLifeTimeArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
||||||
@@ -72,7 +72,7 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
})
|
})
|
||||||
|
|
||||||
if len(podLifeTimeArgs.States) > 0 {
|
if len(podLifeTimeArgs.States) > 0 {
|
||||||
states := sets.NewString(podLifeTimeArgs.States...)
|
states := sets.New(podLifeTimeArgs.States...)
|
||||||
podFilter = podutil.WrapFilterFuncs(podFilter, func(pod *v1.Pod) bool {
|
podFilter = podutil.WrapFilterFuncs(podFilter, func(pod *v1.Pod) bool {
|
||||||
if states.Has(string(pod.Status.Phase)) {
|
if states.Has(string(pod.Status.Phase)) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error {
|
|||||||
return fmt.Errorf("failed to get label selectors from strategy's params: %+v", err)
|
return fmt.Errorf("failed to get label selectors from strategy's params: %+v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
podLifeTimeAllowedStates := sets.NewString(
|
podLifeTimeAllowedStates := sets.New(
|
||||||
string(v1.PodRunning),
|
string(v1.PodRunning),
|
||||||
string(v1.PodPending),
|
string(v1.PodPending),
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if !podLifeTimeAllowedStates.HasAll(args.States...) {
|
if !podLifeTimeAllowedStates.HasAll(args.States...) {
|
||||||
return fmt.Errorf("states must be one of %v", podLifeTimeAllowedStates.List())
|
return fmt.Errorf("states must be one of %v", podLifeTimeAllowedStates.UnsortedList())
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -64,10 +64,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type RemoveDuplicatesArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type RemoveDuplicatesArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if removeDuplicatesArgs.Namespaces != nil {
|
if removeDuplicatesArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(removeDuplicatesArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(removeDuplicatesArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(removeDuplicatesArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(removeDuplicatesArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
||||||
@@ -279,7 +279,7 @@ func hasExcludedOwnerRefKind(ownerRefs []metav1.OwnerReference, excludeOwnerKind
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
exclude := sets.NewString(excludeOwnerKinds...)
|
exclude := sets.New(excludeOwnerKinds...)
|
||||||
for _, owner := range ownerRefs {
|
for _, owner := range ownerRefs {
|
||||||
if exclude.Has(owner.Kind) {
|
if exclude.Has(owner.Kind) {
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type RemoveFailedPodsArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type RemoveFailedPodsArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if failedPodsArgs.Namespaces != nil {
|
if failedPodsArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(failedPodsArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(failedPodsArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(failedPodsArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(failedPodsArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
||||||
@@ -126,7 +126,7 @@ func validateCanEvict(pod *v1.Pod, failedPodArgs *RemoveFailedPodsArgs) error {
|
|||||||
if len(failedPodArgs.ExcludeOwnerKinds) > 0 {
|
if len(failedPodArgs.ExcludeOwnerKinds) > 0 {
|
||||||
ownerRefList := podutil.OwnerRef(pod)
|
ownerRefList := podutil.OwnerRef(pod)
|
||||||
for _, owner := range ownerRefList {
|
for _, owner := range ownerRefList {
|
||||||
if sets.NewString(failedPodArgs.ExcludeOwnerKinds...).Has(owner.Kind) {
|
if sets.New(failedPodArgs.ExcludeOwnerKinds...).Has(owner.Kind) {
|
||||||
errs = append(errs, fmt.Errorf("pod's owner kind of %s is excluded", owner.Kind))
|
errs = append(errs, fmt.Errorf("pod's owner kind of %s is excluded", owner.Kind))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ func validateCanEvict(pod *v1.Pod, failedPodArgs *RemoveFailedPodsArgs) error {
|
|||||||
reasons = append(reasons, getFailedContainerStatusReasons(pod.Status.InitContainerStatuses)...)
|
reasons = append(reasons, getFailedContainerStatusReasons(pod.Status.InitContainerStatuses)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !sets.NewString(failedPodArgs.Reasons...).HasAny(reasons...) {
|
if !sets.New(failedPodArgs.Reasons...).HasAny(reasons...) {
|
||||||
errs = append(errs, fmt.Errorf("pod does not match any of the reasons"))
|
errs = append(errs, fmt.Errorf("pod does not match any of the reasons"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type RemovePodsHavingTooManyRestartsArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type RemovePodsHavingTooManyRestartsArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if tooManyRestartsArgs.Namespaces != nil {
|
if tooManyRestartsArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(tooManyRestartsArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(tooManyRestartsArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(tooManyRestartsArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(tooManyRestartsArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type RemovePodsViolatingInterPodAntiAffinityArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type RemovePodsViolatingInterPodAntiAffinityArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if interPodAntiAffinityArgs.Namespaces != nil {
|
if interPodAntiAffinityArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(interPodAntiAffinityArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(interPodAntiAffinityArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(interPodAntiAffinityArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(interPodAntiAffinityArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
podFilter, err := podutil.NewOptions().
|
podFilter, err := podutil.NewOptions().
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type RemovePodsViolatingNodeAffinityArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type RemovePodsViolatingNodeAffinityArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if nodeAffinityArgs.Namespaces != nil {
|
if nodeAffinityArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(nodeAffinityArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(nodeAffinityArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(nodeAffinityArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(nodeAffinityArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
||||||
|
|||||||
@@ -50,10 +50,10 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("want args to be of type RemovePodsViolatingNodeTaintsArgs, got %T", args)
|
return nil, fmt.Errorf("want args to be of type RemovePodsViolatingNodeTaintsArgs, got %T", args)
|
||||||
}
|
}
|
||||||
|
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if nodeTaintsArgs.Namespaces != nil {
|
if nodeTaintsArgs.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(nodeTaintsArgs.Namespaces.Include...)
|
includedNamespaces = sets.New(nodeTaintsArgs.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(nodeTaintsArgs.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(nodeTaintsArgs.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
// We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter
|
||||||
@@ -67,7 +67,7 @@ func New(args runtime.Object, handle frameworktypes.Handle) (frameworktypes.Plug
|
|||||||
return nil, fmt.Errorf("error initializing pod filter function: %v", err)
|
return nil, fmt.Errorf("error initializing pod filter function: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
excludedTaints := sets.NewString(nodeTaintsArgs.ExcludedTaints...)
|
excludedTaints := sets.New(nodeTaintsArgs.ExcludedTaints...)
|
||||||
excludeTaint := func(taint *v1.Taint) bool {
|
excludeTaint := func(taint *v1.Taint) bool {
|
||||||
// Exclude taints by key *or* key=value
|
// Exclude taints by key *or* key=value
|
||||||
return excludedTaints.Has(taint.Key) || (taint.Value != "" && excludedTaints.Has(fmt.Sprintf("%s=%s", taint.Key, taint.Value)))
|
return excludedTaints.Has(taint.Key) || (taint.Value != "" && excludedTaints.Has(fmt.Sprintf("%s=%s", taint.Key, taint.Value)))
|
||||||
|
|||||||
@@ -113,10 +113,10 @@ func (d *RemovePodsViolatingTopologySpreadConstraint) Balance(ctx context.Contex
|
|||||||
}
|
}
|
||||||
klog.V(1).InfoS("Processing namespaces for topology spread constraints")
|
klog.V(1).InfoS("Processing namespaces for topology spread constraints")
|
||||||
podsForEviction := make(map[*v1.Pod]struct{})
|
podsForEviction := make(map[*v1.Pod]struct{})
|
||||||
var includedNamespaces, excludedNamespaces sets.String
|
var includedNamespaces, excludedNamespaces sets.Set[string]
|
||||||
if d.args.Namespaces != nil {
|
if d.args.Namespaces != nil {
|
||||||
includedNamespaces = sets.NewString(d.args.Namespaces.Include...)
|
includedNamespaces = sets.New(d.args.Namespaces.Include...)
|
||||||
excludedNamespaces = sets.NewString(d.args.Namespaces.Exclude...)
|
excludedNamespaces = sets.New(d.args.Namespaces.Exclude...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. for each namespace...
|
// 1. for each namespace...
|
||||||
|
|||||||
@@ -1215,12 +1215,12 @@ func TestTopologySpreadConstraint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tc.expectedEvictedPods != nil {
|
if tc.expectedEvictedPods != nil {
|
||||||
diff := sets.NewString(tc.expectedEvictedPods...).Difference(sets.NewString(evictedPods...))
|
diff := sets.New(tc.expectedEvictedPods...).Difference(sets.New(evictedPods...))
|
||||||
if diff.Len() > 0 {
|
if diff.Len() > 0 {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"Expected pods %v to be evicted but %v were not evicted. Actual pods evicted: %v",
|
"Expected pods %v to be evicted but %v were not evicted. Actual pods evicted: %v",
|
||||||
tc.expectedEvictedPods,
|
tc.expectedEvictedPods,
|
||||||
diff.List(),
|
diff.UnsortedList(),
|
||||||
evictedPods,
|
evictedPods,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,10 +113,10 @@ type profileImpl struct {
|
|||||||
preEvictionFilterPlugins []preEvictionFilterPlugin
|
preEvictionFilterPlugins []preEvictionFilterPlugin
|
||||||
|
|
||||||
// Each extension point with a list of plugins implementing the extension point.
|
// Each extension point with a list of plugins implementing the extension point.
|
||||||
deschedule sets.String
|
deschedule sets.Set[string]
|
||||||
balance sets.String
|
balance sets.Set[string]
|
||||||
filter sets.String
|
filter sets.Set[string]
|
||||||
preEvictionFilter sets.String
|
preEvictionFilter sets.Set[string]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option for the handleImpl.
|
// Option for the handleImpl.
|
||||||
@@ -184,10 +184,10 @@ func buildPlugin(config api.DeschedulerProfile, pluginName string, handle *handl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *profileImpl) registryToExtensionPoints(registry pluginregistry.Registry) {
|
func (p *profileImpl) registryToExtensionPoints(registry pluginregistry.Registry) {
|
||||||
p.deschedule = sets.NewString()
|
p.deschedule = sets.New[string]()
|
||||||
p.balance = sets.NewString()
|
p.balance = sets.New[string]()
|
||||||
p.filter = sets.NewString()
|
p.filter = sets.New[string]()
|
||||||
p.preEvictionFilter = sets.NewString()
|
p.preEvictionFilter = sets.New[string]()
|
||||||
|
|
||||||
for plugin, pluginUtilities := range registry {
|
for plugin, pluginUtilities := range registry {
|
||||||
if _, ok := pluginUtilities.PluginType.(frameworktypes.DeschedulePlugin); ok {
|
if _, ok := pluginUtilities.PluginType.(frameworktypes.DeschedulePlugin); ok {
|
||||||
@@ -232,16 +232,16 @@ func NewProfile(config api.DeschedulerProfile, reg pluginregistry.Registry, opts
|
|||||||
pi.registryToExtensionPoints(reg)
|
pi.registryToExtensionPoints(reg)
|
||||||
|
|
||||||
if !pi.deschedule.HasAll(config.Plugins.Deschedule.Enabled...) {
|
if !pi.deschedule.HasAll(config.Plugins.Deschedule.Enabled...) {
|
||||||
return nil, fmt.Errorf("profile %q configures deschedule extension point of non-existing plugins: %v", config.Name, sets.NewString(config.Plugins.Deschedule.Enabled...).Difference(pi.deschedule))
|
return nil, fmt.Errorf("profile %q configures deschedule extension point of non-existing plugins: %v", config.Name, sets.New(config.Plugins.Deschedule.Enabled...).Difference(pi.deschedule))
|
||||||
}
|
}
|
||||||
if !pi.balance.HasAll(config.Plugins.Balance.Enabled...) {
|
if !pi.balance.HasAll(config.Plugins.Balance.Enabled...) {
|
||||||
return nil, fmt.Errorf("profile %q configures balance extension point of non-existing plugins: %v", config.Name, sets.NewString(config.Plugins.Balance.Enabled...).Difference(pi.balance))
|
return nil, fmt.Errorf("profile %q configures balance extension point of non-existing plugins: %v", config.Name, sets.New(config.Plugins.Balance.Enabled...).Difference(pi.balance))
|
||||||
}
|
}
|
||||||
if !pi.filter.HasAll(config.Plugins.Filter.Enabled...) {
|
if !pi.filter.HasAll(config.Plugins.Filter.Enabled...) {
|
||||||
return nil, fmt.Errorf("profile %q configures filter extension point of non-existing plugins: %v", config.Name, sets.NewString(config.Plugins.Filter.Enabled...).Difference(pi.filter))
|
return nil, fmt.Errorf("profile %q configures filter extension point of non-existing plugins: %v", config.Name, sets.New(config.Plugins.Filter.Enabled...).Difference(pi.filter))
|
||||||
}
|
}
|
||||||
if !pi.preEvictionFilter.HasAll(config.Plugins.PreEvictionFilter.Enabled...) {
|
if !pi.preEvictionFilter.HasAll(config.Plugins.PreEvictionFilter.Enabled...) {
|
||||||
return nil, fmt.Errorf("profile %q configures preEvictionFilter extension point of non-existing plugins: %v", config.Name, sets.NewString(config.Plugins.PreEvictionFilter.Enabled...).Difference(pi.preEvictionFilter))
|
return nil, fmt.Errorf("profile %q configures preEvictionFilter extension point of non-existing plugins: %v", config.Name, sets.New(config.Plugins.PreEvictionFilter.Enabled...).Difference(pi.preEvictionFilter))
|
||||||
}
|
}
|
||||||
|
|
||||||
handle := &handleImpl{
|
handle := &handleImpl{
|
||||||
@@ -258,7 +258,7 @@ func NewProfile(config api.DeschedulerProfile, reg pluginregistry.Registry, opts
|
|||||||
pluginNames = append(pluginNames, config.Plugins.PreEvictionFilter.Enabled...)
|
pluginNames = append(pluginNames, config.Plugins.PreEvictionFilter.Enabled...)
|
||||||
|
|
||||||
plugins := make(map[string]frameworktypes.Plugin)
|
plugins := make(map[string]frameworktypes.Plugin)
|
||||||
for _, plugin := range sets.NewString(pluginNames...).List() {
|
for _, plugin := range sets.New(pluginNames...).UnsortedList() {
|
||||||
pg, err := buildPlugin(config, plugin, handle, reg)
|
pg, err := buildPlugin(config, plugin, handle, reg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("unable to build %v plugin: %v", plugin, err)
|
return nil, fmt.Errorf("unable to build %v plugin: %v", plugin, err)
|
||||||
|
|||||||
@@ -444,19 +444,19 @@ func TestProfileExtensionPoints(t *testing.T) {
|
|||||||
|
|
||||||
// Validate the extension points of all registered plugins are properly detected
|
// Validate the extension points of all registered plugins are properly detected
|
||||||
|
|
||||||
diff := cmp.Diff(sets.NewString("DeschedulePlugin_0", "DeschedulePlugin_1", "DeschedulePlugin_2", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2"), prfl.deschedule)
|
diff := cmp.Diff(sets.New("DeschedulePlugin_0", "DeschedulePlugin_1", "DeschedulePlugin_2", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2"), prfl.deschedule)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for deschedule failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for deschedule failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
diff = cmp.Diff(sets.NewString("BalancePlugin_0", "BalancePlugin_1", "BalancePlugin_2", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2"), prfl.balance)
|
diff = cmp.Diff(sets.New("BalancePlugin_0", "BalancePlugin_1", "BalancePlugin_2", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2"), prfl.balance)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for balance failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for balance failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
diff = cmp.Diff(sets.NewString("DefaultEvictor", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2", "FilterPlugin_0", "FilterPlugin_1", "FilterPlugin_2"), prfl.filter)
|
diff = cmp.Diff(sets.New("DefaultEvictor", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2", "FilterPlugin_0", "FilterPlugin_1", "FilterPlugin_2"), prfl.filter)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for filter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for filter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
diff = cmp.Diff(sets.NewString("DefaultEvictor", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2", "FilterPlugin_0", "FilterPlugin_1", "FilterPlugin_2"), prfl.preEvictionFilter)
|
diff = cmp.Diff(sets.New("DefaultEvictor", "FakePlugin_0", "FakePlugin_1", "FakePlugin_2", "FilterPlugin_0", "FilterPlugin_1", "FilterPlugin_2"), prfl.preEvictionFilter)
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for preEvictionFilter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for preEvictionFilter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
@@ -467,7 +467,7 @@ func TestProfileExtensionPoints(t *testing.T) {
|
|||||||
names = append(names, pl.Name())
|
names = append(names, pl.Name())
|
||||||
}
|
}
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
diff = cmp.Diff(sets.NewString("FakePlugin_0"), sets.NewString(names...))
|
diff = cmp.Diff(sets.New("FakePlugin_0"), sets.New(names...))
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for deschedule failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for deschedule failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
@@ -478,7 +478,7 @@ func TestProfileExtensionPoints(t *testing.T) {
|
|||||||
names = append(names, pl.Name())
|
names = append(names, pl.Name())
|
||||||
}
|
}
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
diff = cmp.Diff(sets.NewString(), sets.NewString(names...))
|
diff = cmp.Diff(sets.New[string](), sets.New(names...))
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for balance failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for balance failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ func TestProfileExtensionPoints(t *testing.T) {
|
|||||||
names = append(names, pl.Name())
|
names = append(names, pl.Name())
|
||||||
}
|
}
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
diff = cmp.Diff(sets.NewString("DefaultEvictor", "FilterPlugin_0", "FilterPlugin_1"), sets.NewString(names...))
|
diff = cmp.Diff(sets.New("DefaultEvictor", "FilterPlugin_0", "FilterPlugin_1"), sets.New(names...))
|
||||||
if diff != "" {
|
if diff != "" {
|
||||||
t.Errorf("check for filter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
t.Errorf("check for filter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ const SystemCriticalPriority = 2 * int32(1000000000)
|
|||||||
// GetNamespacesFromPodAffinityTerm returns a set of names
|
// GetNamespacesFromPodAffinityTerm returns a set of names
|
||||||
// according to the namespaces indicated in podAffinityTerm.
|
// according to the namespaces indicated in podAffinityTerm.
|
||||||
// If namespaces is empty it considers the given pod's namespace.
|
// If namespaces is empty it considers the given pod's namespace.
|
||||||
func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffinityTerm) sets.String {
|
func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffinityTerm) sets.Set[string] {
|
||||||
names := sets.String{}
|
names := sets.New[string]()
|
||||||
if len(podAffinityTerm.Namespaces) == 0 {
|
if len(podAffinityTerm.Namespaces) == 0 {
|
||||||
names.Insert(pod.Namespace)
|
names.Insert(pod.Namespace)
|
||||||
} else {
|
} else {
|
||||||
@@ -29,7 +29,7 @@ func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffini
|
|||||||
|
|
||||||
// PodMatchesTermsNamespaceAndSelector returns true if the given <pod>
|
// PodMatchesTermsNamespaceAndSelector returns true if the given <pod>
|
||||||
// matches the namespace and selector defined by <affinityPod>`s <term>.
|
// matches the namespace and selector defined by <affinityPod>`s <term>.
|
||||||
func PodMatchesTermsNamespaceAndSelector(pod *v1.Pod, namespaces sets.String, selector labels.Selector) bool {
|
func PodMatchesTermsNamespaceAndSelector(pod *v1.Pod, namespaces sets.Set[string], selector labels.Selector) bool {
|
||||||
if !namespaces.Has(pod.Namespace) {
|
if !namespaces.Has(pod.Namespace) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
)
|
)
|
||||||
|
|
||||||
var supportedQoSComputeResources = sets.NewString(string(v1.ResourceCPU), string(v1.ResourceMemory))
|
var supportedQoSComputeResources = sets.New(string(v1.ResourceCPU), string(v1.ResourceMemory))
|
||||||
|
|
||||||
// QOSList is a set of (resource name, QoS class) pairs.
|
// QOSList is a set of (resource name, QoS class) pairs.
|
||||||
type QOSList map[v1.ResourceName]v1.PodQOSClass
|
type QOSList map[v1.ResourceName]v1.PodQOSClass
|
||||||
@@ -44,7 +44,7 @@ func GetPodQOS(pod *v1.Pod) v1.PodQOSClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// process limits
|
// process limits
|
||||||
qosLimitsFound := sets.NewString()
|
qosLimitsFound := sets.New[string]()
|
||||||
for name, quantity := range container.Resources.Limits {
|
for name, quantity := range container.Resources.Limits {
|
||||||
if !isSupportedQoSComputeResource(name) {
|
if !isSupportedQoSComputeResource(name) {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user