Skip to content

Commit

Permalink
*: adjust volume tagging (#5525)
Browse files Browse the repository at this point in the history
Signed-off-by: BornChanger <[email protected]>
  • Loading branch information
BornChanger authored Jan 18, 2024
1 parent 3bd2bad commit 9c48ee5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/backup/snapshotter/snapshotter_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9c48ee5

Please sign in to comment.