From 6be1a9115f0e55a39ba5775ec896c818bdcbcaff Mon Sep 17 00:00:00 2001 From: Lyndon-Li Date: Wed, 15 Jan 2025 14:53:57 +0800 Subject: [PATCH] recall repo maintenance history on restart Signed-off-by: Lyndon-Li --- pkg/repository/maintenance/maintenance.go | 2 +- pkg/repository/maintenance/maintenance_test.go | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/repository/maintenance/maintenance.go b/pkg/repository/maintenance/maintenance.go index 807a4113c7..b854046ba0 100644 --- a/pkg/repository/maintenance/maintenance.go +++ b/pkg/repository/maintenance/maintenance.go @@ -284,7 +284,7 @@ func WaitAllJobsComplete(ctx context.Context, cli client.Client, repo *velerov1a history := []velerov1api.BackupRepositoryMaintenanceStatus{} - startPos := len(history) - limit + startPos := len(jobList.Items) - limit if startPos < 0 { startPos = 0 } diff --git a/pkg/repository/maintenance/maintenance_test.go b/pkg/repository/maintenance/maintenance_test.go index 1854aa0f9f..e4335a61fe 100644 --- a/pkg/repository/maintenance/maintenance_test.go +++ b/pkg/repository/maintenance/maintenance_test.go @@ -444,7 +444,7 @@ func TestGetJobConfig(t *testing.T) { } } -func TestWaitAlJobsComplete(t *testing.T) { +func TestWaitAllJobsComplete(t *testing.T) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) veleroNamespace := "velero" @@ -680,11 +680,6 @@ func TestWaitAlJobsComplete(t *testing.T) { jobPodSucceeded3, }, expectedStatus: []velerov1api.BackupRepositoryMaintenanceStatus{ - { - Result: velerov1api.BackupRepositoryMaintenanceSucceeded, - StartTimestamp: &metav1.Time{Time: now}, - CompleteTimestamp: &metav1.Time{Time: now.Add(time.Hour)}, - }, { Result: velerov1api.BackupRepositoryMaintenanceFailed, StartTimestamp: &metav1.Time{Time: now.Add(time.Hour)},