Skip to content

Instantly share code, notes, and snippets.

@jlsherrill
Created December 13, 2021 21:47
Show Gist options
  • Save jlsherrill/29e0b18dbdda470b42cf4af110856d03 to your computer and use it in GitHub Desktop.
Save jlsherrill/29e0b18dbdda470b42cf4af110856d03 to your computer and use it in GitHub Desktop.
cleaning_up_missing_content.md

run:

foreman-rake console

Then inside the console run:

if Katello::Resources::Candlepin::Owner.all
  Katello::Content.all.each do |c| 
    ::Katello::Resources::Candlepin::Content.get(c.organization.label, c.cp_content_id)
  rescue RestClient::NotFound
    puts "Will Delete #{c.label}"
  end && []
end

This will print out the 'content' sets that will be deleted, for example:

Will Delete my-missing-repo
=> []

If this output looks okay, then run this to actually delete them:

if Katello::Resources::Candlepin::Owner.all
  Katello::Content.all.each do |c| 
    ::Katello::Resources::Candlepin::Content.get(c.organization.label, c.cp_content_id)
  rescue RestClient::NotFound
    puts "Deleting #{c.label}"
    c.delete
  end && []
end

Finally, re-run:

foreman-rake katello:correct_repositories

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment