Skip to content

Commit d4050a8

Browse files
authored
Merge pull request kubernetes#119394 from aroradaman/fix/proxy-conntrack
Fix stale conntrack flow detection logic
2 parents 1bfced5 + 2e5f171 commit d4050a8

File tree

5 files changed

+144
-93
lines changed

5 files changed

+144
-93
lines changed

pkg/proxy/endpoints.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ func (info *BaseEndpointInfo) Port() (int, error) {
117117
return proxyutil.PortPart(info.Endpoint)
118118
}
119119

120-
// Equal is part of proxy.Endpoint interface.
121-
func (info *BaseEndpointInfo) Equal(other Endpoint) bool {
122-
return info.String() == other.String() &&
123-
info.GetIsLocal() == other.GetIsLocal() &&
124-
info.IsReady() == other.IsReady()
125-
}
126-
127120
// GetNodeName returns the NodeName for this endpoint.
128121
func (info *BaseEndpointInfo) GetNodeName() string {
129122
return info.NodeName
@@ -414,18 +407,18 @@ func detectStaleConntrackEntries(oldEndpointsMap, newEndpointsMap EndpointsMap,
414407
}
415408

416409
for _, ep := range epList {
417-
// If the old endpoint wasn't Ready then there can't be stale
410+
// If the old endpoint wasn't Serving then there can't be stale
418411
// conntrack entries since there was no traffic sent to it.
419-
if !ep.IsReady() {
412+
if !ep.IsServing() {
420413
continue
421414
}
422415

423416
deleted := true
424417
// Check if the endpoint has changed, including if it went from
425-
// ready to not ready. If it did change stale entries for the old
418+
// serving to not serving. If it did change stale entries for the old
426419
// endpoint have to be cleared.
427420
for i := range newEndpointsMap[svcPortName] {
428-
if newEndpointsMap[svcPortName][i].Equal(ep) {
421+
if newEndpointsMap[svcPortName][i].String() == ep.String() {
429422
deleted = false
430423
break
431424
}
@@ -446,21 +439,21 @@ func detectStaleConntrackEntries(oldEndpointsMap, newEndpointsMap EndpointsMap,
446439
continue
447440
}
448441

449-
epReady := 0
442+
epServing := 0
450443
for _, ep := range epList {
451-
if ep.IsReady() {
452-
epReady++
444+
if ep.IsServing() {
445+
epServing++
453446
}
454447
}
455448

456-
oldEpReady := 0
449+
oldEpServing := 0
457450
for _, ep := range oldEndpointsMap[svcPortName] {
458-
if ep.IsReady() {
459-
oldEpReady++
451+
if ep.IsServing() {
452+
oldEpServing++
460453
}
461454
}
462455

463-
if epReady > 0 && oldEpReady == 0 {
456+
if epServing > 0 && oldEpServing == 0 {
464457
*newlyActiveUDPServices = append(*newlyActiveUDPServices, svcPortName)
465458
}
466459
}

0 commit comments

Comments
 (0)