Commit 68bd8992 authored by Valery Sizov's avatar Valery Sizov

Handle invalid repositories in Docker Registry correctly

parent 22e4f0c6
---
title: 'Geo: Handle repositories in Docker Registry with no tags gracefully'
merge_request: 23022
author:
type: fixed
......@@ -55,10 +55,11 @@ module Geo
def primary_tags
@primary_tags ||= begin
tags = client.repository_tags(name)['tags']
return [] if tags.nil?
manifest = client.repository_tags(name)
tags.map do |tag|
return [] unless manifest && manifest['tags']
manifest['tags'].map do |tag|
{ name: tag, digest: client.repository_tag_digest(name, tag) }
end
end
......
......@@ -84,5 +84,20 @@ describe Geo::ContainerRepositorySync, :geo do
described_class.new(container_repository).execute
end
context 'when primary repository has no tags' do
it 'considers the primary repository empty and does not fail' do
stub_request(:get, "http://primary.registry.gitlab/v2/group/test/my_image/tags/list")
.with(
headers: { 'Authorization' => 'bearer pull-token' })
.to_return(
status: 200,
headers: { 'Content-Type' => 'application/json' })
expect(container_repository).to receive(:delete_tag_by_digest).with('sha256:aaaaa')
described_class.new(container_repository).execute
end
end
end
end
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