ceph: improve owner reference management

It's better to validate ownerReferences when setting them. In addition, we should use
controllerrutil.Set{Controller,Owner}Reference, that have such validation, as possible.

Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
This commit is contained in:
Satoru Takeuchi committed 2021-03-16 10:29:33 +00:00
1 parent 53cc160817
commit 26c8fd9bd1
85 files changed
+631 -309

No files matched your search

@@ -136,12 +136,14 @@ func IsReadyToReconcile(c client.Client, clustercontext *clusterd.Context, names
// ClusterOwnerRef represents the owner reference of the CephCluster CR
func ClusterOwnerRef(clusterName, clusterID string) metav1.OwnerReference {
blockOwner := true
controller := true
return metav1.OwnerReference{
APIVersion: fmt.Sprintf("%s/%s", ClusterResource.Group, ClusterResource.Version),
Kind: ClusterResource.Kind,
Name: clusterName,
UID: types.UID(clusterID),
BlockOwnerDeletion: &blockOwner,
Controller: &controller,
}
}