Skip to content

Commit

Permalink
Refine comments about calling ClearConntrackEntryForService in Antrea…
Browse files Browse the repository at this point in the history
…Proxy (#6442)

Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
  • Loading branch information
hongliangl authored Jun 14, 2024
1 parent 4e49d41 commit 6e00ebf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/agent/proxy/proxier.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func (p *proxier) removeStaleServices() {
}
delete(p.endpointsInstalledMap, svcPortName)
}
// Cleanup all UDP conntrack connections related to the Service.
if p.cleanupStaleUDPSvcConntrack && needClearConntrackEntries(svcInfo.OFProtocol) {
if !p.removeStaleServiceConntrackEntries(svcPortName, svcInfo) {
continue
Expand Down Expand Up @@ -361,6 +360,8 @@ func (p *proxier) removeStaleServiceConntrackEntries(svcPortName k8sproxy.Servic
svcIPToPort[virtualNodePortDNATIP.String()] = nodePort
}

// Clean up the UDP conntrack entries matching the stale Service IPs and ports. For a UDP Service without Endpoint,
// no UDP conntrack entry will have been generated, but there is no harm in calling this function.
for svcIPStr, port := range svcIPToPort {
svcIP := net.ParseIP(svcIPStr)
if err := p.routeClient.ClearConntrackEntryForService(svcIP, port, nil, svcProto); err != nil {
Expand Down Expand Up @@ -427,7 +428,7 @@ func (p *proxier) removeStaleConntrackEntries(svcPortName k8sproxy.ServicePortNa
staleSvcIPToPort[virtualNodePortDNATIP.String()] = pNodePort
svcNodePortChanged = true
}
// Delete the conntrack entries due to the change of the Service.
// Clean up the UDP conntrack entries matching the stale Service IPs and ports.
for svcIPStr, port := range staleSvcIPToPort {
svcIP := net.ParseIP(svcIPStr)
if err := p.routeClient.ClearConntrackEntryForService(svcIP, port, nil, pSvcInfo.OFProtocol); err != nil {
Expand All @@ -453,7 +454,7 @@ func (p *proxier) removeStaleConntrackEntries(svcPortName k8sproxy.ServicePortNa
remainingSvcIPToPort[nodeIP.String()] = nodePort
}
}
// Delete the conntrack entries related to the remaining Service IPs, Service port, nodePort and stale Endpoint IPs.
// Clean up the UDP conntrack entries matching the remaining Service IPs and ports, and the stale Endpoint IPs.
for svcIPStr, port := range remainingSvcIPToPort {
for _, endpoint := range staleEndpoints {
svcIP := net.ParseIP(svcIPStr)
Expand Down

0 comments on commit 6e00ebf

Please sign in to comment.