Skip to content

Commit

Permalink
*: code format
Browse files Browse the repository at this point in the history
Signed-off-by: BornChanger <[email protected]>
  • Loading branch information
BornChanger committed Jul 27, 2023
1 parent c2ac3c5 commit 44eefb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 2 additions & 7 deletions cmd/backup-manager/app/backup/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ import (
const (
gcPausedKeyword = "GC is paused"
pdSchedulesPausedKeyword = "Schedulers are paused"

DisabledSizeCalculate = "disabled"
CalculateFullSize = "full"
CalculateIncremental = "incremental"
CalculateAll = "all"
)

// Manager mainly used to manage backup related work
Expand Down Expand Up @@ -322,8 +317,8 @@ func (bm *Manager) performBackup(ctx context.Context, backup *v1alpha1.Backup, d
backupErr := bm.backupData(ctx, backup, bm.StatusUpdater)

defer func() {
// When not disabled, calculate the backup size for ebs backup job even if it fails
if bm.Mode == string(v1alpha1.BackupModeVolumeSnapshot) && !bm.Initialize && !bm.Initialize && backup.Spec.CalcSizeLevel != DisabledSizeCalculate {
// Calculate the backup size for ebs backup job even if it fails
if bm.Mode == string(v1alpha1.BackupModeVolumeSnapshot) && !bm.Initialize && !bm.Initialize {
fullBackupSize, incrementalBackupSize, err := util.CalcVolSnapBackupSize(ctx, backup.Spec.StorageProvider, backup.Spec.CalcSizeLevel)
if err != nil {
klog.Errorf("Failed to calc volume snapshot backup, err: %v", err)
Expand Down
9 changes: 6 additions & 3 deletions cmd/backup-manager/app/util/backup_size.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/aws/aws-sdk-go/service/ebs"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/pingcap/errors"
backup "github.com/pingcap/tidb-operator/cmd/backup-manager/app/backup"
"github.com/pingcap/tidb-operator/cmd/backup-manager/app/constants"
"github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1"
"github.com/pingcap/tidb-operator/pkg/backup/util"
Expand All @@ -53,6 +52,10 @@ const (
ListSnapMaxReturnResult = 10000
// EbsApiConcurrency This value can be between 1 and 50 due to aws service quota
EbsApiConcurrency = 40

CalculateFullSize = "full"
CalculateIncremental = "incremental"
CalculateAll = "all"
)

// CalcVolSnapBackupSize get snapshots from backup meta and then calc the backup size of snapshots.
Expand Down Expand Up @@ -150,7 +153,7 @@ func calcBackupSize(ctx context.Context, volumes map[string]string, level string
// sort snapshots by timestamp
workerPool.ApplyOnErrorGroup(eg, func() error {
var snapSize uint64
if level == backup.CalculateFullSize || level == backup.CalculateFullSize {
if level == CalculateFullSize || level == CalculateFullSize {
snapSize, apiReq, err := calculateSnapshotSize(volumeId, snapshotId)
if err != nil {
return err
Expand All @@ -159,7 +162,7 @@ func calcBackupSize(ctx context.Context, volumes map[string]string, level string
atomic.AddUint64(&apiReqCount, apiReq)
}

if level == backup.CalculateAll || level == backup.CalculateIncremental {
if level == CalculateAll || level == CalculateIncremental {
volSnapshots, err := getVolSnapshots(volumeId)
if err != nil {
return err
Expand Down

0 comments on commit 44eefb2

Please sign in to comment.