-
Notifications
You must be signed in to change notification settings - Fork 297
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 #36928 - (sorta) handle load balanced smart proxies when registering hosts #10804
Fixes #36928 - (sorta) handle load balanced smart proxies when registering hosts #10804
Conversation
app/controllers/katello/api/rhsm/candlepin_proxies_controller.rb
Outdated
Show resolved
Hide resolved
|
||
def registering_thru_load_balancer?(hostname) | ||
# If the request doesn't come from any known smart proxy, it came from a load balancer. | ||
get_content_source_id(hostname).nil? |
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.
Is this a safe assumption? Could you instead check all smart-proxies registration URLs and see if they match the hostname?
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.
Yeah, that would be better. At this point I should probably just change it not to use the header, too..
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.
Updated to check if hostname is a known load balancer. 👍
@ekohl given you had a lot of opinion around the implementation where we used registration_url to indicate a load-balancer rather than introducing a dedicated parameter to indicate load-balancing I think you should review this. |
e4139f2
to
4245df0
Compare
4245df0
to
46a24de
Compare
Added some tests; marking ready for review. |
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 have a setup with load balanced capsules so I can't really test this, but in general this reads like it should do the trick, assuming my mental model of the whole thing is correct.
53f81be
to
a865133
Compare
@adamruzicka @jeremylenz I have done some testings on a Sat\Cap 6.15 + Haproxy setup with two RHEL clients .. The results are looking great. Details can be found in the private comment 11 of the main Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=2240956 |
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.
After poking around the rails console on a load-balanced set up, this is looking good to me! Credit to @sayan3296 for the setup.
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.
Just the log statements need cleaning then this should be good to merge.
a865133
to
ed31c3b
Compare
ed31c3b
to
4254bde
Compare
4254bde
to
a0ddb54
Compare
@@ -6,6 +6,7 @@ | |||
require "oauth" | |||
require "gettext_i18n_rails" | |||
require "foreman-tasks" | |||
require "foreman_remote_execution" |
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.
Given
Line 37 in 6d8d3ca
gem.add_dependency "foreman_remote_execution", ">= 7.1.0" |
I am rather confident we never have a Katello install w/o REX.
But at the same time it indicates that the way we load stuff differs so heavily in prod/dev/test, that things go weird.
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.
https://community.theforeman.org/t/requiring-rex-in-katello-4-0/19582 indicates that dep is here to stay :)
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.
Tests are good, so ACK!
…ering hosts (Katello#10804) * Fixes #36928 - (sorta) handle load balanced smart proxies when registering hosts (cherry picked from commit 27e9e68)
What are the changes introduced in this pull request?
As we know, currently
--serverurl
parameter tosubscription-manager
, which contacts the server you specify for registration.registered_through
value is set to the hostname of the load balancer, which is not a smart proxy.registered_through
value won't match the name of any known Smart Proxy.registered_through
Smart Proxy to be listed as[]
, breaking Remote Execution on certain setups depending on your settings.With this change, some methods are added to attempt to surmise
In the case of smart proxies, this is determined by comparing the smart proxy's
registration_url
hostname with itsurl
hostname. If they're different, we assume it's a load balanced setup.In the case of host registration, this is still determined (for now) by comparing the request headers to known smart proxy names.
Additionally, we add the following behavior changes when a host is registered through a load balancer:
registered_through
to all known smart proxies behind the load balancernil
, becausenil
assumes the host has access to all library content, when actually it only has access to content synced by its smart proxy(ies).Considerations taken when implementing this change?
Ideally a load balancer would be a Foreman entity which holds a list of smart proxies, and the user would explicitly tell us which smart proxies go with which load balancer, and we could just refer to that. But that would require a rather large effort, so this is being offered as somewhat of a stopgap to fix the immediate bug. None of the changes here preclude a more proper feature design from happening later.
What are the testing steps for this pull request?
I actually haven't tested this with a load balancer yet. You may leave my hard-codings in, or ideally set up an actual load balancer and take them out.