summaryrefslogtreecommitdiff
path: root/app/services/projects
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-27 00:06:23 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-27 00:06:23 +0000
commitbd8a202da68db8c61150d52e246997f04c329110 (patch)
tree27231f7ecf92696b90712510ea408fb7d1b6366b /app/services/projects
parent59a349817c0869e8e0d750884b34256ca4faefca (diff)
downloadgitlab-ce-bd8a202da68db8c61150d52e246997f04c329110.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/projects')
-rw-r--r--app/services/projects/container_repository/cleanup_tags_service.rb4
-rw-r--r--app/services/projects/container_repository/delete_tags_service.rb34
2 files changed, 21 insertions, 17 deletions
diff --git a/app/services/projects/container_repository/cleanup_tags_service.rb b/app/services/projects/container_repository/cleanup_tags_service.rb
index 1b880a7aab1..b995df12e56 100644
--- a/app/services/projects/container_repository/cleanup_tags_service.rb
+++ b/app/services/projects/container_repository/cleanup_tags_service.rb
@@ -26,13 +26,13 @@ module Projects
def delete_tags(tags_to_delete, tags_by_digest)
deleted_digests = group_by_digest(tags_to_delete).select do |digest, tags|
- delete_tag_digest(digest, tags, tags_by_digest[digest])
+ delete_tag_digest(tags, tags_by_digest[digest])
end
deleted_digests.values.flatten
end
- def delete_tag_digest(digest, tags, other_tags)
+ def delete_tag_digest(tags, other_tags)
# Issue: https://gitlab.com/gitlab-org/gitlab-foss/issues/21405
# we have to remove all tags due
# to Docker Distribution bug unable
diff --git a/app/services/projects/container_repository/delete_tags_service.rb b/app/services/projects/container_repository/delete_tags_service.rb
index 48bd9394dc5..af58d3780b0 100644
--- a/app/services/projects/container_repository/delete_tags_service.rb
+++ b/app/services/projects/container_repository/delete_tags_service.rb
@@ -24,32 +24,36 @@ module Projects
dummy_manifest = container_repository.client.generate_empty_manifest(container_repository.path)
return error('could not generate manifest') if dummy_manifest.nil?
- # update the manifests of the tags with the new dummy image
- deleted_tags = []
- tag_digests = []
+ deleted_tags = replace_tag_manifests(container_repository, dummy_manifest, tag_names)
+
+ # Deletes the dummy image
+ # All created tag digests are the same since they all have the same dummy image.
+ # a single delete is sufficient to remove all tags with it
+ if deleted_tags.any? && container_repository.delete_tag_by_digest(deleted_tags.values.first)
+ success(deleted: deleted_tags.keys)
+ else
+ error('could not delete tags')
+ end
+ end
+
+ # update the manifests of the tags with the new dummy image
+ def replace_tag_manifests(container_repository, dummy_manifest, tag_names)
+ deleted_tags = {}
tag_names.each do |name|
digest = container_repository.client.put_tag(container_repository.path, name, dummy_manifest)
next unless digest
- deleted_tags << name
- tag_digests << digest
+ deleted_tags[name] = digest
end
# make sure the digests are the same (it should always be)
- tag_digests.uniq!
+ digests = deleted_tags.values.uniq
# rubocop: disable CodeReuse/ActiveRecord
- Gitlab::Sentry.track_exception(ArgumentError.new('multiple tag digests')) if tag_digests.many?
+ Gitlab::Sentry.track_exception(ArgumentError.new('multiple tag digests')) if digests.many?
- # Deletes the dummy image
- # All created tag digests are the same since they all have the same dummy image.
- # a single delete is sufficient to remove all tags with it
- if tag_digests.any? && container_repository.delete_tag_by_digest(tag_digests.first)
- success(deleted: deleted_tags)
- else
- error('could not delete tags')
- end
+ deleted_tags
end
end
end