2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module HashedStorage
|
2020-04-08 14:13:33 +05:30
|
|
|
class ProjectMigrateWorker < BaseWorker # rubocop:disable Scalability/IdempotentWorker
|
2019-07-07 11:18:12 +05:30
|
|
|
include ApplicationWorker
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
sidekiq_options retry: 3
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
queue_namespace :hashed_storage
|
2020-06-23 00:09:42 +05:30
|
|
|
loggable_arguments 1
|
2021-06-08 01:23:25 +05:30
|
|
|
tags :exclude_from_gitlab_com
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
attr_reader :project_id
|
|
|
|
|
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
|
|
|
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)
|
2020-01-01 13:55:28 +05:30
|
|
|
break unless project && project.storage_upgradable?
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
old_disk_path ||= Storage::LegacyProject.new(project).disk_path
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
::Projects::HashedStorage::MigrationService.new(project, old_disk_path, logger: logger).execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
|
|
|
end
|
|
|
|
end
|