Commit dbd88c02 authored by Kamil Trzciński's avatar Kamil Trzciński

Put cancelled job in DeadSet

This replicates Sidekiq behavior
of pushing dead job into DeadSet.
parent 8d17c4da
...@@ -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