Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebs br: new snapshot tagging (#50548) #50569

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions br/pkg/aws/ebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ func (e *EC2Session) CreateSnapshots(backupInfo *config.EBSBasedBRMeta) (map[str
}
}

tags := []*ec2.Tag{
ec2Tag("TiDBCluster-BR", "new"),
}

workerPool := utils.NewWorkerPool(e.concurrency, "create snapshots")
for i := range backupInfo.TiKVComponent.Stores {
store := backupInfo.TiKVComponent.Stores[i]
Expand Down Expand Up @@ -137,6 +141,12 @@ func (e *EC2Session) CreateSnapshots(backupInfo *config.EBSBasedBRMeta) (map[str
createSnapshotInput.SetInstanceSpecification(&instanceSpecification)
// Copy tags from source volume
createSnapshotInput.SetCopyTagsFromSource("volume")
createSnapshotInput.SetTagSpecifications([]*ec2.TagSpecification{
{
ResourceType: aws.String(ec2.ResourceTypeSnapshot),
Tags: tags,
},
})
resp, err := e.createSnapshotsWithRetry(context.TODO(), &createSnapshotInput)

if err != nil {
Expand Down Expand Up @@ -330,11 +340,6 @@ func (e *EC2Session) EnableDataFSR(meta *config.EBSBasedBRMeta, targetAZ string)

// waitDataFSREnabled waits FSR for data volume snapshots are all enabled and also have enough credit balance
func (e *EC2Session) waitDataFSREnabled(snapShotIDs []*string, targetAZ string) error {
// Record current time
start := time.Now()

// get the maximum size of volumes, in GiB
var maxVolumeSize int64 = 0
resp, err := e.ec2.DescribeSnapshots(&ec2.DescribeSnapshotsInput{SnapshotIds: snapShotIDs})
if err != nil {
return errors.Trace(err)
Expand All @@ -343,6 +348,7 @@ func (e *EC2Session) waitDataFSREnabled(snapShotIDs []*string, targetAZ string)
return errors.Errorf("specified snapshot [%s] is not found", *snapShotIDs[0])
}

<<<<<<< HEAD
for _, s := range resp.Snapshots {
if *s.VolumeSize > maxVolumeSize {
maxVolumeSize = *s.VolumeSize
Expand All @@ -362,6 +368,9 @@ func (e *EC2Session) waitDataFSREnabled(snapShotIDs []*string, targetAZ string)
}

// Wait that all snapshot has enough fsr credit balance, it's very likely true since we have wait for long enough
=======
// Wait that all snapshot has enough fsr credit balance
>>>>>>> 7ba2330394b (ebs br: new snapshot tagging (#50548))
log.Info("Start check and wait all snapshots have enough fsr credit balance")

startIdx := 0
Expand All @@ -379,9 +388,8 @@ func (e *EC2Session) waitDataFSREnabled(snapShotIDs []*string, targetAZ string)
}
retryCount++
}
// Retry for both invalid calling and not enough fsr credit
// Cloudwatch by default flushes every 5 seconds. So, 20 seconds wait should be enough
time.Sleep(20 * time.Second)
// Retry for both invalid calling and not enough fsr credit at 3 minute intervals
time.Sleep(3 * time.Minute)
}
}

Expand Down