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 #20057 - fix duplicate akey repo sets #6973
Conversation
Issues: #20057 |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
provider.products.each do |product| | ||
product.displayable_product_contents.each do |prod_content| | ||
selected_contents = product_content.select { |product_content| product_content.product_id == product.id }.select(&:displayable?) |
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.
Shadowing outer local variable - product_content.
@@ -38,6 +38,32 @@ def content_access_mode | |||
self.owner_details['contentAccessMode'] | |||
end | |||
|
|||
def enabled_product_content(for_repositories) | |||
return [] if for_repositories && for_repositories.empty? |
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.
for_repositories.blank?
def enabled_product_content(for_repositories) | ||
return [] if for_repositories && for_repositories.empty? | ||
repositories = for_repositories.select([:product_id, :content_id]).to_a | ||
content_ids = repositories.map(&:content_id) |
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 you are just using content_id from here then why do you need [:product_id, :content_id]
end | ||
|
||
def filtered_product_content | ||
cp_products = Katello::Resources::Candlepin::Product.all(Organization.first.label, [:id, :productContent]) |
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 dont remember exactly how this works. Can you enlighten me on why you are getting all products from Organization.first as opposed to current org?
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.
that should be self ;) /me thinks i copy and pasted from my console
@parthaa updated |
@@ -399,6 +399,10 @@ def import(organization_name, path_to_file, options) | |||
self.post(path, {:import => File.new(path_to_file, 'rb')}, self.default_headers.except('content-type')) | |||
end | |||
|
|||
def product_content(organization_name) | |||
Product.all(organization_name, [:id, :productContent]) |
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.
This is no chance this would be confused with '::Katello::Product' right ?
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 don't think so, we do things in similar places in this file
Code looks good to me. But the "show all " in the repository sets page seems to show me non yum repos also (like I saw paths pointing to ostree and docker). In the master version the docker ones were getting ignored. And I don't know if ostree stuff can be overridden. So might not not want to include that, |
app/models/katello/activation_key.rb
Outdated
end | ||
content.uniq | ||
considered_products = content_access_mode_all ? all_products : self.products | ||
repositories = Katello::Repository.where(:product_id => considered_products) |
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.
Might need to limit this to type yum.
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.
fixed by using .subscribable
I definitely notice the perf improvements definitely and no dupes. Nice work. Address the above comment and should be good to go. |
to_return = [] | ||
|
||
cp_products.each do |product_hash| | ||
product = ::Katello::Product.find_by(:cp_id => product_hash['id']) |
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.
cp_id is not org safe!
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.
- product = ::Katello::Product.find_by(:cp_id => product_hash['id'])
+ product = ::Katello::Product.find_by(:organization_id => self.id, :cp_id => product_hash['id'])
Not to overcomplicate this PR but can you check if the content hosts could use this logic for subs and repo sets... My guess is they are suffering from the same ailments |
Rh Repos page
|
1b3519d
to
5330a4d
Compare
Updated to fix multi-org issue, added to content host repo sets listing, and sped it up even more by using more specific includes on the candlepin request. |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
Updated to move to a service as much as i could. let me know if you like it better |
content = pcf.product_content | ||
|
||
overrides = @activation_key.content_overrides | ||
content.map! { |pc| ProductContentPresenter.new(pc, overrides) } |
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 like the refactoring but I think you could DRY it up further by adding overrides logic to the Finder and make him return ProductContentPresenter... That would mean we can use the same logic for both AK and CH
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
@parthaa updated! |
APJ |
this fixes duplicate repository sets from being returned when listing them for an activation key. In addition this improves performance by using a single api call for all product content in the org, as well as using a presenter to only fetch the activation key overrides once, instead of once per product content. In addition this updates the redhat repos page to use this new content fetching method to speed up that page as well. Move product content to a service
this fixes duplicate repository sets from being returned
when listing them for an activation key. In addition this improves performance
by using a single api call for all product content in the org,
as well as using a presenter to only fetch the activation key overrides
once, instead of once per product content.
In addition this updates the redhat repos page to use this new
content fetching method to speed up that page as well.