diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-04-08 19:47:23 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-04-08 19:47:36 -0300 |
commit | 285fcb4744ed5464aab7d2ff248e7824dd77315c (patch) | |
tree | cdef018693b92c164d069ae1a66e80e7acb03c7f /lib/gitlab/background_migration.rb | |
parent | 61ed92396814dcd97e787e1f7c44c05078df7118 (diff) | |
download | gitlab-ce-285fcb4744ed5464aab7d2ff248e7824dd77315c.tar.gz |
Add methods to check dead and retrying jobsosw-schedule-multiple-mr-assignees-ff-auto-enabling
It adds two methods for checking if a background job
(for a given class) has dead or retrying jobs.
Diffstat (limited to 'lib/gitlab/background_migration.rb')
-rw-r--r-- | lib/gitlab/background_migration.rb | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb index 5251e0fadf9..2e3a4f3b869 100644 --- a/lib/gitlab/background_migration.rb +++ b/lib/gitlab/background_migration.rb @@ -58,11 +58,31 @@ module Gitlab migration_class_for(class_name).new.perform(*arguments) end - def self.exists?(migration_class) + def self.exists?(migration_class, additional_queues = []) enqueued = Sidekiq::Queue.new(self.queue) scheduled = Sidekiq::ScheduledSet.new - [enqueued, scheduled].each do |queue| + enqueued_job?([enqueued, scheduled], migration_class) + end + + def self.dead_jobs?(migration_class) + dead_set = Sidekiq::DeadSet.new + + enqueued_job?([dead_set], migration_class) + end + + def self.retrying_jobs?(migration_class) + retry_set = Sidekiq::RetrySet.new + + enqueued_job?([retry_set], migration_class) + end + + def self.migration_class_for(class_name) + const_get(class_name) + end + + def self.enqueued_job?(queues, migration_class) + queues.each do |queue| queue.each do |job| return true if job.queue == self.queue && job.args.first == migration_class end @@ -70,9 +90,5 @@ module Gitlab false end - - def self.migration_class_for(class_name) - const_get(class_name) - end end end |