From 03e4f2904462a9d249130196f4353f779c9454a1 Mon Sep 17 00:00:00 2001 From: wangyelei Date: Thu, 16 May 2024 17:54:25 +0800 Subject: [PATCH] fix: when a component does not specify componentDefRef, each component will create a backupPolicy (#7375) --- controllers/apps/transformer_cluster_backup_policy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/apps/transformer_cluster_backup_policy.go b/controllers/apps/transformer_cluster_backup_policy.go index 491c8117965..166473e8679 100644 --- a/controllers/apps/transformer_cluster_backup_policy.go +++ b/controllers/apps/transformer_cluster_backup_policy.go @@ -520,7 +520,7 @@ func (r *clusterBackupPolicyTransformer) mergeClusterBackup( func (r *clusterBackupPolicyTransformer) getClusterComponentSpecs() []*appsv1alpha1.ClusterComponentSpec { var compSpecs []*appsv1alpha1.ClusterComponentSpec for i, v := range r.clusterTransformContext.Cluster.Spec.ComponentSpecs { - if v.ComponentDefRef == r.backupPolicy.ComponentDefRef || slices.Contains(r.backupPolicy.ComponentDefs, v.ComponentDef) { + if (v.ComponentDefRef != "" && v.ComponentDefRef == r.backupPolicy.ComponentDefRef) || slices.Contains(r.backupPolicy.ComponentDefs, v.ComponentDef) { compSpecs = append(compSpecs, &r.clusterTransformContext.Cluster.Spec.ComponentSpecs[i]) } }