From cee8858614fb0cd3876a2943c4764c0a408c3a73 Mon Sep 17 00:00:00 2001 From: Matt Pryor Date: Mon, 30 Jan 2023 17:16:31 +0000 Subject: [PATCH] Only respect controller refs for resources Signed-off-by: Matt Pryor --- pkg/cache/references.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/cache/references.go b/pkg/cache/references.go index 218983655..90412bf8d 100644 --- a/pkg/cache/references.go +++ b/pkg/cache/references.go @@ -20,9 +20,17 @@ func mightHaveInferredOwner(r *Resource) bool { func (c *clusterCache) resolveResourceReferences(un *unstructured.Unstructured) ([]metav1.OwnerReference, func(kube.ResourceKey) bool) { var isInferredParentOf func(_ kube.ResourceKey) bool - ownerRefs := un.GetOwnerReferences() + allOwnerRefs := un.GetOwnerReferences() gvk := un.GroupVersionKind() + // TODO: Put this behind a gate + ownerRefs := []metav1.OwnerReference{} + for _, ownerRef := range allOwnerRefs { + if ownerRef.Controller != nil && *ownerRef.Controller { + ownerRefs = append(ownerRefs, ownerRef) + } + } + switch { // Special case for endpoint. Remove after https://github.com/kubernetes/kubernetes/issues/28483 is fixed