Provisioning: Use commit only once mode in bulk delete (#108759)

Use commit only once mode in bulk delete
This commit is contained in:
Roberto Jiménez Sánchez 2025-07-29 10:37:27 +02:00 committed by GitHub
parent a2698dc3b5
commit 6af1bfe21b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -46,9 +46,12 @@ func (w *Worker) Process(ctx context.Context, repo repository.Repository, job pr
return w.deleteFiles(ctx, rw, progress, opts, paths...)
}
msg := fmt.Sprintf("Delete from Grafana %s", job.Name)
stageOptions := repository.StageOptions{
PushOnWrites: false,
Timeout: 10 * time.Minute,
Mode: repository.StageModeCommitOnlyOnce,
CommitOnlyOnceMessage: msg,
PushOnWrites: false,
Timeout: 10 * time.Minute,
}
err := w.wrapFn(ctx, repo, stageOptions, fn)

View File

@ -93,7 +93,10 @@ func TestDeleteWorker_ProcessNotReaderWriter(t *testing.T) {
mockWrapFn := repository.NewMockWrapWithStageFn(t)
mockWrapFn.On("Execute", mock.Anything, mockRepo, mock.MatchedBy(func(opts repository.StageOptions) bool {
return !opts.PushOnWrites && opts.Timeout == 10*time.Minute
return !opts.PushOnWrites &&
opts.Timeout == 10*time.Minute &&
opts.Mode == repository.StageModeCommitOnlyOnce &&
opts.CommitOnlyOnceMessage == "Delete from Grafana "+job.Name
}), mock.Anything).Return(errors.New("delete job submitted targeting repository that is not a ReaderWriter"))
mockProgress.On("SetTotal", mock.Anything, 1).Return()
@ -145,7 +148,10 @@ func TestDeleteWorker_ProcessDeleteFilesSuccess(t *testing.T) {
mockWrapFn := repository.NewMockWrapWithStageFn(t)
mockWrapFn.On("Execute", mock.Anything, mockRepo, mock.MatchedBy(func(opts repository.StageOptions) bool {
return !opts.PushOnWrites && opts.Timeout == 10*time.Minute
return !opts.PushOnWrites &&
opts.Timeout == 10*time.Minute &&
opts.Mode == repository.StageModeCommitOnlyOnce &&
opts.CommitOnlyOnceMessage == "Delete from Grafana "+job.Name
}), mock.Anything).Return(func(ctx context.Context, repo repository.Repository, stageOptions repository.StageOptions, fn func(repository.Repository, bool) error) error {
return fn(mockRepo, false)
})