Class: Projects::ImportExport::ParallelProjectExportWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, ExceptionBacktrace, Sidekiq::InterruptionsExhausted
Defined in:
app/workers/projects/import_export/parallel_project_export_worker.rb

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_CONCURRENCY_LIMIT_PERCENTAGE_BY_URGENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DATA_CONSISTENCY_PER_DB, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::LOAD_BALANCED_DATA_CONSISTENCIES, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Class Method Details

.perform_failure(job, message, exception) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/workers/projects/import_export/parallel_project_export_worker.rb', line 40

def self.perform_failure(job, message, exception)
  export_job = ProjectExportJob.find_by(id: job['args'].first) # rubocop:disable CodeReuse/ActiveRecord -- No suitable finder
  return unless export_job

  export_job.fail_op!
  project = export_job.project

  log_payload = {
    message: 'Parallel project export error',
    export_error: message,
    project_export_job_id: export_job.id,
    project_name: project.name,
    project_id: project.id
  }

  Gitlab::ExceptionLogFormatter.format!(exception, log_payload)
  Gitlab::Export::Logger.error(log_payload)
end

Instance Method Details

#perform(project_export_job_id, user_id, after_export_strategy = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/workers/projects/import_export/parallel_project_export_worker.rb', line 59

def perform(project_export_job_id, user_id, after_export_strategy = {})
  export_job = ProjectExportJob.find(project_export_job_id)

  return if export_job.finished?

  export_job.update_attribute(:jid, jid)
  current_user = User.find(user_id)
  after_export = build!(after_export_strategy)

  export_service = ::Projects::ImportExport::ParallelExportService.new(export_job, current_user, after_export)
  export_service.execute

  export_job.finish!
rescue ::Import::AfterExportStrategies::AfterExportStrategyBuilder::StrategyNotFoundError
  export_job.fail_op!
end