Bug 1131213

Summary: rhn-migrate-classic-to-rhsm throws gaierror: [Errno -2] Name or service not known
Product: Red Hat Enterprise Linux 6 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Bryan Kearney <bkearney>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.6CC: bkearney, jesusr, tlavigne
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: CLI parameter, --serverurl, was being ignored. Consequence: Unable to migrate from a server given a url without specifying it in the rhsm.conf. Fix: Honor the serverurl parameter during migrations. Result: User is able to specify a server on the command line.
Story Points: ---
Clone Of:
: 1171808 (view as bug list) Environment:
Last Closed: 2014-10-14 07:48:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1014343, 1171808, 1172203    

Description John Sefler 2014-08-18 17:12:54 UTC
Description of problem:
The rhn-migrate-classic-to-rhsm fails when passing the --serverurl option with a valid value to override the undesired server hostname:port/prefix currently set in the rhsm.conf.


Version-Release number of selected component (if applicable):
[root@jsefler-6 ~]# rpm -q subscription-manager-migration
subscription-manager-migration-1.12.10-1.el6.x86_64


How reproducible:


Steps to Reproduce:
Demonstrate that registration to the target serverurl actually works...
[root@jsefler-6 ~]# subscription-manager register --serverurl=subscription.rhn.stage.redhat.com:443/subscription
Username: qa
Password: 
The system has been registered with ID: de5f3967-bd89-42bf-b55e-33d16c0dad59 
[root@jsefler-6 ~]# subscription-manager unregister
System has been unregistered.
[root@jsefler-6 ~]# 

^Success as expected^ demonstrates that --serverurl=subscription.rhn.stage.redhat.com:443/subscription is good.
Now let's register classically to RHN and then try to migrate to the same serverurl with the same credentials, but this time it will fail.  It appears to fail because the --serverurl is not overriding the corresponding values in the rhsm.conf.


[root@jsefler-6 ~]# rhnreg_ks --serverUrl=https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC --username=qa --password=redhatqa --norhnsd --nohardware --nopackages --novirtinfo
[root@jsefler-6 ~]# rhn-channel --list
rhel-x86_64-server-6
[root@jsefler-6 ~]# subscription-manager config --server.hostname=foo.redhat.com --server.port=123 --server.prefix=/bar
[root@jsefler-6 ~]# rhn-migrate-classic-to-rhsm --serverurl=subscription.rhn.stage.redhat.com:443/subscription
Red Hat username: qa
Red Hat password: 
Subscription Service username: qa
Subscription Service password: 
Unable to connect to certificate server: [Errno -2] Name or service not known.  See /var/log/rhsm/rhsm.log for more details.
[root@jsefler-6 ~]# 



Actual results:
above

Expected results:
Expected the serverurl that I specified on the command line to be used during migration to override the undesirable values configured in rhsm.conf. 



Additional info:

