From 9c48ee56a7660ab929c306d7df1c1823c7b53a21 Mon Sep 17 00:00:00 2001 From: BornChanger <97348524+BornChanger@users.noreply.github.com> Date: Thu, 18 Jan 2024 19:08:37 +0800 Subject: [PATCH] *: adjust volume tagging (#5525) Signed-off-by: BornChanger --- pkg/backup/snapshotter/snapshotter_aws.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/backup/snapshotter/snapshotter_aws.go b/pkg/backup/snapshotter/snapshotter_aws.go index 116ac2f780..5f14b6658e 100644 --- a/pkg/backup/snapshotter/snapshotter_aws.go +++ b/pkg/backup/snapshotter/snapshotter_aws.go @@ -18,7 +18,6 @@ import ( "fmt" "regexp" - "github.com/pingcap/tidb-operator/pkg/apis/label" "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1" "github.com/pingcap/tidb-operator/pkg/backup/constants" "github.com/pingcap/tidb-operator/pkg/backup/util" @@ -29,8 +28,8 @@ import ( const ( CloudAPIConcurrency = 8 PVCTagKey = "CSIVolumeName" - PodTagKey = "kubernetes.io/created-for/pvc/name" - PodNSTagKey = "kubernetes.io/created-for/pvc/namespace" + PvcNameTagKey = "kubernetes.io/created-for/pvc/name" + PvcNSTagKey = "kubernetes.io/created-for/pvc/namespace" ) // AWSSnapshotter is the snapshotter for creating snapshots from volumes (during a backup) @@ -105,8 +104,10 @@ func (s *AWSSnapshotter) AddVolumeTags(pvs []*corev1.PersistentVolume) error { for _, pv := range pvs { tags := make(map[string]string) tags[PVCTagKey] = pv.GetName() - tags[PodTagKey] = pv.GetAnnotations()[label.AnnPodNameKey] - tags[PodNSTagKey] = pv.GetLabels()[label.NamespaceLabelKey] + if pv.Spec.ClaimRef != nil { + tags[PvcNameTagKey] = pv.Spec.ClaimRef.Name + tags[PvcNSTagKey] = pv.Spec.ClaimRef.Namespace + } resourcesTags[pv.GetAnnotations()[constants.AnnRestoredVolumeID]] = tags }