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

Convert containers hawkular Endpoints port=nil to port=443 #98

Merged

Conversation

cben
Copy link
Contributor

@cben cben commented Oct 18, 2017

For a time (before ManageIQ/manageiq-ui-classic#1172), it was possible in UI to save containers provider with blank hawkular port, which got saved as port = nil.
Then it'd be impossible to edit the provider, as UI would crash:

manageiq containers providers port nil

On fine this was fixed by ManageIQ/manageiq-ui-classic#1565 adding special case in UI to tolerate nil.
On master, @AparnaKarve asked to not introduce special cases but do a migration.
Better late than never :-)

After investigating, @yaacov @moolitayer and me concluded such provider does connect to hawkular with port 443 (it builds a url without port, confirmed experimentally).
This migration normalizes such endpoints to port 443, works same but possible to edit in UI:

manageiq containers providers port 443

Tested by checking out fine-1, creating such provider, migrating all the way to master, it was still broken, and fixed by this migration. That's how I took above screenshots.
(in some cases such endpoints might have already been deleted by ManageIQ/manageiq#14990 migration. But not if hostname was autodetected from route => this is still sometimes needed.)

https://bugzilla.redhat.com/show_bug.cgi?id=1432070

@miq-bot add-label bug, data
@moolitayer @AparnaKarve please review

@moolitayer
Copy link

This migration normalizes such endpoints to port 0, still invalid but possible to edit in UI:

@cben what if we remove these endpoints altogether? that way we will not have failed authentication checks for an endpoint the user did not intend to create (event if the user does not go into the edit screen and disables metrics altogether)

@cben
Copy link
Contributor Author

cben commented Oct 23, 2017 via email

@yaacov
Copy link
Member

yaacov commented Oct 23, 2017

it was possible in UI to save containers provider with blank hawkular port, which got saved as port = nil.

a. This is fine, when port==nil we fallback to default port [1] , IMHO, if you want to migrate it, it should be to the default port.

b. In old versions of ManageIQ it was not possible to have no metrics, metrics where always on, and values fall-back to default url. port and token if not given explicitly. IMHO migration of missing endpoint should be to a default values, and to nil/0.

[1] https://github.com/ManageIQ/manageiq-providers-kubernetes/blob/master/app/models/manageiq/providers/kubernetes/container_manager/metrics_capture/hawkular_client_mixin.rb#L23

@Fryguy
Copy link
Member

Fryguy commented Oct 23, 2017

This looks good to me, I just want approval from @simon3z or @moolitayer before merge.

@simon3z
Copy link
Contributor

simon3z commented Oct 23, 2017

a. This is fine, when port==nil we fallback to default port [1] , IMHO, if you want to migrate it, it should be to the default port.

+1 for what @yaacov is suggesting here.
@cben what do you think?

b. In old versions of ManageIQ it was not possible to have no metrics, metrics where always on, and values fall-back to default url. port and token if not given explicitly. IMHO migration of missing endpoint should be to a default values, and to nil/0.

This one is actually sad, but I don't have any other good suggestions here.

@moolitayer
Copy link

These endpoints were only possible by actually going into Hawkular tab and clearing the port field, not sure it's "didn't intend to create" but never mind.

I thought this was a situation where the user had pressed add from the default endpoint tab
I'm good with @yaacov's suggestion in this case 👍
I was really surprised that fine screens allowed that... (I checked that master blocks it so I can sleep at night)

Deleting will result in UI showing "Metrics: disabled" in Provider Edit right?

Right

@cben cben changed the title Convert invalid containers hawkular Endpoints port=nil to port=0 [WIP] Convert invalid containers hawkular Endpoints port=nil to port=0 Oct 26, 2017
@miq-bot miq-bot added the wip label Oct 26, 2017
@cben cben force-pushed the fix_hawkular_endpoints_with_port_nil branch from cb07dca to 12df92c Compare October 30, 2017 13:17
For a time (before ManageIQ/manageiq-ui-classic#1172),
it was possible in UI to save containers provider without hawkular port
and then it'd be impossible to edit the provider as UI would crash.

AFAICT, such providers were effectively using port 443
(builds hawkular url https://<host>/ without port, HTTPS defaults to 443).
This migration normalizes such endpoints to port 443.

This makes it possible to edit in UI, without adding a nil special case.
We'll also be able to simplify hawkular connection code in future.

https://bugzilla.redhat.com/show_bug.cgi?id=1432070
@cben cben changed the title [WIP] Convert invalid containers hawkular Endpoints port=nil to port=0 Convert containers hawkular Endpoints port=nil to port=443 Oct 30, 2017
@cben
Copy link
Contributor Author

cben commented Oct 30, 2017

Confirmed experimentally, such endpoint is not broken as I originally thought but accesses https URL with port omitted, so it uses port 443. This is also what @yaacov @moolitayer and me saw in code.

=> Changed migration to set port 443. Dropped down migration, will not change 443 into nil.
Updated PR description and screenshot. PTAL.

@cben cben force-pushed the fix_hawkular_endpoints_with_port_nil branch from 12df92c to dd5ed57 Compare October 30, 2017 16:48
@miq-bot miq-bot removed the wip label Oct 30, 2017
@miq-bot
Copy link
Member

miq-bot commented Oct 30, 2017

Checked commit cben@dd5ed57 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 1 offense detected

db/migrate/20171030131403_fix_hawkular_endpoints_with_port_nil.rb

@cben
Copy link
Contributor Author

cben commented Oct 30, 2017

@yaacov PTAL

@yaacov
Copy link
Member

yaacov commented Oct 30, 2017

what about the update_all , don't you want to fix that first ?

o/w LGTM 👍

Copy link
Member

@yaacov yaacov left a comment

Choose a reason for hiding this comment

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

LGTM 👍

p.s.
unless you want to change update_all to something else

@cben
Copy link
Contributor Author

cben commented Oct 30, 2017

you mean miq-bot? IIUC we routinely ignore this advice in migrations, because we want migrations to be fast where feasible, and because the model stubs don't normally have validations anyway.

@Fryguy please review (nice to have but not blocker)

@Fryguy
Copy link
Member

Fryguy commented Oct 30, 2017

yeah, ignore the update_all warning (I keep forgetting to change that in the rubocop.yml)

@moolitayer You good with this?

@chessbyte
Copy link
Member

@simon3z @moolitayer can one of you guys approve this PR?

Copy link

@moolitayer moolitayer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@chessbyte chessbyte merged commit 207c35b into ManageIQ:master Oct 30, 2017
@chessbyte chessbyte added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 30, 2017
@chessbyte chessbyte self-assigned this Oct 30, 2017
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.

7 participants