From d3d3d75e26473ad7cd52044298662c5e2aa929e8 Mon Sep 17 00:00:00 2001 From: Shanshan Date: Mon, 20 May 2024 12:03:23 +0800 Subject: [PATCH] fix: missing svc related feature gates in backup (#7388) Co-authored-by: wusai80 --- .../dataprotection/backup_controller.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/controllers/dataprotection/backup_controller.go b/controllers/dataprotection/backup_controller.go index d22d253b9b7..16abfce12f4 100644 --- a/controllers/dataprotection/backup_controller.go +++ b/controllers/dataprotection/backup_controller.go @@ -710,6 +710,16 @@ func getClusterObjectString(cluster *appsv1alpha1.Cluster) (*string, error) { constant.ExtraEnvAnnotationKey: v, } } + + for _, key := range getServiceFeatureGatesAnnotationKeys() { + if v, ok := cluster.Annotations[key]; ok { + if newCluster.Annotations == nil { + newCluster.Annotations = map[string]string{} + } + newCluster.Annotations[key] = v + } + } + clusterBytes, err := json.Marshal(newCluster) if err != nil { return nil, err @@ -733,3 +743,13 @@ func setClusterSnapshotAnnotation(backup *dpv1alpha1.Backup, cluster *appsv1alph backup.Annotations[constant.ClusterSnapshotAnnotationKey] = *clusterString return nil } + +// getServiceFeatureGatesAnnotationKeys returns the keys of the annotations that are used to enable or disable certain service features. +func getServiceFeatureGatesAnnotationKeys() []string { + return []string{ + constant.EnabledNodePortSvcAnnotationKey, + constant.EnabledPodOrdinalSvcAnnotationKey, + constant.DisabledClusterIPSvcAnnotationKey, + constant.ShardSvcAnnotationKey, + } +}