Class: HashedStorage::ProjectRollbackWorker

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

Overview

rubocop:disable Scalability/IdempotentWorker

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_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, 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::Loggable

#build_structured_payload

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_taken_log_level, #lease_taken_message, #lease_timeout, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease

Instance Attribute Details

#project_idObject (readonly)

Returns the value of attribute project_id.



14
15
16
# File 'app/workers/hashed_storage/project_rollback_worker.rb', line 14

def project_id
  @project_id
end

Instance Method Details

#perform(project_id, old_disk_path = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/workers/hashed_storage/project_rollback_worker.rb', line 16

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

    old_disk_path ||= project.disk_path

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