Class: HashedStorage::ProjectMigrateWorker

Inherits:
BaseWorker
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/hashed_storage/project_migrate_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY

Constants included from WorkerAttributes

WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Constants inherited from BaseWorker

BaseWorker::LEASE_KEY_SEGMENT, BaseWorker::LEASE_TIMEOUT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_key, #lease_release?, #lease_timeout, #log_error, #release_lease, #renew_lease!, #try_obtain_lease

Instance Attribute Details

#project_idObject (readonly)

Returns the value of attribute project_id


10
11
12
# File 'app/workers/hashed_storage/project_migrate_worker.rb', line 10

def project_id
  @project_id
end

Instance Method Details

#perform(project_id, old_disk_path = nil) ⇒ Object

rubocop: disable CodeReuse/ActiveRecord


13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/workers/hashed_storage/project_migrate_worker.rb', line 13

def perform(project_id, old_disk_path = nil)
  @project_id = project_id # we need to set this in order to create the lease_key

  try_obtain_lease do
    project = Project.without_deleted.find_by(id: project_id)
    break unless project && project.storage_upgradable?

    old_disk_path ||= Storage::LegacyProject.new(project).disk_path

    ::Projects::HashedStorage::MigrationService.new(project, old_disk_path, logger: logger).execute
  end
end