2018-11-08 19:23:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module ProjectImportOptions
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
IMPORT_RETRY_COUNT = 5
|
|
|
|
|
|
|
|
included do
|
2020-06-23 00:09:42 +05:30
|
|
|
sidekiq_options retry: IMPORT_RETRY_COUNT, status_expiration: Gitlab::Import::StuckImportJob::IMPORT_JOBS_EXPIRATION
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
if project.jira_import?
|
|
|
|
project.latest_jira_import.do_fail!
|
|
|
|
else
|
|
|
|
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'] })
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
Sidekiq.logger.warn "Failed #{job['class']} with #{job['args']}: #{job['error_message']}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|