Class: ObjectStorage::MigrateUploadsWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker, Report, ObjectStorageQueue
Defined in:
app/workers/object_storage/migrate_uploads_worker.rb

Defined Under Namespace

Modules: Report Classes: MigrationResult

Constant Summary collapse

SanityCheckError =
Class.new(StandardError)

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_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, 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 Report

#failures, #header, #report!

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

.enqueue!(uploads, to_store) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord



70
71
72
# File 'app/workers/object_storage/migrate_uploads_worker.rb', line 70

def self.enqueue!(uploads, to_store)
  perform_async(uploads.ids, to_store)
end

Instance Method Details

#perform(*args) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'app/workers/object_storage/migrate_uploads_worker.rb', line 76

def perform(*args)
  ids, to_store = retrieve_applicable_args!(args)

  @to_store = to_store

  uploads = Upload.preload(:model).where(id: ids)

  results = migrate(uploads)

  report!(results)
rescue SanityCheckError => e
  # do not retry: the job is insane
  Gitlab::AppLogger.warn "#{self.class}: Sanity check error (#{e.message})"
end