-
Notifications
You must be signed in to change notification settings - Fork 289
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 #28894 - load the pools from AR database instead of Candlepin #8550
Conversation
Can one of the admins verify this patch? |
[ok to test] |
@matt8754 how is a good way to test this, how many subs/hosts do you need? |
This is a good change. I can see an unnecessary call being made to candlepin before:
after:
I verified that this does not affect the output of the API. |
@@ -5,8 +5,7 @@ module Glue::Candlepin::CandlepinObject | |||
module ClassMethods | |||
def get_for_organization(organization) | |||
# returns objects from AR database rather than candlepin data | |||
pool_ids = self.get_for_owner(organization.label).collect { |x| x['id'] } | |||
self.where(:cp_id => pool_ids) | |||
self.where(:organization => organization) |
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.
It looks like this method is only used in one place, and I don't think it makes sense to have a separate method anymore since it only has a single where
clause.
Let's remove this method and update subscriptions_controller.rb:
+++ b/app/controllers/katello/api/v2/subscriptions_controller.rb
@@ -65,7 +65,7 @@ module Katello
return available_for_activation_key if params[:available_for] == "activation_key"
collection = Pool.readable
collection = collection.where(:unmapped_guest => false)
- collection = collection.get_for_organization(Organization.find(params[:organization_id])) if params[:organization_id]
+ collection = collection.where(organization: Organization.find(params[:organization_id])) if params[:organization_id]
collection = collection.for_activation_key(@activation_key) if params[:activation_key_id]
collection
end
I think the tests will need to be updated. You can verify locally with:
ktest ./test/controllers/api/v2/subscriptions_controller_test.rb
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.
Thanks, Jonathon. This is exactly what I came out first. However, I was worried about breaking the tests as they call get_for_organization. I'll take a look further for that.
Ideally, it would be good to have 3K+ hypervisors with the VDC sub attached. This would match the customer's env from which the issue happens. |
In case there is a large list of pools, this will improve the speed when loading up the subscription page.
[test 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.
ACK. Thank you @matt8754 - we appreciate your contribution.
In case there is a large list of pools, this will improve the speed when loading up the subscription page.