diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-10 09:08:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-10 09:08:07 +0300 |
commit | 232655bf32cd474d54de357b65ef43d77271117c (patch) | |
tree | d176e36660e41bb2b629237639015d4dde7d4414 /app/workers | |
parent | f5ae9d0960aa422a65a2a22e230100257dddb9ed (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
3 files changed, 30 insertions, 32 deletions
diff --git a/app/workers/concerns/gitlab/github_import/notify_upon_death.rb b/app/workers/concerns/gitlab/github_import/notify_upon_death.rb deleted file mode 100644 index 3d7120665b6..00000000000 --- a/app/workers/concerns/gitlab/github_import/notify_upon_death.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module GithubImport - # NotifyUponDeath can be included into a GitHub worker class if it should - # notify any JobWaiter instances upon being moved to the Sidekiq dead queue. - # - # Note that this will only notify the waiter upon graceful termination, a - # SIGKILL will still result in the waiter _not_ being notified. - # - # Workers including this module must have jobs passed where the last - # argument is the key to notify, as a String. - module NotifyUponDeath - extend ActiveSupport::Concern - - included do - # If a job is being exhausted we still want to notify the - # AdvanceStageWorker. This prevents the entire import from getting stuck - # just because 1 job threw too many errors. - sidekiq_retries_exhausted do |job| - args = job['args'] - jid = job['jid'] - - if args.length == 3 && (key = args.last) && key.is_a?(String) - JobWaiter.notify(key, jid) - end - end - end - end - end -end diff --git a/app/workers/concerns/gitlab/github_import/object_importer.rb b/app/workers/concerns/gitlab/github_import/object_importer.rb index bd0b566658e..63c1ba8e699 100644 --- a/app/workers/concerns/gitlab/github_import/object_importer.rb +++ b/app/workers/concerns/gitlab/github_import/object_importer.rb @@ -11,7 +11,7 @@ module Gitlab include ApplicationWorker include GithubImport::Queue include ReschedulingMethods - include NotifyUponDeath + include Gitlab::NotifyUponDeath feature_category :importers worker_has_external_dependencies! diff --git a/app/workers/concerns/gitlab/notify_upon_death.rb b/app/workers/concerns/gitlab/notify_upon_death.rb new file mode 100644 index 00000000000..66dc6270637 --- /dev/null +++ b/app/workers/concerns/gitlab/notify_upon_death.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Gitlab + # NotifyUponDeath can be included into a worker class if it should + # notify any JobWaiter instances upon being moved to the Sidekiq dead queue. + # + # Note that this will only notify the waiter upon graceful termination, a + # SIGKILL will still result in the waiter _not_ being notified. + # + # Workers including this module must have jobs passed where the last + # argument is the key to notify, as a String. + module NotifyUponDeath + extend ActiveSupport::Concern + + included do + # If a job is being exhausted we still want to notify the + # Gitlab::Import::AdvanceStageWorker. This prevents the entire import from getting stuck + # just because 1 job threw too many errors. + sidekiq_retries_exhausted do |job| + args = job['args'] + jid = job['jid'] + + if args.length == 3 && (key = args.last) && key.is_a?(String) + JobWaiter.notify(key, jid) + end + end + end + end +end |