summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-08-21 21:15:03 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2019-08-21 21:15:03 +0200
commitdbd88c02d6d2e4cb8af5347dd8e7b3ae63079a9d (patch)
tree479feae90b06a0063454e810b7e02228212baa01
parent8d17c4dae6b4662dddffe9e2ddca8100e8cd3d0b (diff)
downloadgitlab-ce-dbd88c02d6d2e4cb8af5347dd8e7b3ae63079a9d.tar.gz
Put cancelled job in DeadSetsidekiq-interrupt-running-jobs-deadset
This replicates Sidekiq behavior of pushing dead job into DeadSet.
-rw-r--r--lib/gitlab/sidekiq_middleware/monitor.rb6
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb10
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/gitlab/sidekiq_middleware/monitor.rb b/lib/gitlab/sidekiq_middleware/monitor.rb
index 0d88fe760d3..53a6132edac 100644
--- a/lib/gitlab/sidekiq_middleware/monitor.rb
+++ b/lib/gitlab/sidekiq_middleware/monitor.rb
@@ -8,8 +8,12 @@ module Gitlab
yield
end
rescue Gitlab::SidekiqMonitor::CancelledError
+ # push job to DeadSet
+ payload = ::Sidekiq.dump_json(job)
+ ::Sidekiq::DeadSet.new.kill(payload, notify_failure: false)
+
# ignore retries
- raise Sidekiq::JobRetry::Skip
+ raise ::Sidekiq::JobRetry::Skip
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb b/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb
index 2933d26a387..7319cdc2399 100644
--- a/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb
@@ -33,9 +33,17 @@ describe Gitlab::SidekiqMiddleware::Monitor do
end
end
- it 'does skip this job' do
+ it 'skips the job' do
expect { subject }.to raise_error(Sidekiq::JobRetry::Skip)
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