[root@jsefler-6 ~]# tail -f /var/log/rhsm/rhsm.log
2014-08-18 13:03:31,924 [DEBUG] rhn-migrate-classic-to-rhsm @profile.py:97 - Loading current RPM profile.
2014-08-18 13:03:32,232 [INFO] rhn-migrate-classic-to-rhsm @connection.py:648 - Using basic authentication as: qa
2014-08-18 13:03:32,233 [INFO] rhn-migrate-classic-to-rhsm @connection.py:670 - Connection Built: host: foo.redhat.com, port: 123, handler: /bar
2014-08-18 13:03:32,233 [DEBUG] rhn-migrate-classic-to-rhsm @identity.py:131 - Loading consumer info from identity certificates.
2014-08-18 13:03:32,233 [ERROR] rhn-migrate-classic-to-rhsm @identity.py:143 - [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/identity.py", line 135, in reload
    self.consumer = self._get_consumer_identity()
  File "/usr/share/rhsm/subscription_manager/identity.py", line 151, in _get_consumer_identity
    return ConsumerIdentity.read()
  File "/usr/share/rhsm/subscription_manager/identity.py", line 48, in read
    f = open(cls.keypath())
IOError: [Errno 2] No such file or directory: '/etc/pki/consumer/key.pem'
2014-08-18 13:03:32,234 [INFO] rhn-migrate-classic-to-rhsm @identity.py:144 - Error reading consumer identity cert
2014-08-18 13:03:32,236 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:414 - Loaded CA certificates from /etc/rhsm/ca/: jsefler-f14-7candlepin.pem, jsefler-f14-candlepin.pem, candlepin-stage.pem, redhat-uep.pem, candlepin-local.pem
2014-08-18 13:03:32,237 [DEBUG] rhn-migrate-classic-to-rhsm @connection.py:446 - Making request: GET /bar/users/qa%40redhat.com/owners
2014-08-18 13:03:32,561 [ERROR] rhn-migrate-classic-to-rhsm @migrate.py:297 - [Errno -2] Name or service not known
2014-08-18 13:03:32,566 [ERROR] rhn-migrate-classic-to-rhsm @migrate.py:298 - Traceback (most recent call last):
  File "/usr/share/rhsm/subscription_manager/migrate/migrate.py", line 292, in check_ok_to_proceed
    self.cp.getOwnerList(username)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 911, in getOwnerList
    return self.conn.request_get(method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 550, in request_get
    return self._request("GET", method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 453, in _request
    conn.request(request_type, handler, body=body, headers=headers)
  File "/usr/lib64/python2.6/httplib.py", line 914, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request
    self.endheaders()
  File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
    self._send_output()
  File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
    self.send(msg)
  File "/usr/lib64/python2.6/httplib.py", line 739, in send
    self.connect()
  File "/usr/lib64/python2.6/site-packages/M2Crypto/httpslib.py", line 51, in connect
    socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
gaierror: [Errno -2] Name or service not known

Comment 1 John Sefler 2014-08-18 21:08:51 UTC
This appears to be a regression from RHEL6.5 which passes the same test scenario....

[root@jsefler-6 ~]# rpm -q subscription-manager-migration
subscription-manager-migration-1.9.11-1.el6.x86_64


[root@jsefler-6 ~]# rhnreg_ks --serverUrl=https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC --username=qa --password=redhatqa --norhnsd --nohardware --nopackages --novirtinfo
[root@jsefler-6 ~]# rhn-channel --list
rhel-x86_64-server-6
[root@jsefler-6 ~]# subscription-manager config --server.hostname=foo.redhat.com --server.port=123 --server.prefix=/bar
[root@jsefler-6 ~]# rhn-migrate-classic-to-rhsm --serverurl=subscription.rhn.stage.redhat.com:443/subscription
Red Hat account: qa
Password: 
System Engine Username: qa
Password: 

Retrieving existing RHN Classic subscription information...

+-----------------------------------------------------+
System is currently subscribed to these RHN Classic Channels:
+-----------------------------------------------------+
rhel-x86_64-server-6

+-----------------------------------------------------+
Installing product certificates for these RHN Classic channels:
+-----------------------------------------------------+
rhel-x86_64-server-6

Product certificates installed successfully to /etc/pki/product.

Preparing to unregister system from RHN Classic...
System successfully unregistered from RHN Classic.

Attempting to register system to Red Hat Subscription Management...
The system has been registered with ID: b04b0b82-8314-4cf0-815d-c0c4319fb5de 
System 'URI:CN=jsefler-6.usersys.redhat.com' successfully registered to Red Hat Subscription Management.

Attempting to auto-attach to appropriate subscriptions...
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

[root@jsefler-6 ~]#

Comment 3 Bryan Kearney 2014-08-28 13:03:24 UTC
Pushing to 7.1 (next release cycle) per conversations with QE.

Comment 7 Chris Snyder 2014-09-04 18:19:41 UTC
should be in as of commit: edce99dcd4dffe724c72921ad4d8d8f3c1a01972

link to pr here for reference: https://github.com/candlepin/subscription-manager/commit/edce99dcd4dffe724c72921ad4d8d8f3c1a01972

Comment 8 John Sefler 2014-09-08 16:49:49 UTC
Moving back to RHEL6 since the rhn-migrate-classic-to-rhsm tool is more useful on RHEL6 that RHEL7.

Comment 10 John Sefler 2014-09-09 14:06:04 UTC
Verifying Version...
[root@jsefler-6 ~]# rpm -q subscription-manager-migration
subscription-manager-migration-1.12.14-5.el6.x86_64


[root@jsefler-6 ~]# rhnreg_ks --serverUrl=https://xmlrpc.rhn.code.stage.redhat.com/XMLRPC --username=qa --password=**** --norhnsd --nohardware --nopackages --novirtinfo
[root@jsefler-6 ~]# rhn-channel --list
rhel-x86_64-server-6
[root@jsefler-6 ~]# subscription-manager config --server.hostname=foo.redhat.com --server.port=123 --server.prefix=/bar
[root@jsefler-6 ~]# subscription-manager config | head -5
[server]
   hostname = foo.redhat.com
   insecure = [0]
   port = 123
   prefix = /bar
[root@jsefler-6 ~]# rhn-migrate-classic-to-rhsm --serverurl=subscription.rhn.stage.redhat.com:443/subscription
Red Hat username: qa
Red Hat password: 
Subscription Service username: qa
Subscription Service password: 

Retrieving existing RHN Classic subscription information...

+-----------------------------------------------------+
System is currently subscribed to these RHN Classic Channels:
+-----------------------------------------------------+
rhel-x86_64-server-6

+-----------------------------------------------------+
Installing product certificates for these RHN Classic channels:
+-----------------------------------------------------+
rhel-x86_64-server-6

Product certificates installed successfully to /etc/pki/product.

Preparing to unregister system from RHN Classic...
System successfully unregistered from RHN Classic.

Attempting to register system to Red Hat Subscription Management...
The system has been registered with ID: 77723f29-94a3-4748-908e-54f9b4228f03 
System 'jsefler-6.usersys.redhat.com' successfully registered to Red Hat Subscription Management.

Attempting to auto-attach to appropriate subscriptions...
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

[root@jsefler-6 ~]# 
[root@jsefler-6 ~]# subscription-manager config | head -5
[server]
   hostname = subscription.rhn.stage.redhat.com
   insecure = [0]
   port = [443]
   prefix = [/subscription]
[root@jsefler-6 ~]# 



VERIFIED: Specifying the --serverurl for rhn-migrate-classic-to-rhsm will override the values set in rhsm.conf

Comment 12 errata-xmlrpc 2014-10-14 07:48:27 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1384.html