From 359b38a34c82c1a04fa18a88c02640d290cc542f Mon Sep 17 00:00:00 2001 From: Amir Alavi Date: Thu, 11 May 2023 22:35:44 -0400 Subject: [PATCH] update deprecated sets.String to generic sets --- pkg/descheduler/pod/pods.go | 8 +++--- .../nodeutilization/nodeutilization.go | 4 +-- .../plugins/podlifetime/pod_lifetime.go | 8 +++--- .../plugins/podlifetime/validation.go | 4 +-- .../removeduplicates/removeduplicates.go | 8 +++--- .../plugins/removefailedpods/failedpods.go | 10 +++---- .../toomanyrestarts.go | 6 ++--- .../pod_antiaffinity.go | 6 ++--- .../node_affinity.go | 6 ++--- .../node_taint.go | 8 +++--- .../topologyspreadconstraint.go | 6 ++--- .../topologyspreadconstraint_test.go | 4 +-- pkg/framework/profile/profile.go | 26 +++++++++---------- pkg/framework/profile/profile_test.go | 14 +++++----- pkg/utils/priority.go | 6 ++--- pkg/utils/qos.go | 4 +-- 16 files changed, 64 insertions(+), 64 deletions(-) diff --git a/pkg/descheduler/pod/pods.go b/pkg/descheduler/pod/pods.go index 4f0011684..98a0051b9 100644 --- a/pkg/descheduler/pod/pods.go +++ b/pkg/descheduler/pod/pods.go @@ -53,8 +53,8 @@ func WrapFilterFuncs(filters ...FilterFunc) FilterFunc { type Options struct { filter FilterFunc - includedNamespaces sets.String - excludedNamespaces sets.String + includedNamespaces sets.Set[string] + excludedNamespaces sets.Set[string] labelSelector *metav1.LabelSelector } @@ -71,13 +71,13 @@ func (o *Options) WithFilter(filter FilterFunc) *Options { } // WithNamespaces sets included namespaces -func (o *Options) WithNamespaces(namespaces sets.String) *Options { +func (o *Options) WithNamespaces(namespaces sets.Set[string]) *Options { o.includedNamespaces = namespaces return o } // WithoutNamespaces sets excluded namespaces -func (o *Options) WithoutNamespaces(namespaces sets.String) *Options { +func (o *Options) WithoutNamespaces(namespaces sets.Set[string]) *Options { o.excludedNamespaces = namespaces return o } diff --git a/pkg/framework/plugins/nodeutilization/nodeutilization.go b/pkg/framework/plugins/nodeutilization/nodeutilization.go index 5e5355fcc..d1fe8daf6 100644 --- a/pkg/framework/plugins/nodeutilization/nodeutilization.go +++ b/pkg/framework/plugins/nodeutilization/nodeutilization.go @@ -282,9 +282,9 @@ func evictPods( podEvictor frameworktypes.Evictor, continueEviction continueEvictionCond, ) { - var excludedNamespaces sets.String + var excludedNamespaces sets.Set[string] if evictableNamespaces != nil { - excludedNamespaces = sets.NewString(evictableNamespaces.Exclude...) + excludedNamespaces = sets.New(evictableNamespaces.Exclude...) } if continueEviction(nodeInfo, totalAvailableUsage) { diff --git a/pkg/framework/plugins/podlifetime/pod_lifetime.go b/pkg/framework/plugins/podlifetime/pod_lifetime.go index d386a7849..b6e327789 100644 --- a/pkg/framework/plugins/podlifetime/pod_lifetime.go +++ b/pkg/framework/plugins/podlifetime/pod_lifetime.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if podLifeTimeArgs.Namespaces != nil { - includedNamespaces = sets.NewString(podLifeTimeArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(podLifeTimeArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(podLifeTimeArgs.Namespaces.Include...) + excludedNamespaces = sets.New(podLifeTimeArgs.Namespaces.Exclude...) } // 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 { - states := sets.NewString(podLifeTimeArgs.States...) + states := sets.New(podLifeTimeArgs.States...) podFilter = podutil.WrapFilterFuncs(podFilter, func(pod *v1.Pod) bool { if states.Has(string(pod.Status.Phase)) { return true diff --git a/pkg/framework/plugins/podlifetime/validation.go b/pkg/framework/plugins/podlifetime/validation.go index 144120beb..973dceb6a 100644 --- a/pkg/framework/plugins/podlifetime/validation.go +++ b/pkg/framework/plugins/podlifetime/validation.go @@ -43,7 +43,7 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error { 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.PodPending), @@ -53,7 +53,7 @@ func ValidatePodLifeTimeArgs(obj runtime.Object) error { ) 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 diff --git a/pkg/framework/plugins/removeduplicates/removeduplicates.go b/pkg/framework/plugins/removeduplicates/removeduplicates.go index a3910c385..4e310c3bf 100644 --- a/pkg/framework/plugins/removeduplicates/removeduplicates.go +++ b/pkg/framework/plugins/removeduplicates/removeduplicates.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if removeDuplicatesArgs.Namespaces != nil { - includedNamespaces = sets.NewString(removeDuplicatesArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(removeDuplicatesArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(removeDuplicatesArgs.Namespaces.Include...) + excludedNamespaces = sets.New(removeDuplicatesArgs.Namespaces.Exclude...) } // 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 } - exclude := sets.NewString(excludeOwnerKinds...) + exclude := sets.New(excludeOwnerKinds...) for _, owner := range ownerRefs { if exclude.Has(owner.Kind) { return true diff --git a/pkg/framework/plugins/removefailedpods/failedpods.go b/pkg/framework/plugins/removefailedpods/failedpods.go index 10bcec71d..f77d0b629 100644 --- a/pkg/framework/plugins/removefailedpods/failedpods.go +++ b/pkg/framework/plugins/removefailedpods/failedpods.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if failedPodsArgs.Namespaces != nil { - includedNamespaces = sets.NewString(failedPodsArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(failedPodsArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(failedPodsArgs.Namespaces.Include...) + excludedNamespaces = sets.New(failedPodsArgs.Namespaces.Exclude...) } // 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 { ownerRefList := podutil.OwnerRef(pod) 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)) } } @@ -143,7 +143,7 @@ func validateCanEvict(pod *v1.Pod, failedPodArgs *RemoveFailedPodsArgs) error { 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")) } } diff --git a/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go b/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go index 86efd35b3..4d4299867 100644 --- a/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go +++ b/pkg/framework/plugins/removepodshavingtoomanyrestarts/toomanyrestarts.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if tooManyRestartsArgs.Namespaces != nil { - includedNamespaces = sets.NewString(tooManyRestartsArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(tooManyRestartsArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(tooManyRestartsArgs.Namespaces.Include...) + excludedNamespaces = sets.New(tooManyRestartsArgs.Namespaces.Exclude...) } // We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter diff --git a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go index 8a6ee73f9..85d1738f8 100644 --- a/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go +++ b/pkg/framework/plugins/removepodsviolatinginterpodantiaffinity/pod_antiaffinity.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if interPodAntiAffinityArgs.Namespaces != nil { - includedNamespaces = sets.NewString(interPodAntiAffinityArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(interPodAntiAffinityArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(interPodAntiAffinityArgs.Namespaces.Include...) + excludedNamespaces = sets.New(interPodAntiAffinityArgs.Namespaces.Exclude...) } podFilter, err := podutil.NewOptions(). diff --git a/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go b/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go index a97ad67fe..e6f820b71 100644 --- a/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go +++ b/pkg/framework/plugins/removepodsviolatingnodeaffinity/node_affinity.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if nodeAffinityArgs.Namespaces != nil { - includedNamespaces = sets.NewString(nodeAffinityArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(nodeAffinityArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(nodeAffinityArgs.Namespaces.Include...) + excludedNamespaces = sets.New(nodeAffinityArgs.Namespaces.Exclude...) } // We can combine Filter and PreEvictionFilter since for this strategy it does not matter where we run PreEvictionFilter diff --git a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go index 766f63cb4..8bbc929bc 100644 --- a/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go +++ b/pkg/framework/plugins/removepodsviolatingnodetaints/node_taint.go @@ -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) } - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if nodeTaintsArgs.Namespaces != nil { - includedNamespaces = sets.NewString(nodeTaintsArgs.Namespaces.Include...) - excludedNamespaces = sets.NewString(nodeTaintsArgs.Namespaces.Exclude...) + includedNamespaces = sets.New(nodeTaintsArgs.Namespaces.Include...) + excludedNamespaces = sets.New(nodeTaintsArgs.Namespaces.Exclude...) } // 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) } - excludedTaints := sets.NewString(nodeTaintsArgs.ExcludedTaints...) + excludedTaints := sets.New(nodeTaintsArgs.ExcludedTaints...) excludeTaint := func(taint *v1.Taint) bool { // Exclude taints by key *or* key=value return excludedTaints.Has(taint.Key) || (taint.Value != "" && excludedTaints.Has(fmt.Sprintf("%s=%s", taint.Key, taint.Value))) diff --git a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go index 82bea175c..5cc67ce95 100644 --- a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go +++ b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go @@ -113,10 +113,10 @@ func (d *RemovePodsViolatingTopologySpreadConstraint) Balance(ctx context.Contex } klog.V(1).InfoS("Processing namespaces for topology spread constraints") podsForEviction := make(map[*v1.Pod]struct{}) - var includedNamespaces, excludedNamespaces sets.String + var includedNamespaces, excludedNamespaces sets.Set[string] if d.args.Namespaces != nil { - includedNamespaces = sets.NewString(d.args.Namespaces.Include...) - excludedNamespaces = sets.NewString(d.args.Namespaces.Exclude...) + includedNamespaces = sets.New(d.args.Namespaces.Include...) + excludedNamespaces = sets.New(d.args.Namespaces.Exclude...) } // 1. for each namespace... diff --git a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go index bab1dd1e9..2a14fd4c7 100644 --- a/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go +++ b/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint_test.go @@ -1215,12 +1215,12 @@ func TestTopologySpreadConstraint(t *testing.T) { } 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 { t.Errorf( "Expected pods %v to be evicted but %v were not evicted. Actual pods evicted: %v", tc.expectedEvictedPods, - diff.List(), + diff.UnsortedList(), evictedPods, ) } diff --git a/pkg/framework/profile/profile.go b/pkg/framework/profile/profile.go index d242c5cbe..87d5df302 100644 --- a/pkg/framework/profile/profile.go +++ b/pkg/framework/profile/profile.go @@ -113,10 +113,10 @@ type profileImpl struct { preEvictionFilterPlugins []preEvictionFilterPlugin // Each extension point with a list of plugins implementing the extension point. - deschedule sets.String - balance sets.String - filter sets.String - preEvictionFilter sets.String + deschedule sets.Set[string] + balance sets.Set[string] + filter sets.Set[string] + preEvictionFilter sets.Set[string] } // Option for the handleImpl. @@ -184,10 +184,10 @@ func buildPlugin(config api.DeschedulerProfile, pluginName string, handle *handl } func (p *profileImpl) registryToExtensionPoints(registry pluginregistry.Registry) { - p.deschedule = sets.NewString() - p.balance = sets.NewString() - p.filter = sets.NewString() - p.preEvictionFilter = sets.NewString() + p.deschedule = sets.New[string]() + p.balance = sets.New[string]() + p.filter = sets.New[string]() + p.preEvictionFilter = sets.New[string]() for plugin, pluginUtilities := range registry { if _, ok := pluginUtilities.PluginType.(frameworktypes.DeschedulePlugin); ok { @@ -232,16 +232,16 @@ func NewProfile(config api.DeschedulerProfile, reg pluginregistry.Registry, opts pi.registryToExtensionPoints(reg) 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...) { - 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...) { - 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...) { - 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{ @@ -258,7 +258,7 @@ func NewProfile(config api.DeschedulerProfile, reg pluginregistry.Registry, opts pluginNames = append(pluginNames, config.Plugins.PreEvictionFilter.Enabled...) 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) if err != nil { return nil, fmt.Errorf("unable to build %v plugin: %v", plugin, err) diff --git a/pkg/framework/profile/profile_test.go b/pkg/framework/profile/profile_test.go index f7cbb8526..21331c9b4 100644 --- a/pkg/framework/profile/profile_test.go +++ b/pkg/framework/profile/profile_test.go @@ -444,19 +444,19 @@ func TestProfileExtensionPoints(t *testing.T) { // 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 != "" { 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 != "" { 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 != "" { 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 != "" { 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()) } 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 != "" { 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()) } sort.Strings(names) - diff = cmp.Diff(sets.NewString(), sets.NewString(names...)) + diff = cmp.Diff(sets.New[string](), sets.New(names...)) if 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()) } 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 != "" { t.Errorf("check for filter failed. Results are not deep equal. mismatch (-want +got):\n%s", diff) } diff --git a/pkg/utils/priority.go b/pkg/utils/priority.go index 9010b3467..33e8e77f3 100644 --- a/pkg/utils/priority.go +++ b/pkg/utils/priority.go @@ -17,8 +17,8 @@ const SystemCriticalPriority = 2 * int32(1000000000) // GetNamespacesFromPodAffinityTerm returns a set of names // according to the namespaces indicated in podAffinityTerm. // If namespaces is empty it considers the given pod's namespace. -func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffinityTerm) sets.String { - names := sets.String{} +func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffinityTerm) sets.Set[string] { + names := sets.New[string]() if len(podAffinityTerm.Namespaces) == 0 { names.Insert(pod.Namespace) } else { @@ -29,7 +29,7 @@ func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffini // PodMatchesTermsNamespaceAndSelector returns true if the given // matches the namespace and selector defined by `s . -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) { return false } diff --git a/pkg/utils/qos.go b/pkg/utils/qos.go index 56938b528..c0aed053a 100644 --- a/pkg/utils/qos.go +++ b/pkg/utils/qos.go @@ -6,7 +6,7 @@ import ( "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. type QOSList map[v1.ResourceName]v1.PodQOSClass @@ -44,7 +44,7 @@ func GetPodQOS(pod *v1.Pod) v1.PodQOSClass { } } // process limits - qosLimitsFound := sets.NewString() + qosLimitsFound := sets.New[string]() for name, quantity := range container.Resources.Limits { if !isSupportedQoSComputeResource(name) { continue