Bug 1637092 - [URI::InvalidComponentError]: bad component(expected host component): Method:[block in method_missing]
Summary: [URI::InvalidComponentError]: bad component(expected host component): Metho...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.9.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.10.0
Assignee: Joe Rafaniello
QA Contact: Satyajit Bulage
Red Hat CloudForms Documentation
URL:
Whiteboard:
Depends On:
Blocks: 1639353
TreeView+ depends on / blocked
 
Reported: 2018-10-08 15:40 UTC by Niladri Roy
Modified: 2021-12-10 17:50 UTC (History)
7 users (show)

Fixed In Version: 5.10.0.20
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1639353 (view as bug list)
Environment:
Last Closed: 2019-02-12 16:52:15 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Niladri Roy 2018-10-08 15:40:07 UTC
Description of problem:
Embedded ansible worker stops with below error

[----] E, [2018-09-24T03:44:15.962201 #22140:b1a37d0] ERROR -- : [URI::InvalidComponentError]: bad component(expected host component):   Method:[block in method_missing]



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

How reproducible:
Everytime at Cu environment

Steps to Reproduce:
1.
2.
3.

Actual results:
Embedded ansible worker tries to reactivate itself, Cu follows 
https://access.redhat.com/solutions/3080891
Then only embedded ansible becomes usable again

Expected results:
Embedded ansible worker shouldn't stop and should keep running

Additional info:

Comment 3 Joe Rafaniello 2018-10-09 20:47:04 UTC
From the backtrace, it's failing in the vmdb/util.rb, trying to build a URI with a bad host component:

https://github.com/ManageIQ/manageiq/blob/master/lib/vmdb/util.rb#L18

From there, it's grabbing the http proxy from Settings.yml, advanced settings:

proxy = ::Settings.http_proxy[proxy_config].to_hash

It tries the http_proxy -> embedded_ansible section from advanced settings/settings.yml first and if blank, uses the default section.

If you look at their default section from the logs/configs, there '' values are tripping up this code:


:http_proxy:
...
  :default:
    :host: ''
    :password: ''
    :port: ''
    :user: ''
    :scheme: 
...
  :embedded_ansible:
    :host: 
    :password: 
    :port: 
    :user: 
    :scheme: 


I am making a code change to ignore these blank values but there is a workaround.

vmdb
bin/rails console

puts SettingsChange.where(:resource_type => "MiqServer").where(:key => "/http_proxy/default").where(:value => "''")

If that looks right, you can remove those rows:

SettingsChange.where(:resource_type => "MiqServer").where(:key => "/http_proxy/default").where(:value => "''").destroy_all

Comment 4 Joe Rafaniello 2018-10-10 14:40:25 UTC
Note, it looks like the user had previously set a default http proxy in the settings but then wanted to remove it and couldn't, so they set the values to ''.  While this works, it caused this bug.  A better way to "remove" previously configured values such a http proxy was implemented in 5.10.0.3 in https://bugzilla.redhat.com/show_bug.cgi?id=1576984.

Comment 5 Niladri Roy 2018-10-11 07:42:31 UTC
Hello Joe,

Thanks for your help on this. Cu tried the rails commands, but it didn't help, he tried few steps on his own which fixed the issue. I have given the details below

================================================

irb(main):001:0> puts SettingsChange.where(:resource_type => "MiqServer").where(:key => "/http_proxy/default").where(:value => "''")
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
=> nil

(I was not sure what is exptected so I fired the destoy method)
irb(main):002:0> SettingsChange.where(:resource_type => "MiqServer").where(:key => "/http_proxy/default").where(:value => "''").destroy_all
=> []

Result: nothing changed. 

But I was able to check this part in our configuration. The quotes are something like a workaround, because it was not possible to remove values from the fields in the advanced settings of manual configuration, so we decided to insert "blanks" in the proxytab to avoid the use of our proxyserver for default requests.  We used this from here: https://bugzilla.redhat.com/show_bug.cgi?id=1358433

After saving blank vars, the configuration does not change and the settings are still present, even if we remove them out of our configuration. It would be fine if the developers will fix this as well, because then there is no need of empty quotes. 

But at least I think I found a way to remove the quotes from the configuration. I will show you what I did:
The config part was like this:


  :default:
    :host:  ''
    :password:  ''
    :port:  ''
    :user:  ''
    :scheme:  

I changed it to the following and hit the save button:

  :default:
    :host:""
    :password:""
    :port:""
    :user:""
    :scheme:""

After a reload the config looks like this


  :default: :host:"" :password:"" :port:"" :user:"" :scheme:""

Then I just removed the double quotes and set it back to a normal layout:

  :default:
    :host:
    :password:
    :port:
    :user:
    :scheme:  

It worked!
Now Ansible is working as expected again and we are able to go ahead with our development. 

================================


I have also informed Cu about the RFE which has been implemented in 5.10.0.3
I think this BZ can be closed now

Comment 6 CFME Bot 2018-10-11 13:57:51 UTC
New commit detected on ManageIQ/manageiq/master:

https://github.com/ManageIQ/manageiq/commit/5f55f94f6b887e585220d70c2dd6405c8e39955e
commit 5f55f94f6b887e585220d70c2dd6405c8e39955e
Author:     Joe Rafaniello <jrafanie>
AuthorDate: Tue Oct  9 16:08:08 2018 -0400
Commit:     Joe Rafaniello <jrafanie>
CommitDate: Tue Oct  9 16:08:08 2018 -0400

    Handle a blank value for the http_proxy host

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

    We have no way (in the UI) to remove a previously configured http_proxy host
    in Settings.yml/advanced settings, so people were forced to save a ''
    value.  This code was only checking for nil values and should really
    check for blank values.  It doesn't make sense to reimplement the regex
    used by the URI class to parse host values for validity but handling
    some obvious blank values make sense here.

 lib/vmdb/util.rb | 2 +-
 spec/lib/vmdb/util_spec.rb | 6 +
 2 files changed, 7 insertions(+), 1 deletion(-)

Comment 7 Joe Rafaniello 2018-10-11 15:29:08 UTC
Thanks for the information Niladri.  I'm glad you were able to workaround the issue. That workaround is pretty unfortunate but I'm glad they were able to get it to work.  The RFE in 5.10.0.3 should make this much easier.  I'll keep this BZ in post because I did change code to not only check for a nil http_proxy host value but also an empty string '' or "" value since it's possible others will have tried to use the empty string trick to "remove" a setting.

Comment 9 CFME Bot 2018-10-15 17:10:36 UTC
New commit detected on ManageIQ/manageiq/hammer:

https://github.com/ManageIQ/manageiq/commit/edcd4ffbb84fc0db15c0ac4f3322da0ba75d0b02
commit edcd4ffbb84fc0db15c0ac4f3322da0ba75d0b02
Author:     Brandon Dunne <brandondunne>
AuthorDate: Wed Oct 10 10:05:50 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Wed Oct 10 10:05:50 2018 -0400

    Merge pull request #18073 from jrafanie/handle_blank_http_proxy_host

    Handle a blank value for the http_proxy host

    (cherry picked from commit a17d07e26daeeb1c06e5dd888ee535ae823cbbe9)

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

 lib/vmdb/util.rb | 2 +-
 spec/lib/vmdb/util_spec.rb | 6 +
 2 files changed, 7 insertions(+), 1 deletion(-)

Comment 10 Satyajit Bulage 2018-11-16 12:01:57 UTC
Followed Steps for Verification:

1. Added Proxy server
2. Enabled Embedded Ansible Server role.
3. Ordered Ansible Playbook via service
4. Removed Proxy server entries with "<<reset>>" keyword in place of previous values.
5. Again ordered same service

In both the scenario successfully playbook execution without any error.

Verified Version: 5.10.0.24.20181113213923_03b81fd


Note You need to log in before you can comment on or make changes to this bug.