Improve the naming of the stale-conntrack-entry-tracking fields
The APIs talked about "stale services" and "stale endpoints", but the thing that is actually "stale" is the conntrack entries, not the services/endpoints. Fix the names to indicate what they actual keep track of. Also, all three fields (2 in the endpoints update object and 1 in the service update object) are currently UDP-specific, but only the service one made that clear. Fix that too.
This commit is contained in:
@@ -337,15 +337,16 @@ func (sct *ServiceChangeTracker) PendingChanges() sets.String {
|
||||
|
||||
// UpdateServiceMapResult is the updated results after applying service changes.
|
||||
type UpdateServiceMapResult struct {
|
||||
// UDPStaleClusterIP holds stale (no longer assigned to a Service) Service IPs that had UDP ports.
|
||||
// Callers can use this to abort timeout-waits or clear connection-tracking information.
|
||||
UDPStaleClusterIP sets.String
|
||||
// DeletedUDPClusterIPs holds stale (no longer assigned to a Service) Service IPs
|
||||
// that had UDP ports. Callers can use this to abort timeout-waits or clear
|
||||
// connection-tracking information.
|
||||
DeletedUDPClusterIPs sets.String
|
||||
}
|
||||
|
||||
// Update updates ServicePortMap base on the given changes.
|
||||
func (sm ServicePortMap) Update(changes *ServiceChangeTracker) (result UpdateServiceMapResult) {
|
||||
result.UDPStaleClusterIP = sets.NewString()
|
||||
sm.apply(changes, result.UDPStaleClusterIP)
|
||||
result.DeletedUDPClusterIPs = sets.NewString()
|
||||
sm.apply(changes, result.DeletedUDPClusterIPs)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -398,10 +399,9 @@ func (sct *ServiceChangeTracker) serviceToServiceMap(service *v1.Service) Servic
|
||||
return svcPortMap
|
||||
}
|
||||
|
||||
// apply the changes to ServicePortMap and update the stale udp cluster IP set. The UDPStaleClusterIP argument is passed in to store the
|
||||
// udp protocol service cluster ip when service is deleted from the ServicePortMap.
|
||||
// apply the changes to ServicePortMap and update the deleted UDP cluster IP set.
|
||||
// apply triggers processServiceMapChange on every change.
|
||||
func (sm *ServicePortMap) apply(changes *ServiceChangeTracker, UDPStaleClusterIP sets.String) {
|
||||
func (sm *ServicePortMap) apply(changes *ServiceChangeTracker, deletedUDPClusterIPs sets.String) {
|
||||
changes.lock.Lock()
|
||||
defer changes.lock.Unlock()
|
||||
for _, change := range changes.items {
|
||||
@@ -412,7 +412,7 @@ func (sm *ServicePortMap) apply(changes *ServiceChangeTracker, UDPStaleClusterIP
|
||||
// filter out the Update event of current changes from previous changes before calling unmerge() so that can
|
||||
// skip deleting the Update events.
|
||||
change.previous.filter(change.current)
|
||||
sm.unmerge(change.previous, UDPStaleClusterIP)
|
||||
sm.unmerge(change.previous, deletedUDPClusterIPs)
|
||||
}
|
||||
// clear changes after applying them to ServicePortMap.
|
||||
changes.items = make(map[types.NamespacedName]*serviceChange)
|
||||
@@ -467,15 +467,15 @@ func (sm *ServicePortMap) filter(other ServicePortMap) {
|
||||
}
|
||||
}
|
||||
|
||||
// unmerge deletes all other ServicePortMap's elements from current ServicePortMap. We pass in the UDPStaleClusterIP strings sets
|
||||
// for storing the stale udp service cluster IPs. We will clear stale udp connection base on UDPStaleClusterIP later
|
||||
func (sm *ServicePortMap) unmerge(other ServicePortMap, UDPStaleClusterIP sets.String) {
|
||||
// unmerge deletes all other ServicePortMap's elements from current ServicePortMap and
|
||||
// updates deletedUDPClusterIPs with all of the newly-deleted UDP cluster IPs.
|
||||
func (sm *ServicePortMap) unmerge(other ServicePortMap, deletedUDPClusterIPs sets.String) {
|
||||
for svcPortName := range other {
|
||||
info, exists := (*sm)[svcPortName]
|
||||
if exists {
|
||||
klog.V(4).InfoS("Removing service port", "portName", svcPortName)
|
||||
if info.Protocol() == v1.ProtocolUDP {
|
||||
UDPStaleClusterIP.Insert(info.ClusterIP().String())
|
||||
deletedUDPClusterIPs.Insert(info.ClusterIP().String())
|
||||
}
|
||||
delete(*sm, svcPortName)
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user