Commit d57d8ddb authored by Stan Hu's avatar Stan Hu

Merge branch 'sidekiq-interrupt-running-jobs-deadset' into 'master'

Put cancelled job in DeadSet

See merge request gitlab-org/gitlab-ce!32070
parents 45b3f554 dbd88c02
...@@ -8,8 +8,12 @@ module Gitlab ...@@ -8,8 +8,12 @@ module Gitlab
yield yield
end end
rescue Gitlab::SidekiqMonitor::CancelledError rescue Gitlab::SidekiqMonitor::CancelledError
# push job to DeadSet
payload = ::Sidekiq.dump_json(job)
::Sidekiq::DeadSet.new.kill(payload, notify_failure: false)
# ignore retries # ignore retries
raise Sidekiq::JobRetry::Skip raise ::Sidekiq::JobRetry::Skip
end end
end end
end end
......
...@@ -33,9 +33,17 @@ describe Gitlab::SidekiqMiddleware::Monitor do ...@@ -33,9 +33,17 @@ describe Gitlab::SidekiqMiddleware::Monitor do
end end
end end
it 'does skip this job' do it 'skips the job' do
expect { subject }.to raise_error(Sidekiq::JobRetry::Skip) expect { subject }.to raise_error(Sidekiq::JobRetry::Skip)
end end
it 'puts job in DeadSet' do
::Sidekiq::DeadSet.new.clear
expect do
subject rescue Sidekiq::JobRetry::Skip
end.to change { ::Sidekiq::DeadSet.new.size }.by(1)
end
end end
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