Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

m-bucher
Copy link
Contributor

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 ;-)

@theforeman-bot
Copy link

Issues: #36716

Copy link
Member

@ekohl ekohl left a 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']))
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

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?

Copy link
Contributor Author

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 😉 )

@chris1984
Copy link
Member

@m-bucher Did you want to revisit this at all? I have a customer reproducer I think still attached to the downstream Bugzilla.

@m-bucher
Copy link
Contributor Author

@chris1984 I was unsure, if this really does the same as the original-script (where everything was done within the DBs).
Since I had no more system having that issue I also was not able to verify that it fixes the real-life issue instead of just the manipulated-a-working-system-for-testing issue.

If you are able to verify the function of this PR, I will be delighted to revisit it, so we can finally merge it 😃

@m-bucher m-bucher force-pushed the add_candlepin_product_content_fix branch 2 times, most recently from 1bc2fec to f1ebb8e Compare July 29, 2024 10:06
@m-bucher
Copy link
Contributor Author

m-bucher commented Aug 2, 2024

You'll need a Redmine issue in the correct project.

Done 😄

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

Successfully merging this pull request may close these issues.

4 participants