From 57d455d84236af8c9d59dc0209310e5b8833086a Mon Sep 17 00:00:00 2001 From: KubeKyrie Date: Thu, 19 Dec 2024 18:05:30 +0800 Subject: [PATCH] fix set owner-reference Signed-off-by: KubeKyrie --- pkg/controllers/cluster/controller.go | 7 ++++++- pkg/controllers/clusterops/controller.go | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/controllers/cluster/controller.go b/pkg/controllers/cluster/controller.go index 419a8a3b8..4949baf6b 100644 --- a/pkg/controllers/cluster/controller.go +++ b/pkg/controllers/cluster/controller.go @@ -180,7 +180,12 @@ func (c *Controller) UpdateOwnReferenceToCluster(cluster *clusterv1alpha1.Cluste return util.UpdateOwnReference(c.ClientSet, cluster.Spec.ConfigDataList(), cluster.Spec.SecretDataList(), - *metav1.NewControllerRef(cluster, clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster")), + metav1.OwnerReference{ + APIVersion: clusterv1alpha1.SchemeGroupVersion.String(), + Kind: clusterv1alpha1.SchemeGroupVersion.WithKind("Cluster").Kind, + Name: cluster.Name, + UID: cluster.GetUID(), + }, ) } diff --git a/pkg/controllers/clusterops/controller.go b/pkg/controllers/clusterops/controller.go index 4307b1fb3..6ac45f1e6 100644 --- a/pkg/controllers/clusterops/controller.go +++ b/pkg/controllers/clusterops/controller.go @@ -811,7 +811,12 @@ func (c *Controller) UpdateOwnReferenceToClusterOps(clusterOps *clusteroperation c.ClientSet, clusterOps.Spec.ConfigDataList(), clusterOps.Spec.SecretDataList(), - *metav1.NewControllerRef(clusterOps, clusteroperationv1alpha1.SchemeGroupVersion.WithKind("ClusterOperation")), + metav1.OwnerReference{ + APIVersion: clusterv1alpha1.SchemeGroupVersion.String(), + Kind: clusterv1alpha1.SchemeGroupVersion.WithKind("ClusterOperation").Kind, + Name: clusterOps.Name, + UID: clusterOps.GetUID(), + }, ) }