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

Fix web console for AWS, GCE and enable for RHOS #15901

Merged

Conversation

bmclaughlin
Copy link
Contributor

@bmclaughlin bmclaughlin commented Aug 29, 2017

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

Copy link
Contributor

@petervo petervo left a 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

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

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

nil
else
ext_management_system.zone.remote_cockpit_ws_miq_server
end
Copy link
Member

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)

nil
else
ext_management_system.zone.remote_cockpit_ws_miq_server
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy/paste code

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy/paste code

ipaddresses.find { |ip| IPAddr.new(ip).ipv4? }
if %w(amazon google).include?(vendor.downcase)
public_address
elsif %w(openstack).include?(vendor.downcase)
Copy link
Member

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.

@Fryguy
Copy link
Member

Fryguy commented Aug 30, 2017

@jrafanie Please also review.

@bmclaughlin bmclaughlin force-pushed the enable-cockpit-for-cloud-providers branch 3 times, most recently from 1c81061 to 8f1cca0 Compare August 30, 2017 18:01
@bmclaughlin
Copy link
Contributor Author

bmclaughlin commented Aug 30, 2017

@chessbyte @Fryguy @jrafanie @petervo, changes made per reviews, thanks! Ready for another round.

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') }
Copy link
Contributor

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.

Copy link
Contributor Author

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)

Copy link
Contributor

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

Copy link
Member

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') }

Copy link
Contributor Author

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!

Copy link
Member

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.

@miq-bot
Copy link
Member

miq-bot commented Sep 1, 2017

This pull request is not mergeable. Please rebase and repush.

@bmclaughlin bmclaughlin force-pushed the enable-cockpit-for-cloud-providers branch from 9a1dcc2 to 47bcea1 Compare September 1, 2017 17:15
@miq-bot
Copy link
Member

miq-bot commented Sep 1, 2017

Checked commits bmclaughlin/manageiq@0ade159~...47bcea1 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks fine. 🍪

@h-kataria
Copy link
Contributor

verified fix in UI

@jrafanie
Copy link
Member

jrafanie commented Sep 1, 2017

LGTM, @petervo's test concern has been addressed, merging so we can merge the UI PR.

@jrafanie jrafanie merged commit 24add7e into ManageIQ:master Sep 1, 2017
@jrafanie jrafanie added this to the Sprint 68 Ending Sep 4, 2017 milestone Sep 1, 2017
@bmclaughlin bmclaughlin deleted the enable-cockpit-for-cloud-providers branch September 1, 2017 19:59
@simaishi
Copy link
Contributor

@bmclaughlin I assume fine/yes ?

@simaishi
Copy link
Contributor

@bmclaughlin ^ ping

@bmclaughlin
Copy link
Contributor Author

@simaishi yes, thank you.

@miq-bot add_label fine/yes

@bmclaughlin
Copy link
Contributor Author

@miq-bot remove_label fine/yes

This will require a Fine specific PR.

@simaishi
Copy link
Contributor

simaishi commented Dec 7, 2017

Backported to Fine via #16609

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.

None yet

8 participants