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)},