Skip to content

Commit

Permalink
remove unused method
Browse files Browse the repository at this point in the history
  • Loading branch information
korotkov-aerospike committed Dec 22, 2024
1 parent 0f78b66 commit 01892e4
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 48 deletions.
5 changes: 0 additions & 5 deletions internal/server/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
Expand Down
23 changes: 0 additions & 23 deletions pkg/service/backup_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions pkg/service/backup_list_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
11 changes: 0 additions & 11 deletions pkg/service/restore_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{{
Expand Down Expand Up @@ -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")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/service/retention_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ 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)
}
}

return nil
}

func (e *RetentionManagerImpl) deleteExcessFullBackups(
func (e *RetentionManagerImpl) deleteFullBackups(
ctx context.Context, timestamps []time.Time, retainCount int,
) error {
if len(timestamps) <= retainCount {
Expand All @@ -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 {
Expand Down

0 comments on commit 01892e4

Please sign in to comment.