Bug 1598952 - virt-who forces an invalid rhevm url by including the port number
Summary: virt-who forces an invalid rhevm url by including the port number
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Virt-who Configure Plugin
Version: 6.3.0
Hardware: All
OS: All
unspecified
high
Target Milestone: Unspecified
Assignee: Marek Hulan
QA Contact: Katello QA List
satellite-doc-list
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-07-07 02:18 UTC by Glenn Snead
Modified: 2019-01-14 19:34 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-01-14 19:34:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
virt-who -o command output (5.71 KB, text/plain)
2018-07-07 02:18 UTC, Glenn Snead
no flags Details
virt-who.log output (3.40 KB, text/plain)
2018-07-10 13:57 UTC, Glenn Snead
no flags Details
/etc/virt-who.d/ files (10.00 KB, application/x-tar)
2018-07-11 13:40 UTC, Glenn Snead
no flags Details
Foreman production.log (117.49 KB, text/plain)
2018-07-11 13:41 UTC, Glenn Snead
no flags Details

Description Glenn Snead 2018-07-07 02:18:28 UTC
Created attachment 1457118 [details]
virt-who -o command output

Description of problem:
Virt-who configuration adds ":433" to the https:// url.  This causes a python error: 

[virtwho.main ERROR] MainProcess(21865):Thread-2 @virt.py:run:383 - Thread 'virt-who-config-1' fails with error: Unable to connect to RHEV-M server: ('Connection aborted.', gaierror(-2, 'Name or service not known'))


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


How reproducible:

Configure virt-who to connect to a rhev/rhevm url.  i.e. https://rhev.example.com/ovirt-engine/

Steps to Reproduce:
1. Open the Infrastructure > virt-who configurations menu.
2. Click the "Create config" button.
3. Enter the necessary configuration.  The url to the management vm or server that is running the admin web interface would be this: https://rhev.example.com/ovirt-engine/
4. Click the Submit button.
5. Deploy the configuration: hammer virt-who-config deploy --id 1
6. Stop the virt-who.service: systemctl stop virt-who.service
7. Check the connection: virt-who -o
  You will see this line: 
  The original server URL was incomplete. It has been enhanced to 
  https://rhev.example.com:443/ovirt-engine/


Actual results:
The error message is displayed:
[virtwho.main ERROR] MainProcess(21645):Thread-2 @virt.py:run:383 - Thread 'virt-who-config-1' fails with error: Unable to connect to RHEV-M server: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

Expected results:
There should be a successful connection, but adding the port number 443 to the url creates an invalid url.

Comment 1 Marek Hulan 2018-07-09 13:06:53 UTC
I'm unable to reproduce and I can't find the code that would add the port to url automatically. Can you please provide a log from the moment when you create a virt-who configuration and ideally a screen shot of the form? If you look at the script and scroll down the the part where you see the virt-who configuration part, does it include the port? What is exactly the version of foreman_virt_who_configure plugin you're using? I assume 0.1.9 which simply copies the value that user provides in the form. Hammer should not touch the script at all. Please also upload the content of /etc/virt-who.d

Comment 3 Glenn Snead 2018-07-10 13:57:29 UTC
I configured virt-who to log output to /var/log/virt-who.log and enabled debug level output.  I'll attach the log file.
I'm running the following:
RHEL 7.5
Satellite: 6.3.2-1.el7sat

All packages are up to date.

Comment 4 Glenn Snead 2018-07-10 13:57:59 UTC
Created attachment 1457837 [details]
virt-who.log output

Comment 5 Marek Hulan 2018-07-11 11:03:12 UTC
Sorry if I was not clear.

1) I asked for production.log from Satellite from a moment when you create the configuration in Satellite UI.
2) I asked about the configuration script, if you're not sure what I mean, go to configuration detail page in Satellite UI and copy the whole configuration script and attach it as a private attachment
3) what is output of `rpm -q tfm-rubygem-foreman_virt_who_configure` on your Satellite host?
4) please tar the whole /etc/virt-who.d on a machine where you deployed the virt-who configuration and upload it as a separate attachment.

Comment 6 Glenn Snead 2018-07-11 13:40:34 UTC
Created attachment 1458092 [details]
/etc/virt-who.d/ files

As requested, the /etc/virt-who.d/ directory files.  The second configuration is the new configuration, created so I could obtain recent production.log entries.

Comment 7 Glenn Snead 2018-07-11 13:41:47 UTC
Created attachment 1458093 [details]
Foreman production.log

Comment 8 Glenn Snead 2018-07-11 13:43:21 UTC
As requested, I have uploaded the requested files.

The output of the rpm command is:
tfm-rubygem-foreman_virt_who_configure-0.1.9-1.fm1_15.el7sat.noarch


