From 47cb73db82cc1bb280d731d8824d35e839f5d0b3 Mon Sep 17 00:00:00 2001 From: Siva Kommuri Date: Mon, 4 Mar 2024 12:17:23 -0800 Subject: [PATCH] fix Child Resources having no owner references are created more than once --- reconcilers/child.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/reconcilers/child.go b/reconcilers/child.go index dc56a1c..82b979d 100644 --- a/reconcilers/child.go +++ b/reconcilers/child.go @@ -364,9 +364,12 @@ func (r *ChildReconciler[T, CT, CLT]) filterChildren(resource T, children CLT) [ func (r *ChildReconciler[T, CT, CLT]) listOptions(ctx context.Context, resource T) []client.ListOption { if r.ListOptions == nil { - return []client.ListOption{ - client.InNamespace(resource.GetNamespace()), + opts := []client.ListOption{} + if !r.SkipOwnerReference { + opts = append(opts, client.InNamespace(resource.GetNamespace())) } + + return opts } return r.ListOptions(ctx, resource) }