Skip to content

Commit

Permalink
Update duplicate endpoint handling
Browse files Browse the repository at this point in the history
When we encounter duplicate endpoints, we would always choose the one
with an alphabetically lower name so we have a consistent and reliable
way to break the tie.
  • Loading branch information
sawsa307 committed Mar 11, 2023
1 parent 90f3dfb commit d3403af
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/neg/syncers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,12 @@ func toZoneNetworkEndpointMap(eds []negtypes.EndpointsData, zoneGetter negtypes.
}
zoneNetworkEndpointMap[zone].Insert(networkEndpoint)

// increment the count for duplicated endpoint
if _, contains := networkEndpointPodMap[networkEndpoint]; contains {
// increment the count for duplicate endpoint
if existingPod, contains := networkEndpointPodMap[networkEndpoint]; contains {
dupCount += 1
if existingPod.Name < endpointAddress.TargetRef.Name {
continue // if existing name is alphabetically lower than current one, continue and don't replace
}
}
networkEndpointPodMap[networkEndpoint] = types.NamespacedName{Namespace: endpointAddress.TargetRef.Namespace, Name: endpointAddress.TargetRef.Name}
}
Expand Down

0 comments on commit d3403af

Please sign in to comment.