2018-06-27 03:31:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-11 06:35:03 -05:00
|
|
|
module ProjectImportOptions
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2018-01-11 16:00:03 -05:00
|
|
|
IMPORT_RETRY_COUNT = 5
|
2017-12-11 06:35:03 -05:00
|
|
|
|
2018-01-11 16:00:03 -05:00
|
|
|
included do
|
2017-12-11 06:35:03 -05:00
|
|
|
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
|
|
|
|
|
2018-11-27 04:41:27 -05:00
|
|
|
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'] })
|
2017-12-11 06:35:03 -05:00
|
|
|
Sidekiq.logger.warn "Failed #{job['class']} with #{job['args']}: #{job['error_message']}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|