Commit c2611778 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Storage rollback can now be aborted

Abort functionality works by removing scheduled jobs that were not
processed yet
parent 2ca11a5f
......@@ -93,6 +93,14 @@ module Gitlab
any_non_empty_queue?(::HashedStorage::RollbackerWorker, ::HashedStorage::ProjectRollbackWorker)
end
# Remove all remaining scheduled rollback operations
#
def abort_rollback!
[::HashedStorage::RollbackerWorker, ::HashedStorage::ProjectRollbackWorker].each do |worker|
Sidekiq::Queue.new(worker.queue).clear
end
end
private
def any_non_empty_queue?(*workers)
......
......@@ -232,4 +232,16 @@ RSpec.describe Gitlab::HashedStorage::Migrator, :redis do
expect(subject.rollback_pending?).to be_falsey
end
end
describe 'abort_rollback!' do
let_it_be(:project) { create(:project, :empty_repo) }
it 'removes any rollback related scheduled job' do
Sidekiq::Testing.disable! do
::HashedStorage::RollbackerWorker.perform_async(1, 5)
expect { subject.abort_rollback! }.to change { subject.rollback_pending? }.from(true).to(false)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment