Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTiago Botelho <tiagonbotelho@hotmail.com>2017-12-11 14:35:03 +0300
committerTiago Botelho <tiagonbotelho@hotmail.com>2017-12-15 12:54:10 +0300
commit558c971e3198c3127320402c8d060243c7b28daa (patch)
treeddf2bcf0b02f76dbec6437b05138d2abbc2a40d4 /app/workers/concerns/project_import_options.rb
parentfb47f2a7459f4c413f3fe496bcdb1b40d81d73a4 (diff)
Fork and Import jobs only get marked as failed when the number of Sidekiq retries were exhausted
Diffstat (limited to 'app/workers/concerns/project_import_options.rb')
-rw-r--r--app/workers/concerns/project_import_options.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/workers/concerns/project_import_options.rb b/app/workers/concerns/project_import_options.rb
new file mode 100644
index 00000000000..10b971344f7
--- /dev/null
+++ b/app/workers/concerns/project_import_options.rb
@@ -0,0 +1,23 @@
+module ProjectImportOptions
+ extend ActiveSupport::Concern
+
+ included do
+ IMPORT_RETRY_COUNT = 5
+
+ 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
+
+ project.mark_import_as_failed("Every #{action} attempt has failed: #{job['error_message']}. Please try again.")
+ Sidekiq.logger.warn "Failed #{job['class']} with #{job['args']}: #{job['error_message']}"
+ end
+ end
+end