Skip to content

Commit

Permalink
Fixes #36303 - disable scopes on CV publish errata calc (#10517)
Browse files Browse the repository at this point in the history
Disable user and location scopes when calculating errata
applicability after publishing a content view.

This also fix false positive orphaned content facet detection.
  • Loading branch information
hao-yu authored Apr 14, 2023
1 parent eeb05c6 commit a331781
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
11 changes: 2 additions & 9 deletions app/lib/actions/katello/content_view/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,8 @@ def finalize
version.add_applied_filters!
# update errata applicability counts for all hosts in the CV & Library
unless input[:skip_promotion]
content_view = ::Katello::ContentView.find(input[:content_view_id])
lifecycle_environment = ::Katello::KTEnvironment.find(input[:environment_id])
::Katello::Host::ContentFacet.in_content_views_and_environments(
content_views: [content_view],
lifecycle_environments: [lifecycle_environment]
).each do |facet|
facet.update_applicability_counts
facet.update_errata_status
end
environment = ::Katello::KTEnvironment.find(input[:environment_id])
::Katello::ContentView.find(input[:content_view_id]).update_host_statuses(environment)
end

history = ::Katello::ContentViewHistory.find(input[:history_id])
Expand Down
16 changes: 10 additions & 6 deletions app/models/katello/content_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,16 @@ def check_composite_action_allowed!(env)
end

def check_orphaned_content_facets!(environments: [])
::Katello::Host::ContentFacet.in_content_views_and_environments(
content_views: [self],
lifecycle_environments: environments
).each do |facet|
unless facet.host
fail _("Orphaned content facets for deleted hosts exist for the content view and environment. Please run rake task : katello:clean_orphaned_facets and try again!")
Location.no_taxonomy_scope do
User.as_anonymous_admin do
::Katello::Host::ContentFacet.in_content_views_and_environments(
content_views: [self],
lifecycle_environments: environments
).each do |facet|
unless facet.host
fail _("Orphaned content facets for deleted hosts exist for the content view and environment. Please run rake task : katello:clean_orphaned_facets and try again!")
end
end
end
end
end
Expand Down

0 comments on commit a331781

Please sign in to comment.