-
Notifications
You must be signed in to change notification settings - Fork 293
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.
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.
I have moved the Organization.find_by()
out of the loop. It might even be possible to split it up to get the Products for that organization and only here do the filter for cp_id
.
I do not know if this would make it faster though 🤔
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?
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.
I must admit my knowledge on the inner workings here are limited.
So I am happy to change things here. Maybe someone from the core-Katello team can give feedback (@chris1984 😉 )
@m-bucher Did you want to revisit this at all? I have a customer reproducer I think still attached to the downstream Bugzilla. |
@chris1984 I was unsure, if this really does the same as the original-script (where everything was done within the DBs). If you are able to verify the function of this PR, I will be delighted to revisit it, so we can finally merge it 😃 |
1bc2fec
to
f1ebb8e
Compare
f1ebb8e
to
9a31cf8
Compare
Done 😄 |
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 ;-)