Skip to content

Commit b72910c

Browse files
committed
fix(service.go): rely on LabelServiceName only
When resolving EndpointSlice -> Service ownership, do expose an error if the ownerReference in the metadata does not agree with the kubernetes.io/service-name label. Instead just use the service-name label. This aligns better to the way that other network plugins work.
1 parent 0155169 commit b72910c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/utils/service.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,14 @@ func ServiceNameforEndpointSlice(es *discoveryv1.EndpointSlice) (string, error)
5959
}
6060

6161
// At this point we do some checks to ensure that the final owning service name is sane. Specifically, we want to
62-
// check it against labelSvcName and ownerRefName if they were not blank and return error if they don't agree. We
62+
// check it against labelSvcName and ownerRefName if they were not blank and log a debug log if they don't agree. We
6363
// don't worry about generateName as that is less conclusive.
6464
//
65-
// From above, we already know that if labelSvcName was not blank then it is equal to finalSvcName, so we only need
66-
// to worry about ownerRefName
65+
// See: https://github.com/cloudnativelabs/kube-router/issues/1957 for more information
6766
if ownerRefName != "" && finalSvcName != ownerRefName {
68-
return "", fmt.Errorf("the ownerReferences field on EndpointSlice (%s) doesn't agree with with the %s label "+
69-
"(%s) for %s/%s EndpointSlice", ownerRefName, serviceNameLabel, labelSvcName, es.Namespace, es.Name)
67+
klog.V(1).Infof("The metadata ownerReference name %s and the label service name (%s) %s don't appear to "+
68+
"match for EndpointSlice %s/%s. In this case we prefer the label service name.",
69+
ownerRefName, serviceNameLabel, labelSvcName, es.Namespace, es.Name)
7070
}
7171

7272
return finalSvcName, nil

0 commit comments

Comments
 (0)