mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 21:12:07 +00:00
perf: optimize the GetPodServiceMemberships
function. If the service is not the pod's membership, it seems unnecessary to get the key
Signed-off-by: joey <zchengjoey@gmail.com>
This commit is contained in:
parent
f5c5384181
commit
0dcaedeb6c
@ -61,11 +61,12 @@ func GetPodServiceMemberships(serviceLister v1listers.ServiceLister, pod *v1.Pod
|
||||
// if the service has a nil selector this means selectors match nothing, not everything.
|
||||
continue
|
||||
}
|
||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(service)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if labels.ValidatedSetSelector(service.Spec.Selector).Matches(labels.Set(pod.Labels)) {
|
||||
key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(service)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
set.Insert(key)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user