Skip to content

Commit 4a6756d

Browse files
authored
Merge pull request #9683 from Lyndon-Li/increase-repo-maintenance-history-queue-length
Issue 9428: increase repo maintenance history queue length
2 parents e1cc07c + 1730b7f commit 4a6756d

3 files changed

Lines changed: 10 additions & 5 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix issue #9428, increase repo maintenance history queue length from 3 to 25

pkg/controller/backup_repository_controller.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ import (
5252
const (
5353
repoSyncPeriod = 5 * time.Minute
5454
defaultMaintainFrequency = 7 * 24 * time.Hour
55-
defaultMaintenanceStatusQueueLength = 3
55+
defaultMaintenanceStatusQueueLength = 25
5656
)
5757

58+
var maintenanceStatusQueueLength = defaultMaintenanceStatusQueueLength
59+
5860
type BackupRepoReconciler struct {
5961
client.Client
6062
namespace string
@@ -369,7 +371,7 @@ func ensureRepo(repo *velerov1api.BackupRepository, repoManager repomanager.Mana
369371
}
370372

371373
func (r *BackupRepoReconciler) recallMaintenance(ctx context.Context, req *velerov1api.BackupRepository, log logrus.FieldLogger) error {
372-
history, err := maintenance.WaitAllJobsComplete(ctx, r.Client, req, defaultMaintenanceStatusQueueLength, log)
374+
history, err := maintenance.WaitAllJobsComplete(ctx, r.Client, req, maintenanceStatusQueueLength, log)
373375
if err != nil {
374376
return errors.Wrapf(err, "error waiting incomplete repo maintenance job for repo %s", req.Name)
375377
}
@@ -427,7 +429,7 @@ func consolidateHistory(coming, cur []velerov1api.BackupRepositoryMaintenanceSta
427429

428430
truncated := []velerov1api.BackupRepositoryMaintenanceStatus{}
429431
for consolidator.Len() > 0 {
430-
if len(truncated) == defaultMaintenanceStatusQueueLength {
432+
if len(truncated) == maintenanceStatusQueueLength {
431433
break
432434
}
433435

@@ -537,8 +539,8 @@ func updateRepoMaintenanceHistory(repo *velerov1api.BackupRepository, result vel
537539
}
538540

539541
startingPos := 0
540-
if len(repo.Status.RecentMaintenance) >= defaultMaintenanceStatusQueueLength {
541-
startingPos = len(repo.Status.RecentMaintenance) - defaultMaintenanceStatusQueueLength + 1
542+
if len(repo.Status.RecentMaintenance) >= maintenanceStatusQueueLength {
543+
startingPos = len(repo.Status.RecentMaintenance) - maintenanceStatusQueueLength + 1
542544
}
543545

544546
repo.Status.RecentMaintenance = append(repo.Status.RecentMaintenance[startingPos:], latest)

pkg/controller/backup_repository_controller_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ func TestUpdateRepoMaintenanceHistory(t *testing.T) {
929929

930930
for _, test := range tests {
931931
t.Run(test.name, func(t *testing.T) {
932+
maintenanceStatusQueueLength = 3
933+
932934
updateRepoMaintenanceHistory(test.backupRepo, test.result, &metav1.Time{Time: standardTime}, &metav1.Time{Time: standardTime.Add(time.Hour)}, "fake-message-0")
933935

934936
for at := range test.backupRepo.Status.RecentMaintenance {

0 commit comments

Comments
 (0)