Bug 1561448 - RHSM failing to register with proxy settings
Summary: RHSM failing to register with proxy settings
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Appliance
Version: 5.8.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.10.0
Assignee: Brandon Dunne
QA Contact: luke couzens
URL:
Whiteboard: webui:upgrade:black
Depends On:
Blocks: 1566562 1572621
TreeView+ depends on / blocked
 
Reported: 2018-03-28 11:09 UTC by luke couzens
Modified: 2019-02-11 14:02 UTC (History)
7 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1566562 1572621 (view as bug list)
Environment:
Last Closed: 2019-02-11 14:02:38 UTC
Category: ---
Cloudforms Team: CFME Core
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Picture showing the "Incorrect" method to add the proxy credentials with "https://" that generates the issue. (47.28 KB, image/png)
2018-03-28 13:39 UTC, Robb Manes
no flags Details

Description luke couzens 2018-03-28 11:09:13 UTC
Description of problem:RHSM failing to register with proxy settings


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


How reproducible:100%


Steps to Reproduce:
1.provision appliance
2.nav to configuration-settings-region-redhat updates-edit
3.add rhsm subscription with proxy settings
4.validate and save settings
5.register appliance

Actual results:
websocket message pops up saying 'failed to register'
last message says 'Attaching products'
evm.log [----] E, [2018-03-28T06:13:02.925687 #11981:7c7130] ERROR -- : MIQ(MiqServer#attempt_registration) Registration Failed: subscription-manager repos exit code: 70

Expected results:
registration works correctly using proxy settings

Additional info:
I have tested the proxy on its own and its up and running correctly and validation seems to work correctly with proxy.

There seems to be issues with saving the RHSM configuration settings, looking at /etc/rhsm/rhsm.conf it seems like the proxy settings are added to the file incorrectly.

This leaves the appliance and limbo state as its not registered and you can't use subscription-manager to remove all or register the appliance correctly.

subscription-manager remove --all
Proxy error, unable to connect to proxy server.

A work around for this is to delete all the proxy settings saved to rhsm.conf and then trying subscription-manager again.

subscription-manager remove --all
1 local certificate has been deleted.
1 subscription removed at the server.

evm.log http://pastebin.test.redhat.com/569633
rhsm.conf after saving settings http://pastebin.test.redhat.com/569622

Comment 3 Robb Manes 2018-03-28 13:39:27 UTC
Created attachment 1414192 [details]
Picture showing the "Incorrect" method to add the proxy credentials with "https://" that generates the issue.

The issue arises if, in the editing window where you type the URL of the proxy, you specify the proxy prefixed with "https://" or "http://".  This will incorrectly assume everything after the colon is a port number.

This is likely a text parsing issue, reading the colon as the port indicator and subsequently breaking up the line like so:

proxy_hostname = https
proxy_port = //rmanes-server.usersys.redhat.com

Workaround is to either:

- Specify the proxy without prepending "https://" or "http://"
- Edit the /etc/rhsm/rhsm.conf and change the proxy_hostname and proxy_port fields to the correct proxy location.

Taking a look into how this is handled currently.

Comment 4 Robb Manes 2018-03-28 13:54:03 UTC
Something like this would probably do it:

--- /root/registration_system.rb	2018-03-28 09:52:33.383266635 -0400
+++ app/models/registration_system.rb	2018-03-28 09:51:14.266819032 -0400
@@ -1,4 +1,5 @@
 require 'linux_admin'
+require 'addressable/uri'
 
 module RegistrationSystem
   RHSM_CONFIG_FILE = "/etc/rhsm/rhsm.conf".freeze
@@ -83,8 +84,10 @@
 
     return unless option_values[:proxy_address]
 
-    write_rhsm_config(:proxy_hostname => option_values[:proxy_address].split(':')[0],
-                      :proxy_port     => option_values[:proxy_address].split(':')[1],
+    uri = Addressable::URI.parse(option_values[:proxy_address])
+
+    write_rhsm_config(:proxy_hostname => uri.host,
+                      :proxy_port     => uri.port,
                       :proxy_user     => option_values[:proxy_username],
                       :proxy_password => option_values[:proxy_password])
   end

Comment 5 Robb Manes 2018-03-28 14:54:19 UTC
PR submitted here: https://github.com/ManageIQ/manageiq/pull/17222

Comment 6 CFME Bot 2018-04-03 14:30:45 UTC
New commits detected on ManageIQ/manageiq/master:

https://github.com/ManageIQ/manageiq/commit/ab7f65233e51e43c983c88f726efcd3d7a39f40d
commit ab7f65233e51e43c983c88f726efcd3d7a39f40d
Author:     Robb Manes <robb.manes>
AuthorDate: Wed Mar 28 10:46:42 2018 -0400
Commit:     Robb Manes <robb.manes>
CommitDate: Wed Mar 28 10:46:42 2018 -0400

    Resolve string handling for "https://" or "http://" in update_rhsm_conf

    Previously, if a proxy URI was entered into the registration page leading with
    "https://" or "http://", it would be incorrectly entered into the rhsm.conf.
    This patch prevents this by ensuring it is a valid URI, and correctly parsing
    the string regardless if it has only a host in the URI or if it leads with the
    protocol.

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

 app/models/registration_system.rb | 5 +-
 1 file changed, 3 insertions(+), 2 deletions(-)


https://github.com/ManageIQ/manageiq/commit/58c65e44d21368ce9ddd49042a978c0d9603ab81
commit 58c65e44d21368ce9ddd49042a978c0d9603ab81
Author:     Brandon Dunne <brandondunne>
AuthorDate: Thu Mar 29 14:15:07 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Thu Mar 29 14:15:07 2018 -0400

    Add tests for RegistrationSystem.update_rhsm_conf with http and https

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

 spec/models/registration_system_spec.rb | 31 +-
 1 file changed, 21 insertions(+), 10 deletions(-)


https://github.com/ManageIQ/manageiq/commit/65bfb6a12816774fbc532ca2581533a1917d495b
commit 65bfb6a12816774fbc532ca2581533a1917d495b
Author:     Brandon Dunne <brandondunne>
AuthorDate: Thu Mar 29 14:21:50 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Thu Mar 29 14:21:50 2018 -0400

    Reduce duplicate test logic

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

 spec/models/registration_system_spec.rb | 30 +-
 1 file changed, 12 insertions(+), 18 deletions(-)


https://github.com/ManageIQ/manageiq/commit/47ddbb4a967fed9ae31028088efe97896960d72b
commit 47ddbb4a967fed9ae31028088efe97896960d72b
Author:     Brandon Dunne <brandondunne>
AuthorDate: Thu Mar 29 14:28:28 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Thu Mar 29 14:28:28 2018 -0400

    Test against multiple addresses (hostname, IPv4, IPv6)

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

 spec/models/registration_system_spec.rb | 24 +-
 1 file changed, 13 insertions(+), 11 deletions(-)


https://github.com/ManageIQ/manageiq/commit/dafb5f7a99bb0409191a58f03bd55b59729e9cbb
commit dafb5f7a99bb0409191a58f03bd55b59729e9cbb
Author:     Brandon Dunne <brandondunne>
AuthorDate: Thu Mar 29 15:16:39 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Thu Mar 29 15:16:39 2018 -0400

    myport is not a valid port, 0 is reserved so use that instead

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

 spec/models/registration_system_spec.rb | 8 +-
 1 file changed, 4 insertions(+), 4 deletions(-)


https://github.com/ManageIQ/manageiq/commit/963a3f3a6c2a5d2b5f1059b06c75756323f22a13
commit 963a3f3a6c2a5d2b5f1059b06c75756323f22a13
Author:     Brandon Dunne <brandondunne>
AuthorDate: Thu Mar 29 15:19:09 2018 -0400
Commit:     Brandon Dunne <brandondunne>
CommitDate: Thu Mar 29 15:19:09 2018 -0400

    Fix issues related to proxy_address

    - Allow for http(s) or other schemes
    - Allow for hostname, IPv4 or IPv6 addresses

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

 app/models/registration_system.rb | 6 +-
 1 file changed, 3 insertions(+), 3 deletions(-)

Comment 9 luke couzens 2018-06-19 09:57:59 UTC
Verified in 5.10


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