-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #36716 - Add task to fix candlepin DB #10740
base: master
Are you sure you want to change the base?
Conversation
Issues: #36716 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need a Redmine issue in the correct project. I also don't feel fully qualified to review, so just some more superficial things I noticed.
|
||
# find_missing associations | ||
Katello::Resources::Candlepin::Product.all(owner['key']).each do |cp_product| | ||
katello_product = Katello::Product.find_by_cp_id(cp_product['id'], Organization.find_by(label: owner['key'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this will be cached, but I'd pull the org bit out of the loop. At line 8 you already have label = owner['key']
so I'd add it after that.
content_in_cp = cp_product['productContent'].length | ||
content_in_katello = katello_product.contents.count | ||
logger.debug("Product has #{content_in_cp} content entries in Candlepin and #{content_in_katello} in Katello") | ||
if content_in_cp != content_in_katello |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's a mismatch that where one has X & Y and the other has X & Z this will not fix it. If Katello has a superset of Candlepin then it will always show up. Would it make sense to always compare the two and sync them, regardless of the number?
This is doing similar things than https://github.com/ATIX-AG/orcharhino-scripts/tree/main/find_missing_candlepin_product_contents
This rake-task tries to fix the Candlepin Product-Content associations. It might be that this does not fix all the issues that the above script will fix. But the rake-task will do it in a cleaner way ;-)