Skip to content

Commit

Permalink
*: code format
Browse files Browse the repository at this point in the history
Signed-off-by: BornChanger <dawn_catcher@126.com>
  • Loading branch information
BornChanger committed Feb 3, 2024
1 parent fa8b348 commit a9b58a5
Showing 1 changed file with 17 additions and 24 deletions.
41 changes: 17 additions & 24 deletions br/pkg/aws/ebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,18 @@ func (e *EC2Session) CreateSnapshots(backupInfo *config.EBSBasedBRMeta) (map[str
resp, err := e.createSnapshotsWithRetry(context.TODO(), &createSnapshotInput)

if err != nil {
if aErr, ok := err.(awserr.Error); ok {
if aErr.Code() == "TagLimitExceeded" {
log.Warn("tag number exceeds AWS limitation during snapshots, retry without tagging")
createSnapshotInput.SetTagSpecifications(nil)
resp, err = e.createSnapshotsWithRetry(context.TODO(), &createSnapshotInput)
if err != nil {
return errors.Trace(err)
}
} else {
return errors.Trace(err)
}
} else {
if aErr, ok := err.(awserr.Error); !ok || aErr.Code() != "TagLimitExceeded" {
return errors.Trace(err)
}

log.Warn("tag number exceeds AWS limitation during snapshots, retry without tagging")
createSnapshotInput.SetTagSpecifications(nil)
resp, err = e.createSnapshotsWithRetry(context.TODO(), &createSnapshotInput)
if err != nil {
return errors.Trace(err)
}
}

fillResult(resp)
return nil
})
Expand Down Expand Up @@ -622,18 +619,14 @@ func (e *EC2Session) CreateVolumes(meta *config.EBSBasedBRMeta, volumeType strin

newVol, err := e.ec2.CreateVolume(&req)
if err != nil {
if aErr, ok := err.(awserr.Error); ok {
if aErr.Code() == "TagLimitExceeded" {
log.Warn("tag number exceeds AWS limitation, retry without tagging", zap.String("from_snapshot", oldVol.SnapshotID))
req.SetTagSpecifications(nil)
newVol, err = e.ec2.CreateVolume(&req)
if err != nil {
return errors.Trace(err)
}
} else {
return errors.Trace(err)
}
} else {
if aErr, ok := err.(awserr.Error); !ok || aErr.Code() != "TagLimitExceeded" {
return errors.Trace(err)
}

log.Warn("tag number exceeds AWS limitation, retry without tagging", zap.String("from_snapshot", oldVol.SnapshotID))
req.SetTagSpecifications(nil)
newVol, err = e.ec2.CreateVolume(&req)
if err != nil {
return errors.Trace(err)
}
}
Expand Down

0 comments on commit a9b58a5

Please sign in to comment.