pkg/proxy: using generic sets

pkg/proxy: using generic sets

Signed-off-by: Daman <aroradaman@gmail.com>
This commit is contained in:
Daman
2023-04-15 22:59:21 +05:30
parent 940101e07e
commit c2c8b8d178
17 changed files with 244 additions and 244 deletions

View File

@@ -33,7 +33,7 @@ import (
utilproxy "k8s.io/kubernetes/pkg/proxy/util"
)
var supportedEndpointSliceAddressTypes = sets.NewString(
var supportedEndpointSliceAddressTypes = sets.New[string](
string(discovery.AddressTypeIPv4),
string(discovery.AddressTypeIPv6),
)
@@ -49,7 +49,7 @@ type BaseEndpointInfo struct {
// ZoneHints represent the zone hints for the endpoint. This is based on
// endpoint.hints.forZones[*].name in the EndpointSlice API.
ZoneHints sets.String
ZoneHints sets.Set[string]
// Ready indicates whether this endpoint is ready and NOT terminating.
// For pods, this is true if a pod has a ready status and a nil deletion timestamp.
// This is only set when watching EndpointSlices. If using Endpoints, this is always
@@ -103,7 +103,7 @@ func (info *BaseEndpointInfo) IsTerminating() bool {
}
// GetZoneHints returns the zone hint for the endpoint.
func (info *BaseEndpointInfo) GetZoneHints() sets.String {
func (info *BaseEndpointInfo) GetZoneHints() sets.Set[string] {
return info.ZoneHints
}
@@ -135,7 +135,7 @@ func (info *BaseEndpointInfo) GetZone() string {
}
func newBaseEndpointInfo(IP, nodeName, zone string, port int, isLocal bool,
ready, serving, terminating bool, zoneHints sets.String) *BaseEndpointInfo {
ready, serving, terminating bool, zoneHints sets.Set[string]) *BaseEndpointInfo {
return &BaseEndpointInfo{
Endpoint: net.JoinHostPort(IP, strconv.Itoa(port)),
IsLocal: isLocal,
@@ -232,7 +232,7 @@ func (ect *EndpointChangeTracker) EndpointSliceUpdate(endpointSlice *discovery.E
// PendingChanges returns a set whose keys are the names of the services whose endpoints
// have changed since the last time ect was used to update an EndpointsMap. (You must call
// this _before_ calling em.Update(ect).)
func (ect *EndpointChangeTracker) PendingChanges() sets.String {
func (ect *EndpointChangeTracker) PendingChanges() sets.Set[string] {
return ect.endpointSliceCache.pendingChanges()
}
@@ -361,8 +361,8 @@ func (em EndpointsMap) unmerge(other EndpointsMap) {
}
// getLocalEndpointIPs returns endpoints IPs if given endpoint is local - local means the endpoint is running in same host as kube-proxy.
func (em EndpointsMap) getLocalReadyEndpointIPs() map[types.NamespacedName]sets.String {
localIPs := make(map[types.NamespacedName]sets.String)
func (em EndpointsMap) getLocalReadyEndpointIPs() map[types.NamespacedName]sets.Set[string] {
localIPs := make(map[types.NamespacedName]sets.Set[string])
for svcPortName, epList := range em {
for _, ep := range epList {
// Only add ready endpoints for health checking. Terminating endpoints may still serve traffic
@@ -374,7 +374,7 @@ func (em EndpointsMap) getLocalReadyEndpointIPs() map[types.NamespacedName]sets.
if ep.GetIsLocal() {
nsn := svcPortName.NamespacedName
if localIPs[nsn] == nil {
localIPs[nsn] = sets.NewString()
localIPs[nsn] = sets.New[string]()
}
localIPs[nsn].Insert(ep.IP())
}