From d3403af6a8d28319997e08977e8697aadd75b2d6 Mon Sep 17 00:00:00 2001 From: David Cheung Date: Thu, 9 Mar 2023 22:02:29 +0000 Subject: [PATCH] Update duplicate endpoint handling 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. --- pkg/neg/syncers/utils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/neg/syncers/utils.go b/pkg/neg/syncers/utils.go index 35e2bd4cbd..ebbd45341a 100644 --- a/pkg/neg/syncers/utils.go +++ b/pkg/neg/syncers/utils.go @@ -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} }