Bug 1432070

Summary: "" As a hawkular endpoint port passes validation, but prevents provider edit.
Product: Red Hat CloudForms Management Engine Reporter: Jaroslav Henner <jhenner>
Component: ProvidersAssignee: Beni Paskin-Cherniavsky <cben>
Status: CLOSED CURRENTRELEASE QA Contact: Jaroslav Henner <jhenner>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.8.0CC: cben, epacific, fsimonce, jfrey, jhardy, mtayer, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: container:ui
Fixed In Version: 5.9.0.5 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1462844 (view as bug list) Environment:
Last Closed: 2018-03-06 14:55:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Container Management Target Upstream Version:
Embargoed:
Bug Depends On: 1437138    
Bug Blocks: 1462844    
Attachments:
Description Flags
Screenshot: attempted Edit of provider with hawkular port == nil none

Description Jaroslav Henner 2017-03-14 12:57:44 UTC
Description of problem:
When adding/editing provider, one can set the hawkular port to "" (empty string). This causes the validation to pass, but when the same provider is being edited (url like https://10.8.177.87/ems_container/3/edit), the col-md-12 in main-content <div> is  empty. Javascript console shows

Error: o.hawkular_api_port is null
r@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:348:2138
s@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:245:5805
l/<@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:245:5977
To/this.$get</h.prototype.$eval@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:245:13482
To/this.$get</h.prototype.$digest@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:245:11951
To/this.$get</h.prototype.$apply@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:245:13767
l@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:244:20812
M@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:244:22744
e@https://CENSORED.87/assets/application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:244:23219
  application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:244:31216
o.hawkular_api_port is null  application-8af3fdc53e8044e918c5be446a20a5e3eab6313f497394e4e45df490b1fe1cc4.js:244:31216


Version-Release number of selected component (if applicable):
Version 5.8.0.4.20170307183144_745a3d9 

How reproducible:
3/3

Steps to Reproduce:
1. Add the provider with Hawkular endpoint
2. Edit it and set the H. port to ""
3. Try edit it again

Actual results:
Emty page because of javascript failure because of the port has been set to "" / Null

Expected results:
It probably shouldn't be possible to set the port to ""
It should be possible to edit the provider even though some fields are set to crazy values.

Additional info:
Spring is just behind corner, it is nice weather outside (:

Comment 2 Greg Blomquist 2017-03-14 17:02:48 UTC
Federico, it sounds like this is in the Containers provider section, but I'm not altogether positive.  Please reassign to Alissa or Heiko if it's really just a Hawkular issue.

Comment 3 Federico Simoncelli 2017-03-14 18:01:31 UTC
Beni IIUC this is indeed on OpenShift Hawkular endpoint. Please make sure that's really the case.

Comment 4 Mooli Tayer 2017-04-23 12:41:02 UTC
Beni could this be a duplicate of bug 1437138?

Comment 5 Beni Paskin-Cherniavsky 2017-04-25 14:17:20 UTC
Reproduced.  There are several problems here:

(1) For new provider, without filling Hawkular Hostname, it's possible to edit
    Hawkular Port, including making it empty, and the Hawkular tab is still
    valid, you can press [Add].
    It only prevents [Add] if hostname is non-empty.  This is part of the weird
    way we make hawkular "optional"...

(2) When you do that, if route probing worked, you get hawkular endpoint with
    hostname ("hawkular-metrics.10.35.48.131.xip.io") but with port == nil.

    hawkular-metrics route also has port info e.g.:
      :port=>{:targetPort=>"https-endpoint"}
    I think we should be able to detect both.

(3) When you want to edit, JS crashes, Edit form doesn't show at all!
    "TypeError: Cannot read property 'toString' of null" in 
    getEmsFormIdDataComplete, the function building Edit form.
    Attaching screenshot.

(Jaroslav essentially said all this, I just didn't read carefully until I reproduced.)

I suppose your fix for bug 1437138 will also fix these, not sure if dup, for now marking dependant.
Should I independently fix JS to not crash?

Comment 6 Beni Paskin-Cherniavsky 2017-04-25 14:18:35 UTC
Created attachment 1273926 [details]
Screenshot: attempted Edit of provider with hawkular port == nil

Comment 10 CFME Bot 2017-06-19 17:04:27 UTC
New commit detected on ManageIQ/manageiq-ui-classic/fine:
https://github.com/ManageIQ/manageiq-ui-classic/commit/a1be655a33ed0f5b784e7fffc41431908cc87e34

commit a1be655a33ed0f5b784e7fffc41431908cc87e34
Author:     Beni Cherniavsky-Paskin <cben>
AuthorDate: Mon Jun 19 18:11:47 2017 +0300
Commit:     Beni Cherniavsky-Paskin <cben>
CommitDate: Mon Jun 19 18:11:47 2017 +0300

    Backport of https://github.com/ManageIQ/manageiq-ui-classic/pull/1305
    
    It is possible to add such provider on fine (fixed in #1172, fine/no).
    This makes Edit not crash but display port 443 (and save it upon Save).
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1432070

 .../javascripts/controllers/ems_common/ems_common_form_controller.js    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comment 11 Dave Johnson 2017-07-14 03:49:23 UTC
Please assess the importance of this issue and update the priority accordingly.  Somewhere it was missed in the bug triage process.  Please refer to https://bugzilla.redhat.com/page.cgi?id=fields.html#priority for a reminder on each priority's definition.

If it's something like a tracker bug where it doesn't matter, please set it to Low/Low.

Comment 12 Beni Paskin-Cherniavsky 2017-10-18 22:12:01 UTC
https://github.com/ManageIQ/manageiq-schema/pull/98 migration will fix this on master.

QE: To hit this you need to first run old enough version that allows empty hawkular port, e.g. 5.8.0.  Save such provider (comment 5 has details).
Then upgrade to last 5.8.z or 5.9 (to verify 5.8 or 5.9 fix, they're completely different).
In both cases, it should then be possible to edit the provider.

Comment 13 CFME Bot 2017-10-30 22:44:25 UTC
New commit detected on ManageIQ/manageiq-schema/master:
https://github.com/ManageIQ/manageiq-schema/commit/dd5ed573ab27b7a54c362403be8e38a9a9aea021

commit dd5ed573ab27b7a54c362403be8e38a9a9aea021
Author:     Beni Cherniavsky-Paskin <cben>
AuthorDate: Thu Oct 19 00:50:45 2017 +0300
Commit:     Beni Cherniavsky-Paskin <cben>
CommitDate: Mon Oct 30 17:47:53 2017 +0200

    Convert invalid containers hawkular Endpoints port=nil to port=443
    
    For a time (before https://github.com/ManageIQ/manageiq-ui-classic/pull/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

 ...0131403_fix_hawkular_endpoints_with_port_nil.rb | 25 +++++++++
 ...03_fix_hawkular_endpoints_with_port_nil_spec.rb | 65 ++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 db/migrate/20171030131403_fix_hawkular_endpoints_with_port_nil.rb
 create mode 100644 spec/migrations/20171030131403_fix_hawkular_endpoints_with_port_nil_spec.rb

Comment 14 Jaroslav Henner 2018-01-25 01:59:01 UTC
It is not possible to click on verify button, when the hostname is 

Thanks!

 Version 5.9.0.17.20180116225234_ac8b6f5