Skip to content

Commit 456a027

Browse files
*: adjust volume tagging (#5526)
Signed-off-by: BornChanger <[email protected]> Co-authored-by: BornChanger <[email protected]>
1 parent bb0424a commit 456a027

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pkg/backup/snapshotter/snapshotter_aws.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"fmt"
1919
"regexp"
2020

21-
"github.com/pingcap/tidb-operator/pkg/apis/label"
2221
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
2322
"github.com/pingcap/tidb-operator/pkg/backup/constants"
2423
"github.com/pingcap/tidb-operator/pkg/backup/util"
@@ -29,8 +28,8 @@ import (
2928
const (
3029
CloudAPIConcurrency = 8
3130
PVCTagKey = "CSIVolumeName"
32-
PodTagKey = "kubernetes.io/created-for/pvc/name"
33-
PodNSTagKey = "kubernetes.io/created-for/pvc/namespace"
31+
PvcNameTagKey = "kubernetes.io/created-for/pvc/name"
32+
PvcNSTagKey = "kubernetes.io/created-for/pvc/namespace"
3433
)
3534

3635
// AWSSnapshotter is the snapshotter for creating snapshots from volumes (during a backup)
@@ -105,8 +104,10 @@ func (s *AWSSnapshotter) AddVolumeTags(pvs []*corev1.PersistentVolume) error {
105104
for _, pv := range pvs {
106105
tags := make(map[string]string)
107106
tags[PVCTagKey] = pv.GetName()
108-
tags[PodTagKey] = pv.GetAnnotations()[label.AnnPodNameKey]
109-
tags[PodNSTagKey] = pv.GetLabels()[label.NamespaceLabelKey]
107+
if pv.Spec.ClaimRef != nil {
108+
tags[PvcNameTagKey] = pv.Spec.ClaimRef.Name
109+
tags[PvcNSTagKey] = pv.Spec.ClaimRef.Namespace
110+
}
110111

111112
resourcesTags[pv.GetAnnotations()[constants.AnnRestoredVolumeID]] = tags
112113
}

0 commit comments

Comments
 (0)