Let me know if you need anything else, or things that I have overlooked when I configured virt-who.

Comment 9 Marek Hulan 2018-07-11 15:52:33 UTC
Thanks for details

Perhaps I'm missing something but I see following in the production.log

2018-07-11 09:33:57 bab222b6 [app] [I]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"SrGtaL6SgeRZ6N5uv6c55E3i3FlwgWhwcss4uMREjsjC7BKf7BkysLlFj6glQlovzaWAyJ8YozckrV5LCWlk2w==", "foreman_virt_who_configure_config"=>{"name"=>"rhev01", "organization_id"=>"1", "hypervisor_type"=>"rhevm", "hypervisor_server"=>"https://rhev01.gshome.lan/ovirt-engine", "hypervisor_username"=>"admin", "hypervisor_password"=>"[FILTERED]", "interval"=>"120", "satellite_url"=>"satellite.gshome.lan", "hypervisor_id"=>"hostname", "listing_mode"=>"0", "whitelist"=>"", "blacklist"=>"", "debug"=>"0", "proxy"=>"", "no_proxy"=>""}, "commit"=>"Submit"}
...
https://satellite.gshome.lan/foreman_virt_who_configure/configs/2

which means you've specified https://rhev01.gshome.lan/ovirt-engine as server url (without the port). It created a configuration with id 2. When I look at the /etc/virt-who.d/virt-who-config-2.conf I see the very same url without port 443. So it simply uses the server you specified in the form.

When I look at /etc/virt-who.d/virt-who-config-1.conf I see the port 443 in the url, but I didn't find respective log in production.log. I only see that you deleted older config by this line

2018-07-11 09:32:48 8a20d795 [app] [I] Started DELETE "/foreman_virt_who_configure/configs/1" for 192.168.4.200 at 2018-07-11 09:32:48 -0400

This leads me to the assumption, you've created the configuration (with id 1), with port 443 specified as part of url. Then deployed it. Then deleted it on the server and created a new one (id 2). After you deployed the second one, virt-who still fails since the old configuration is still in place. Note that deletion in Satellite does not clean up any configuration from /etc/virt-who.d directory. You need to clean that up manually.

So try rm /etc/virt-who.d/virt-who-config-1.conf and restart virt-who, that should use the url without 443. Did that help?

Note that if you make a typo in the url, you can edit the configuration in Satellite and then redeploy it. In this case you could have just remove :443 from url in Satellite and rerun hammer virt-who-config deploy --id 1

Comment 10 Glenn Snead 2018-07-11 19:15:27 UTC
I created the second, duplicate configuration to show the production log accepting the new configuration.  

The issue is this: virt-who is attempting to make an HTTP connection with a url that includes the port number (443) in the url, which is an invalid url.

If you read the command output attachment, the url is updated to include the port number.  The connection attempt fails:

MainProcess(10667):MainThread @config.py:init_config:1395 - [virt-who-config-2]: The original server URL was incomplete. It has been enhanced to https://rhev01.gshome.lan:443/ovirt-engine/
2018-07-11 15:10:15,814 [virtwho.virt-who_log DEBUG] MainProcess(10667):MainThread @executor.py:__init__:52 - Using config named 'virt-who-config-2'
2018-07-11 15:10:15,815 [virtwho.virt-who_log INFO] MainProcess(10667):MainThread @main.py:main:158 - Using configuration "virt-who-config-2" ("rhevm" mode)
2018-07-11 15:10:15,815 [virtwho.virt-who_log INFO] MainProcess(10667):MainThread @main.py:main:160 - Using reporter_id='satellite.gshome.lan-c2157f7e18a04edc883e306dd4807269'
2018-07-11 15:10:15,822 [rhsm.https DEBUG] MainProcess(10667):MainThread @https.py:<module>:56 - Using standard libs to provide httplib and ssl
2018-07-11 15:10:15,830 [virtwho.main DEBUG] MainProcess(10667):Thread-2 @virt.py:run:374 - Thread 'virt-who-config-2' started
2018-07-11 15:10:25,891 [virtwho.main ERROR] MainProcess(10667):Thread-2 @virt.py:run:383 - Thread 'virt-who-config-2' fails with error: Unable to connect to RHEV-M server: ('Connection aborted.', gaierror(-2, 'Name or service not known'))

So either one of two things are ocurring:
1. The connection is being rejected because the self signed certificate is causing the connection attempt to be rejected.
2. The URL should not include the port number (443).

Comment 11 Glenn Snead 2019-01-14 19:34:57 UTC
I recently re-deployed my Sat 6.3 server, and my virt-who issue did not resurface.  I'm closing this issue.


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