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

relation_export_worker.rb « import_export « projects « workers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7747d4f409906bc50811b894afec448a8fbfdf15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# frozen_string_literal: true

module Projects
  module ImportExport
    class RelationExportWorker
      include ApplicationWorker
      include ExceptionBacktrace

      idempotent!
      data_consistency :always
      deduplicate :until_executed
      feature_category :importers
      sidekiq_options dead: false, status_expiration: StuckExportJobsWorker::EXPORT_JOBS_EXPIRATION
      urgency :low
      worker_resource_boundary :memory

      sidekiq_retries_exhausted do |job, exception|
        relation_export = Projects::ImportExport::RelationExport.find(job['args'].first)
        project_export_job = relation_export.project_export_job
        project = project_export_job.project

        relation_export.mark_as_failed(job['error_message'])

        log_payload = {
          message: 'Project relation export failed',
          export_error: job['error_message'],
          relation: relation_export.relation,
          project_export_job_id: project_export_job.id,
          project_name: project.name,
          project_id: project.id
        }
        Gitlab::ExceptionLogFormatter.format!(exception, log_payload)
        Gitlab::Export::Logger.error(log_payload)
      end

      def perform(project_relation_export_id)
        relation_export = Projects::ImportExport::RelationExport.find(project_relation_export_id)

        relation_export.retry! if relation_export.started?

        if relation_export.queued?
          Projects::ImportExport::RelationExportService.new(relation_export, jid).execute
        end
      end
    end
  end
end