Skip to content

Commit

Permalink
*: adjust volume tagging (#5526)
Browse files Browse the repository at this point in the history
Signed-off-by: BornChanger <[email protected]>
Co-authored-by: BornChanger <[email protected]>
  • Loading branch information
ti-chi-bot and BornChanger authored Jan 18, 2024
1 parent bb0424a commit 456a027
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 456a027

Please sign in to comment.