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 }