diff --git a/pkg/fedvolumebackup/backupschedule/backup_schedule_manager.go b/pkg/fedvolumebackup/backupschedule/backup_schedule_manager.go index 903f5276ed..f0a89e3e4a 100644 --- a/pkg/fedvolumebackup/backupschedule/backup_schedule_manager.go +++ b/pkg/fedvolumebackup/backupschedule/backup_schedule_manager.go @@ -295,10 +295,7 @@ func sortSnapshotBackups(backupsList []*v1alpha1.VolumeBackup) []*v1alpha1.Volum // it's for test only now func sortAllSnapshotBackups(backupsList []*v1alpha1.VolumeBackup) []*v1alpha1.VolumeBackup { var ascBackupList = make([]*v1alpha1.VolumeBackup, 0) - - for _, backup := range backupsList { - ascBackupList = append(ascBackupList, backup) - } + ascBackupList = append(ascBackupList, backupsList...) sort.Slice(ascBackupList, func(i, j int) bool { return ascBackupList[i].CreationTimestamp.Unix() < ascBackupList[j].CreationTimestamp.Unix() diff --git a/pkg/fedvolumebackup/backupschedule/backup_schedule_manager_test.go b/pkg/fedvolumebackup/backupschedule/backup_schedule_manager_test.go index 3e26b38d86..43fd0e5102 100644 --- a/pkg/fedvolumebackup/backupschedule/backup_schedule_manager_test.go +++ b/pkg/fedvolumebackup/backupschedule/backup_schedule_manager_test.go @@ -16,7 +16,7 @@ package backupschedule import ( "context" "fmt" - old_v1alpha1 "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1" + oldv1alpha1 "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1" "strconv" "testing" "time" @@ -43,7 +43,7 @@ func TestManager(t *testing.T) { bs.Namespace = "ns" bs.Name = "bsname" bs.Spec.BackupTemplate.Template.BR = &v1alpha1.BRConfig{} - bs.Spec.BackupTemplate.Template.S3 = &old_v1alpha1.S3StorageProvider{} + bs.Spec.BackupTemplate.Template.S3 = &oldv1alpha1.S3StorageProvider{} // test pause bs.Spec.Pause = true @@ -204,7 +204,7 @@ func TestBuildBackup(t *testing.T) { // test BR != nil bs.Spec.BackupTemplate.Template.BR = &v1alpha1.BRConfig{} - bs.Spec.BackupTemplate.Template.S3 = &old_v1alpha1.S3StorageProvider{} + bs.Spec.BackupTemplate.Template.S3 = &oldv1alpha1.S3StorageProvider{} bk.Spec.Template.BR = bs.Spec.BackupTemplate.Template.BR.DeepCopy() bk.Spec.Template.S3 = bs.Spec.BackupTemplate.Template.S3.DeepCopy()