Commit 6c3056af authored by Kerri Miller's avatar Kerri Miller

Merge branch '221296/skip_orphaned_pool_repositories_on_restore' into 'master'

Skip orphaned pool repositories on restore

See merge request gitlab-org/gitlab!54112
parents 91034f00 fe792ee4
---
title: Skip orphaned pool repositories on restore
merge_request: 54112
author:
type: fixed
......@@ -201,7 +201,12 @@ module Backup
PoolRepository.includes(:source_project).find_each do |pool|
progress.puts " - Object pool #{pool.disk_path}..."
pool.source_project ||= pool.member_projects.first.root_of_fork_network
pool.source_project ||= pool.member_projects.first&.root_of_fork_network
unless pool.source_project
progress.puts " - Object pool #{pool.disk_path}... " + "[SKIPPED]".color(:cyan)
next
end
pool.state = 'none'
pool.save
......
......@@ -230,6 +230,16 @@ RSpec.describe Backup::Repositories do
expect(pool_repository).not_to be_failed
expect(pool_repository.object_pool.exists?).to be(true)
end
it 'skips pools with no source project, :sidekiq_might_not_need_inline' do
pool_repository = create(:pool_repository, state: :obsolete)
pool_repository.update_column(:source_project_id, nil)
subject.restore
pool_repository.reload
expect(pool_repository).to be_obsolete
end
end
it 'cleans existing repositories' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment