1# frozen_string_literal: true 2 3module HashedStorage 4 class ProjectMigrateWorker < BaseWorker # rubocop:disable Scalability/IdempotentWorker 5 include ApplicationWorker 6 7 data_consistency :always 8 9 sidekiq_options retry: 3 10 11 queue_namespace :hashed_storage 12 loggable_arguments 1 13 14 # https://gitlab.com/gitlab-org/gitlab/-/issues/340629 15 tags :needs_own_queue 16 17 attr_reader :project_id 18 19 def perform(project_id, old_disk_path = nil) 20 @project_id = project_id # we need to set this in order to create the lease_key 21 22 try_obtain_lease do 23 project = Project.without_deleted.find_by_id(project_id) 24 break unless project && project.storage_upgradable? 25 26 old_disk_path ||= Storage::LegacyProject.new(project).disk_path 27 28 ::Projects::HashedStorage::MigrationService.new(project, old_disk_path, logger: logger).execute 29 end 30 end 31 end 32end 33