Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.0 today

project_import_options.rb 836 Bytes
Newer Older
1
2
# frozen_string_literal: true

3
4
5
module ProjectImportOptions
  extend ActiveSupport::Concern

6
  IMPORT_RETRY_COUNT = 5
7

8
  included do
9
10
11
12
13
14
15
16
17
18
19
20
    sidekiq_options retry: IMPORT_RETRY_COUNT, status_expiration: StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION

    # We only want to mark the project as failed once we exhausted all retries
    sidekiq_retries_exhausted do |job|
      project = Project.find(job['args'].first)

      action = if project.forked?
                 "fork"
               else
                 "import"
               end

21
      project.import_state.mark_as_failed(_("Every %{action} attempt has failed: %{job_error_message}. Please try again.") % { action: action, job_error_message: job['error_message'] })
22
23
24
25
      Sidekiq.logger.warn "Failed #{job['class']} with #{job['args']}: #{job['error_message']}"
    end
  end
end