mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
Remove pkg/utils/slice from kube-proxy
This commit is contained in:
parent
9d38c64a7d
commit
25453708ea
@ -20,7 +20,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/proxy"
|
"k8s.io/kubernetes/pkg/proxy"
|
||||||
"k8s.io/kubernetes/pkg/proxy/util"
|
"k8s.io/kubernetes/pkg/proxy/util"
|
||||||
"k8s.io/kubernetes/pkg/util/slice"
|
stringslices "k8s.io/utils/strings/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -263,7 +263,7 @@ func (lb *LoadBalancerRR) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoint
|
|||||||
curEndpoints = state.endpoints
|
curEndpoints = state.endpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists || state == nil || len(curEndpoints) != len(newEndpoints) || !slicesEquiv(slice.CopyStrings(curEndpoints), newEndpoints) {
|
if !exists || state == nil || len(curEndpoints) != len(newEndpoints) || !slicesEquiv(stringslices.Clone(curEndpoints), newEndpoints) {
|
||||||
klog.V(1).Infof("LoadBalancerRR: Setting endpoints for %s to %+v", svcPort, newEndpoints)
|
klog.V(1).Infof("LoadBalancerRR: Setting endpoints for %s to %+v", svcPort, newEndpoints)
|
||||||
lb.removeStaleAffinity(svcPort, newEndpoints)
|
lb.removeStaleAffinity(svcPort, newEndpoints)
|
||||||
// OnEndpointsUpdate can be called without NewService being called externally.
|
// OnEndpointsUpdate can be called without NewService being called externally.
|
||||||
@ -320,10 +320,9 @@ func slicesEquiv(lhs, rhs []string) bool {
|
|||||||
if len(lhs) != len(rhs) {
|
if len(lhs) != len(rhs) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if reflect.DeepEqual(slice.SortStrings(lhs), slice.SortStrings(rhs)) {
|
sort.Strings(lhs)
|
||||||
return true
|
sort.Strings(rhs)
|
||||||
}
|
return stringslices.Equal(lhs, rhs)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName) {
|
func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName) {
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"reflect"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
"k8s.io/kubernetes/pkg/proxy"
|
"k8s.io/kubernetes/pkg/proxy"
|
||||||
"k8s.io/kubernetes/pkg/proxy/util"
|
"k8s.io/kubernetes/pkg/proxy/util"
|
||||||
"k8s.io/kubernetes/pkg/util/slice"
|
stringslices "k8s.io/utils/strings/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -256,7 +256,7 @@ func (lb *LoadBalancerRR) OnEndpointsUpdate(oldEndpoints, endpoints *v1.Endpoint
|
|||||||
curEndpoints = state.endpoints
|
curEndpoints = state.endpoints
|
||||||
}
|
}
|
||||||
|
|
||||||
if !exists || state == nil || len(curEndpoints) != len(newEndpoints) || !slicesEquiv(slice.CopyStrings(curEndpoints), newEndpoints) {
|
if !exists || state == nil || len(curEndpoints) != len(newEndpoints) || !slicesEquiv(stringslices.Clone(curEndpoints), newEndpoints) {
|
||||||
klog.V(1).Infof("LoadBalancerRR: Setting endpoints for %s to %+v", svcPort, newEndpoints)
|
klog.V(1).Infof("LoadBalancerRR: Setting endpoints for %s to %+v", svcPort, newEndpoints)
|
||||||
lb.updateAffinityMap(svcPort, newEndpoints)
|
lb.updateAffinityMap(svcPort, newEndpoints)
|
||||||
// OnEndpointsUpdate can be called without NewService being called externally.
|
// OnEndpointsUpdate can be called without NewService being called externally.
|
||||||
@ -311,10 +311,9 @@ func slicesEquiv(lhs, rhs []string) bool {
|
|||||||
if len(lhs) != len(rhs) {
|
if len(lhs) != len(rhs) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if reflect.DeepEqual(slice.SortStrings(lhs), slice.SortStrings(rhs)) {
|
sort.Strings(lhs)
|
||||||
return true
|
sort.Strings(rhs)
|
||||||
}
|
return stringslices.Equal(lhs, rhs)
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName) {
|
func (lb *LoadBalancerRR) CleanupStaleStickySessions(svcPort proxy.ServicePortName) {
|
||||||
|
Loading…
Reference in New Issue
Block a user