diff --git a/internal/server/handlers/handlers_test.go b/internal/server/handlers/handlers_test.go index 1e1d0f68..a753b018 100644 --- a/internal/server/handlers/handlers_test.go +++ b/internal/server/handlers/handlers_test.go @@ -131,11 +131,6 @@ func (mock restoreManagerMock) CancelRestore(jobID model.RestoreJobID) error { type backupListReaderMock struct{} -func (mock backupListReaderMock) FindFullBackupsForNamespace(_ context.Context, _ model.TimeBounds, _ string, -) ([]model.BackupDetails, error) { - return []model.BackupDetails{}, nil -} - func (mock backupListReaderMock) FullBackupList(_ context.Context, timebounds model.TimeBounds, ) ([]model.BackupDetails, error) { if timebounds == (model.TimeBounds{}) { diff --git a/pkg/service/backup_backend.go b/pkg/service/backup_backend.go index e8f7bb9e..84dde443 100644 --- a/pkg/service/backup_backend.go +++ b/pkg/service/backup_backend.go @@ -164,29 +164,6 @@ func (b *BackupBackend) FindIncrementalBackupsForNamespace( return filteredIncrementalBackups, nil } -// FindFullBackupsForNamespace returns all incremental backups in given range, sorted by time. -func (b *BackupBackend) FindFullBackupsForNamespace( - ctx context.Context, bounds model.TimeBounds, namespace string, -) ([]model.BackupDetails, error) { - allIncrementalBackupList, err := b.FullBackupList(ctx, bounds) - if err != nil { - return nil, err - } - - var filteredIncrementalBackups []model.BackupDetails - for _, b := range allIncrementalBackupList { - if b.Namespace == namespace { - filteredIncrementalBackups = append(filteredIncrementalBackups, b) - } - } - // Sort in place - sort.Slice(filteredIncrementalBackups, func(i, j int) bool { - return filteredIncrementalBackups[i].Created.Before(filteredIncrementalBackups[j].Created) - }) - - return filteredIncrementalBackups, nil -} - func (b *BackupBackend) ReadClusterConfiguration(path string) ([]byte, error) { configBackups, err := storage.ReadFiles(context.Background(), b.storage, path, configExt, nil) if err != nil { diff --git a/pkg/service/backup_list_reader.go b/pkg/service/backup_list_reader.go index e634db3e..b2f36433 100644 --- a/pkg/service/backup_list_reader.go +++ b/pkg/service/backup_list_reader.go @@ -30,9 +30,4 @@ type BackupListReader interface { FindIncrementalBackupsForNamespace( ctx context.Context, bounds model.TimeBounds, namespace string, ) ([]model.BackupDetails, error) - - // FindFullBackupsForNamespace returns all full backups in given range, sorted by time. - FindFullBackupsForNamespace( - ctx context.Context, bounds model.TimeBounds, namespace string, - ) ([]model.BackupDetails, error) } diff --git a/pkg/service/restore_data_test.go b/pkg/service/restore_data_test.go index f5c65b94..961267fe 100644 --- a/pkg/service/restore_data_test.go +++ b/pkg/service/restore_data_test.go @@ -68,12 +68,6 @@ func makeTestRestoreService(wg *sync.WaitGroup) *dataRestorer { type BackendMock struct { } -func (m *BackendMock) FindFullBackupsForNamespace( - _ context.Context, _ model.TimeBounds, _ string, -) ([]model.BackupDetails, error) { - return []model.BackupDetails{}, nil -} - func (m *BackendMock) FindIncrementalBackupsForNamespace(_ context.Context, _ model.TimeBounds, _ string, ) ([]model.BackupDetails, error) { return []model.BackupDetails{{ @@ -155,11 +149,6 @@ func (m *BackendFailMock) FindIncrementalBackupsForNamespace(_ context.Context, return nil, nil } -func (m *BackendFailMock) FindFullBackupsForNamespace(_ context.Context, _ model.TimeBounds, _ string, -) ([]model.BackupDetails, error) { - return nil, nil -} - func (m *BackendFailMock) ReadClusterConfiguration(_ string) ([]byte, error) { return nil, errors.New("mock error") } diff --git a/pkg/service/retention_manager.go b/pkg/service/retention_manager.go index 7e530b07..2fbd0e4b 100644 --- a/pkg/service/retention_manager.go +++ b/pkg/service/retention_manager.go @@ -47,13 +47,13 @@ func (e *RetentionManagerImpl) deleteOldBackups(ctx context.Context) error { timestamps := getTimestamps(fullBackups) if e.policy.FullBackups != nil { - if err := e.deleteExcessFullBackups(ctx, timestamps, *e.policy.FullBackups); err != nil { + if err := e.deleteFullBackups(ctx, timestamps, *e.policy.FullBackups); err != nil { return fmt.Errorf("failed to delete excess full backups: %w", err) } } if e.policy.IncrBackups != nil { - if err := e.deleteExcessIncrementalBackups(ctx, timestamps, *e.policy.IncrBackups); err != nil { + if err := e.deleteIncrementalBackups(ctx, timestamps, *e.policy.IncrBackups); err != nil { return fmt.Errorf("failed to delete excess incremental backups: %w", err) } } @@ -61,7 +61,7 @@ func (e *RetentionManagerImpl) deleteOldBackups(ctx context.Context) error { return nil } -func (e *RetentionManagerImpl) deleteExcessFullBackups( +func (e *RetentionManagerImpl) deleteFullBackups( ctx context.Context, timestamps []time.Time, retainCount int, ) error { if len(timestamps) <= retainCount { @@ -78,7 +78,7 @@ func (e *RetentionManagerImpl) deleteExcessFullBackups( return nil } -func (e *RetentionManagerImpl) deleteExcessIncrementalBackups( +func (e *RetentionManagerImpl) deleteIncrementalBackups( ctx context.Context, timestamps []time.Time, retainCount int, ) error { if len(timestamps) <= retainCount {