Commit fe792ee4 authored by Alex Ives's avatar Alex Ives

Skip orphaned pool repositories on restore

- Instead of scheduling them, leave them in their
  orphaned state.
- Prevents restore process from breaking when they're
  encountered.

Relates to https://gitlab.com/gitlab-org/gitlab/issues/221296
parent b1a936ba
---
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