From 8168a99e70605173c87308121fb6368e7f5d7a80 Mon Sep 17 00:00:00 2001 From: Samir Jha Date: Tue, 24 Oct 2023 15:00:21 +0000 Subject: [PATCH] Fixes #36857 - Run content count update on smart proxy after orphan cleanup --- app/lib/actions/katello/orphan_cleanup/remove_orphans.rb | 8 ++++++++ app/models/katello/concerns/smart_proxy_extensions.rb | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb b/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb index 5db8ae44699..4897ba2d832 100644 --- a/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb +++ b/app/lib/actions/katello/orphan_cleanup/remove_orphans.rb @@ -15,9 +15,17 @@ def plan(proxy) plan_action( Actions::Pulp3::Orchestration::OrphanCleanup::RemoveOrphans, proxy) + plan_self(:smart_proxy_id => proxy.id) end end end + + def finalize + smart_proxy = ::SmartProxy.unscoped.find(input[:smart_proxy_id]) + if smart_proxy.pulp_mirror? + ::ForemanTasks.async_task(::Actions::Katello::CapsuleContent::UpdateContentCounts, smart_proxy) + end + end end end end diff --git a/app/models/katello/concerns/smart_proxy_extensions.rb b/app/models/katello/concerns/smart_proxy_extensions.rb index c6c2e218f8e..54852441371 100644 --- a/app/models/katello/concerns/smart_proxy_extensions.rb +++ b/app/models/katello/concerns/smart_proxy_extensions.rb @@ -126,9 +126,8 @@ def update_content_counts! new_content_counts = { content_view_versions: {} } smart_proxy_helper = ::Katello::SmartProxyHelper.new(self) repos = smart_proxy_helper.repositories_available_to_capsule - return new_content_counts if repos.empty? - repos.each do |repo| + repos&.each do |repo| repo_mirror_service = repo.backend_service(self).with_mirror_adapter repo_content_counts = repo_mirror_service.latest_content_counts translated_counts = {metadata: {}, counts: {}}