-
Notifications
You must be signed in to change notification settings - Fork 897
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
Fix web console for AWS, GCE and enable for RHOS #15901
Fix web console for AWS, GCE and enable for RHOS #15901
Conversation
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.
Mostly looks good, just one testing related regression
app/models/vm/operations.rb
Outdated
MiqCockpitWsWorker.fetch_worker_settings_from_server(miq_server), | ||
ipv4_address || ipaddresses.first) | ||
miq_server.nil? ? nil : MiqCockpitWsWorker.fetch_worker_settings_from_server(miq_server), | ||
ipv4_address || ipaddresses.first).to_s |
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.
the to_s here breaks tests
app/models/container_node.rb
Outdated
nil | ||
else | ||
ext_management_system.zone.remote_cockpit_ws_miq_server | ||
end |
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.
how about the following:
miq_server = ext_management_system.try(:zone).try(:remote_cockpit_ws_miq_server)
app/models/vm/operations.rb
Outdated
nil | ||
else | ||
ext_management_system.zone.remote_cockpit_ws_miq_server | ||
end |
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.
copy/paste code
app/models/vm/operations.rb
Outdated
MiqCockpit::WS.url(miq_server, | ||
MiqCockpitWsWorker.fetch_worker_settings_from_server(miq_server), | ||
ipv4_address || ipaddresses.first) | ||
miq_server.nil? ? nil : MiqCockpitWsWorker.fetch_worker_settings_from_server(miq_server), |
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.
copy/paste code
app/models/vm/operations.rb
Outdated
ipaddresses.find { |ip| IPAddr.new(ip).ipv4? } | ||
if %w(amazon google).include?(vendor.downcase) | ||
public_address | ||
elsif %w(openstack).include?(vendor.downcase) |
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.
Please no provider specific code in the base module. This should be handled via provider overrides.
@jrafanie Please also review. |
1c81061
to
8f1cca0
Compare
@chessbyte @Fryguy @jrafanie @petervo, changes made per reviews, thanks! Ready for another round. |
app/models/vm/operations.rb
Outdated
end | ||
|
||
def ipv4_address | ||
ipaddresses.find { |ip| IPAddr.new(ip).ipv4? } | ||
return public_address unless public_address.nil? | ||
ipaddresses.find { |ip| IPAddr.new(ip).ipv4? unless ip.starts_with?('192') } |
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 robust enough? I think i've seen 10.x IPs on amazon.
Does the VM have any notion if it's hostname is public or not? If it did that might make this simpler.
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.
@petervo Line 25 allows for 10.x ip addresses in my testing (192.x addresses have been unreachable). This solution will even try 192.x ip addresses (unreachable in my testing) in the case the ipv4_address
method returns nil in the cockpit_url
method.
I'm trying for the lowest common denominator and have verified that we can connect to Amazon, GCE, RHOS, RHEV and VMware virtual machines successfully.
If this isn't robust enough for more complex Amazon or , it can be addressed via provider overrides in a follow-up PR per @Fryguy's comment above [1].
[1] #15901 (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 meant 10.x private IPs which in theory would not be reachable.
But I agree this covers most use-cases and like you said it can always be adjusted later if needed
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.
So, this is trying 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 if they're the only ipaddresses on the system?
Can this be:
ipaddresses.find { |ip| IPAddr.new(ip).ipv4? && !ip.starts_with?('192') }
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.
@jrafanie, Yes, the ipv4_address
tries for the most common scenarios (public to private) and falls back to ipaddresses.first
if nothing matches. All 3 ip addresses above would be tried on their own (experienced while debugging and testing this PR...).
Updated the code per your request above, thanks!
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.
Other than going to some remote system to ask what your public ip address is, I'm not sure what else we can do. I'm good with the changes as it seems to cover most of the bases, until it doesn't and we'll worry about it then.
This pull request is not mergeable. Please rebase and repush. |
9a1dcc2
to
47bcea1
Compare
Checked commits bmclaughlin/manageiq@0ade159~...47bcea1 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
verified fix in UI |
LGTM, @petervo's test concern has been addressed, merging so we can merge the UI PR. |
@bmclaughlin I assume |
@bmclaughlin ^ ping |
@miq-bot remove_label fine/yes This will require a Fine specific PR. |
Backported to Fine via #16609 |
This fixes Cockpit console from attempting to connect to AWS and GCE on private instead of public ip addresses and enables Cockpit console for RHOS.
Needs to be reviewed at the same time as ManageIQ/manageiq-ui-classic#2039.
@miq-bot add_labels bug, core, ui
https://bugzilla.redhat.com/show_bug.cgi?id=1450109
https://bugzilla.redhat.com/show_bug.cgi?id=1451655