diff options
author | James Lopez <james@jameslopez.es> | 2017-03-24 12:08:34 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-04-05 16:11:51 +0200 |
commit | 58371efbb0bd051d3a82f82acac98ad4692efeb4 (patch) | |
tree | 226bfb1a920a6344d6efb3b0357473412aa9dade /lib/gitlab/sidekiq_status.rb | |
parent | 7196adaaa4ce5aa259d285dbca6aa98f4deb046b (diff) | |
download | gitlab-ce-58371efbb0bd051d3a82f82acac98ad4692efeb4.tar.gz |
Periodically mark projects that are stuck in importing as failed
Adds import jid to projects
Refactor middleware to set custom expiration time via sidekiq options
Add completed_jids option to sidekiq status and a few other changes
Diffstat (limited to 'lib/gitlab/sidekiq_status.rb')
-rw-r--r-- | lib/gitlab/sidekiq_status.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/sidekiq_status.rb b/lib/gitlab/sidekiq_status.rb index 11e5f1b645c..ca8d3271541 100644 --- a/lib/gitlab/sidekiq_status.rb +++ b/lib/gitlab/sidekiq_status.rb @@ -72,6 +72,8 @@ module Gitlab # job_ids - The Sidekiq job IDs to check. # # Returns an array of true or false indicating job completion. + # true = job is still running + # false = job completed def self.job_status(job_ids) keys = job_ids.map { |jid| key_for(jid) } @@ -82,6 +84,17 @@ module Gitlab end end + # Returns the JIDs that are completed + # + # job_ids - The Sidekiq job IDs to check. + # + # Returns an array of completed JIDs + def self.completed_jids(job_ids) + Sidekiq.redis do |redis| + job_ids.reject { |jid| redis.exists(key_for(jid)) } + end + end + def self.key_for(jid) STATUS_KEY % jid end |