From 90850eca17f52f82983cad62ee8d93a8fb32cc2a Mon Sep 17 00:00:00 2001 From: Gabriel Saratura Date: Thu, 7 May 2026 14:59:29 +0000 Subject: [PATCH] Fix owner ref for billing --- pkg/comp-functions/functions/common/billing_service.go | 2 +- pkg/comp-functions/runtime/function_mgr.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/comp-functions/functions/common/billing_service.go b/pkg/comp-functions/functions/common/billing_service.go index aca927881b..564afc6e0a 100644 --- a/pkg/comp-functions/functions/common/billing_service.go +++ b/pkg/comp-functions/functions/common/billing_service.go @@ -234,7 +234,7 @@ func CreateOrUpdateBillingServiceWithOptions(ctx context.Context, svc *runtime.S Controller: ptr.To(true), BlockOwnerDeletion: ptr.To(false), } - kubeOpts = append(kubeOpts, runtime.KubeOptionSetOwnerReferenceFromKubeObject(billingService, ownerRef)) + kubeOpts = append(kubeOpts, runtime.KubeOptionSetOwnerReferenceFromKubeObject(ownerRef)) } // Set the BillingService as a desired kube object diff --git a/pkg/comp-functions/runtime/function_mgr.go b/pkg/comp-functions/runtime/function_mgr.go index 4bc6a67a61..9d9c97e6b2 100644 --- a/pkg/comp-functions/runtime/function_mgr.go +++ b/pkg/comp-functions/runtime/function_mgr.go @@ -559,10 +559,14 @@ func KubeOptionObserveCreateUpdate(obj *xkube.Object) { obj.Spec.ManagementPolicies = append(obj.Spec.ManagementPolicies, xpv1.ManagementActionCreate, xpv1.ManagementActionUpdate, xpv1.ManagementActionObserve) } -// KubeOptionSetOwnerReferenceFromKubeObject sets the owner reference from kube object to resource -func KubeOptionSetOwnerReferenceFromKubeObject(res client.Object, ownerRef metav1.OwnerReference) KubeObjectOption { +// KubeOptionSetOwnerReferenceFromKubeObject sets the owner reference on the manifest inside the kube object. +func KubeOptionSetOwnerReferenceFromKubeObject(ownerRef metav1.OwnerReference) KubeObjectOption { return func(obj *xkube.Object) { - res.SetOwnerReferences([]metav1.OwnerReference{ownerRef}) + u, ok := obj.Spec.ForProvider.Manifest.Object.(*unstructured.Unstructured) + if !ok { + return + } + u.SetOwnerReferences(append(u.GetOwnerReferences(), ownerRef)) } }