Commit b0e21891 authored by David Fernandez's avatar David Fernandez

Merge branch '356371-import-404' into 'master'

Skip container repository on import 404

See merge request gitlab-org/gitlab!83334
parents 0f4618e9 85c6a588
......@@ -36,7 +36,7 @@ class ContainerRepository < ApplicationRecord
enum status: { delete_scheduled: 0, delete_failed: 1 }
enum expiration_policy_cleanup_status: { cleanup_unscheduled: 0, cleanup_scheduled: 1, cleanup_unfinished: 2, cleanup_ongoing: 3 }
enum migration_skipped_reason: { not_in_plan: 0, too_many_retries: 1, too_many_tags: 2, root_namespace_in_deny_list: 3, migration_canceled: 4 }
enum migration_skipped_reason: { not_in_plan: 0, too_many_retries: 1, too_many_tags: 2, root_namespace_in_deny_list: 3, migration_canceled: 4, not_found: 5 }
delegate :client, :gitlab_api_client, to: :registry
......@@ -317,9 +317,16 @@ class ContainerRepository < ApplicationRecord
try_count = 0
begin
try_count += 1
return true if yield == :ok
case yield
when :ok
return true
when :not_found
skip_import(reason: :not_found)
else
abort_import
end
false
rescue TooManyImportsError
if try_count <= ::ContainerRegistry::Migration.start_max_retries
......
......@@ -1132,6 +1132,17 @@ RSpec.describe ContainerRepository, :aggregate_failures do
end
end
context 'not found response' do
let(:response) { :not_found }
it 'aborts the migration' do
expect(subject).to eq(false)
expect(container_repository).to be_import_skipped
expect(container_repository.reload.migration_skipped_reason).to eq('not_found')
end
end
context 'other response' do
let(:response) { :error }
......
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