Sha256: c56ad99bdbd4b9e6c36e31e967e9654b8428294edbd21824dc86572b345a75bf

Contents?: true

Size: 1.7 KB

Versions: 29

Compression:

Stored size: 1.7 KB

Contents

namespace :katello do
  namespace :upgrades do
    namespace '4.9' do
      desc "Clean orphaned filter rules that cause Pulp copy errors during content view publishing"
      task :clean_orphaned_filter_rules => ['environment'] do
        module_stream_count = 0
        erratum_count = 0
        package_group_count = 0

        ::Katello::ContentViewModuleStreamFilterRule.all.each do |rule|
          # Delete if rule exists in a CV that does not have the matching module stream in its repositories
          content_view = rule.filter.content_view
          unless ::Katello::ModuleStream.in_repositories(content_view.repositories)&.pluck(:id)&.include?(rule.module_stream_id)
            rule.delete
            module_stream_count += 1
          end
        end
        puts "#{module_stream_count} orphaned content view module stream filter rules were deleted."

        ::Katello::ContentViewErratumFilterRule.all.each do |rule|
          content_view = rule.filter.content_view
          unless ::Katello::Erratum.in_repositories(content_view.repositories)&.pluck(:errata_id)&.include?(rule.errata_id)
            rule.delete
            erratum_count += 1
          end
        end
        puts "#{erratum_count} orphaned content view erratum filter rules were deleted."

        ::Katello::ContentViewPackageGroupFilterRule.all.each do |rule|
          content_view = rule.filter.content_view
          unless ::Katello::PackageGroup.in_repositories(content_view.repositories)&.pluck(:pulp_id)&.include?(rule.uuid)
            rule.delete
            package_group_count += 1
          end
        end
        puts "#{package_group_count} orphaned content view package group filter rules were deleted."
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
katello-4.14.2 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.15.0 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.15.0.rc2 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.15.0.rc1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.14.1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.14.0 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.14.0.rc3 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.14.0.rc2 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.14.0.rc1.1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.14.0.rc1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.13.1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.13.0 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.12.1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.13.0.rc1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.12.0 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.12.0.rc3 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.12.0.rc2 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.12.0.rc1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.11.1 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake
katello-4.11.0 lib/katello/tasks/upgrades/4.9/clean_orphaned_filter_rules.rake