From cb9a2dc98071660f5ff523f0ad3ce82eb2ee15f7 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Tue, 12 Sep 2023 14:20:54 -0400 Subject: [PATCH] Fixes #36538 - Don't delete manifests referenced by tags or manifest lists (#10711) (cherry picked from commit cfc586c01d735d5e822139eade23bfc8d589e1c9) --- app/lib/actions/katello/repository/remove_content.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/lib/actions/katello/repository/remove_content.rb b/app/lib/actions/katello/repository/remove_content.rb index 2182da12d79..a926c8e1cc7 100644 --- a/app/lib/actions/katello/repository/remove_content.rb +++ b/app/lib/actions/katello/repository/remove_content.rb @@ -12,7 +12,7 @@ def plan(repository, content_units, options = {}) unless repository.content_view.default? fail _("Can only remove content from within the Default Content View") end - + content_units = valid_docker_manifests_to_delete!(content_units) if (repository.docker? && content_units.first.class::CONTENT_TYPE == 'docker_manifest') action_subject(repository) content_unit_ids = content_units.map(&:id) @@ -58,6 +58,14 @@ def finalize end end + def valid_docker_manifests_to_delete!(content_units) + original_content_units = content_units + content_units = content_units.reject { |dm| dm.docker_tags.count > 0 || dm.docker_manifest_lists.count > 0 } + Rails.logger.warn("Docker Manifests with tags or manifest lists will be ignored; continuing...") if original_content_units.count != content_units.count + fail _("No docker manifests to delete after ignoring manifests with tags or manifest lists") if content_units.count == 0 + content_units + end + def humanized_name _("Remove Content") end