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 adding Kubernetes provider #314

Merged

Conversation

cben
Copy link
Contributor

@cben cben commented Feb 7, 2017

Reported by @evertmulder yesterday, also encountered by @AparnaKarve and by me today.
If get_hostname_from_routes causes exception, you can't [Validate] nor [Add]/[Save] the provider.
This was especially a problem for Kubernetes, apparently made it impossible to create Kubernetes provider via UI.
(Not sure if recent #265 made it more exception-prone? I can confirm the guessing does work on Openshift.)

  • Skipping the guessing entirely for Kubernetes because Routes are an Openshift concept.

IIUC this functionality should be best-effort, failure to guess the hawkular route should not stop block user (if they can make validation happy otherwise).

(The error also doesn't get to UI, the 500 JS page is not the JSON the UI was looking for. That could be improved but in this case I believe errors are not interesting to user anyway.)

@simon3z Please review.

@miq-bot add-label providers/containers, bug

@simon3z
Copy link
Contributor

simon3z commented Feb 9, 2017

@enoodle @moolitayer please review

@simon3z
Copy link
Contributor

simon3z commented Feb 9, 2017

@miq-bot assign cben

@cben
Copy link
Contributor Author

cben commented Feb 12, 2017

@yaacov welcome back, can you review?

@yaacov
Copy link
Member

yaacov commented Feb 12, 2017

LGTM 👍

@cben cben changed the title get_hostname_from_routes: skip on Kubernetes, catch exceptions Fix adding Kubernetes provider Feb 12, 2017
@cben
Copy link
Contributor Author

cben commented Feb 12, 2017

Confirmed, it's currently impossible to add Kubernetes provider via UI!
Editing an existing one is probably impossible too.

Checking euwe...

Copy link

@enoodle enoodle left a comment

Choose a reason for hiding this comment

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

LGTM, one comment though:

I know that we are not collecting them yet, but Kubernetes have introduced a new object called ingress that is a bit similar to Openshift Routes [1]. Maybe we can add a TODO here to remember to check with the ingress once we collect them (Possibly we will collect ingress under the route entity in ManageIQ)

[1]https://kubernetes.io/docs/user-guide/ingress/

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 👍

@cben
Copy link
Contributor Author

cben commented Feb 12, 2017 via email

@cben
Copy link
Contributor Author

cben commented Feb 12, 2017 via email

@simon3z
Copy link
Contributor

simon3z commented Feb 13, 2017

@cben please add tests

Routes are an Openshift concept, no such tning in Kubernetes API.
This should be best-effort, failure to get the hawkular route should not
prevent validating/saving the provider (if it otherwise passes).
@cben cben force-pushed the get_hostname_from_routes-KubeException branch from 65f1cde to 7b6fe36 Compare February 15, 2017 09:06
@miq-bot
Copy link
Member

miq-bot commented Feb 15, 2017

Checked commit cben@7b6fe36 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 2 offenses detected

spec/controllers/ems_common_controller_spec.rb

@cben
Copy link
Contributor Author

cben commented Feb 15, 2017

Added tests, @yaacov please review.

More integration than unit test, because I have hopes to refactor this route fetching to later point when the EMS is already built, and I don't want tests to depend on current interface.
The tests talking about "update" vs "adding" is a lie because they just test set_ems_record_vars. Ideally should do full post :button, :params => ... tests, for all new/edit X validate/hawk validate/save combinations, but out of scope for this PR.

@yaacov the tests call set_ems_record_vars twice on same object, in what I now split into test_setting_many_fields then test_setting_few_fields. You added the second call in
6c63ea7#diff-a3ccea15493bac675c667462322d3047R195
IIUC that never happens in real life — when creating every button click creates a new EMS instance, when editing [Validate] click does find_by_id_filtered but never saves the instance.
I tried splitting the 2nd call to work on fresh EMS instance but that failed 'valid-token' assertions assuming it survived from 1st call.
Is this deliberate?

Consciously ignoring Rubocop here. There are bigger issues with these tests but this is a step forward.

[close-cycling to kick travis, bower EINCOMPLETE]

@cben cben closed this Feb 15, 2017
@cben cben reopened this Feb 15, 2017
@yaacov
Copy link
Member

yaacov commented Feb 15, 2017

LGTM 👍

@cben
Copy link
Contributor Author

cben commented Feb 15, 2017

@miq-bot assign dclarizio

@martinpovolny
Copy link
Member

martinpovolny commented Feb 15, 2017

Well I have to ask why we have so much provider-specific code in a mixin that should have contained the common code for all the providers. But that is not the fault of this PR.

@martinpovolny martinpovolny added this to the Sprint 55 Ending Feb 27, 2017 milestone Feb 15, 2017
@martinpovolny martinpovolny merged commit 7ce10bf into ManageIQ:master Feb 15, 2017
cben added a commit to cben/manageiq-ui-classic that referenced this pull request Apr 9, 2017
Expands ManageIQ#314.
KubeException already covers the common "certificate verify failed" SSL
errors but not rarer ones like "does not match the server certificate".
This might be resolved in Kubeclient or RestClient one day
(ManageIQ/kubeclient#240) but it's blocked
on backward compatibility concerns so let's catch it here for now.

get_hostname_from_routes is best-effort, should never crash UI.
Any SSL error will probably fail both get_hostname_from_routes and the
main validation code; the error from validation will then be displayed
in a red flash.
https://bugzilla.redhat.com/show_bug.cgi?id=1436221
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