Bug 1382355 - CLI Does Not Display Error Message When Auto-Attach has Failure
Summary: CLI Does Not Display Error Message When Auto-Attach has Failure
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: subscription-manager
Version: 6.9
Hardware: Unspecified
OS: Unspecified
high
low
Target Milestone: rc
: ---
Assignee: Kevin Howell
QA Contact: John Sefler
URL:
Whiteboard:
: 1382365 (view as bug list)
Depends On:
Blocks: 1382365
TreeView+ depends on / blocked
 
Reported: 2016-10-06 13:06 UTC by Michael Stead
Modified: 2017-03-21 10:55 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1382365 (view as bug list)
Environment:
Last Closed: 2017-03-21 10:55:44 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Github candlepin subscription-manager pull 1505 None closed 1382355: Don't swallow CLI autoattach exceptions 2020-04-30 04:54:41 UTC
Red Hat Product Errata RHSA-2017:0698 normal SHIPPED_LIVE Moderate: subscription-manager security, bug fix, and enhancement update 2017-03-21 12:39:12 UTC

Description Michael Stead 2016-10-06 13:06:12 UTC
When an exception occurs on the candlepin server during an auto-attach attempt, the subscription-manager CLI provides no indication that the error occurred. It simply states “Unable to find available subscriptions for all your installed products.” -- hiding the error (if one occurred).

The CLI should report that it didn't find any subscriptions because an error occurred, including what was reported in the response's error message.

Currently subscription-manager CLI is swallowing the returned exception and carrying on.

This fix is particularly important for displaying errors such as "Autobind is disabled for owner X". 


Steps to Reproduce:
1. Disable autobind for an owner

$ curl -X PUT -k -u username:password -d '{"autobindDisabled":true}' -H "Content-Type: application/json" https://localhost:8443/candlepin/owners/your_owner_key

2. Register a consumer with the auto-attach option

sudo subscription-manager register --user USERNAME --pass PASSWORD --org YOUR_ORG --auto-attach


Actual results:
Looking in the /etc/rhsm/rhsm.log you will see an error stating that Autobind was disabled for your owner, but the CLI doesn't report the error.

Registraion will complete (as it should), but the CLI will report “Unable to find available subscriptions for all your installed products.” -- no hint as to why.


Expected results:
The CLI should report a message as to what happened.

Comment 3 vritant 2016-10-06 14:13:02 UTC
*** Bug 1382365 has been marked as a duplicate of this bug. ***

Comment 5 Chris Snyder 2016-10-07 20:07:34 UTC
Moving to MODIFIED as the attached fix has passed review and this fix should be included in the first build for RHEL 6.9

Comment 7 Shwetha Kallesh 2016-11-08 06:05:20 UTC
CLI now displays the error message "Autobind is not enabled for owner 'admin'."
while trying register with --auto-attach option to an owner(auto-bind disabled)

 
[root@dhcp35-71 ~]# curl -X PUT -k -u admin:admin -d '{"autobindDisabled":true}' -H "Content-Type: application/json" https://shwetha-workstation.usersys.redhat.com:8443/candlepin/owners/admin
{
  "parentOwner" : null,
  "id" : "8ac6a39f583faff701583fb00dc80002",
  "key" : "admin",
  "displayName" : "Admin Owner",
  "contentPrefix" : null,
  "defaultServiceLevel" : null,
  "upstreamConsumer" : null,
  "logLevel" : null,
  "autobindDisabled" : true,
  "href" : "/owners/admin",
  "created" : "2016-11-07T16:47:32+0000",
  "updated" : "2016-11-08T06:00:16+0000"
}

[root@dhcp35-71 ~]# subscription-manager register --force --auto-attach
The system with UUID 1c8ab3fa-ac58-4c5e-9d59-08f73a808731 has been unregistered
Registering to: shwetha-workstation.usersys.redhat.com:8443/candlepin
Username: admin
Password: 
Organization: admin
The system has been registered with ID: ec5470ef-b3e8-49d5-847c-2f025e671f4c 
Autobind is not enabled for owner 'admin'.

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Not Subscribed

Comment 8 Shwetha Kallesh 2016-11-08 09:22:08 UTC
Moving bug to verified state


[root@rhel69-shwetha ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.0.19-1
subscription management rules: 5.20
subscription-manager: 1.18.4-1.el6
python-rhsm: 1.18.4-1.el6

[root@rhel69-shwetha ~]# curl -X PUT -k -u admin:admin -d '{"autobindDisabled":true}' -H "Content-Type: application/json" https://shwetha-workstation.usersys.redhat.com:8443/candlepin/owners/admin
{
  "parentOwner" : null,
  "id" : "8ac6a39f5843389d01584338b4580003",
  "key" : "admin",
  "displayName" : "Admin Owner",
  "contentPrefix" : null,
  "defaultServiceLevel" : null,
  "upstreamConsumer" : null,
  "logLevel" : null,
  "autobindDisabled" : true,
  "href" : "/owners/admin",
  "created" : "2016-11-08T09:15:39+0000",
  "updated" : "2016-11-08T09:18:00+0000"
}[root@rhel69-shwetha ~]# subscription-manager register --force --auto-attach
Registering to: shwetha-workstation.usersys.redhat.com:8443/candlepin
Username: admin
Password: 
Organization: admin
The system has been registered with ID: 44e317cb-860a-4bb1-9442-2d1b52ba2f42 
Autobind is not enabled for owner 'admin'.

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Not Subscribed

Unable to find available subscriptions for all your installed products.











2016-11-08 04:18:36,911 [INFO] subscription-manager:3691:MainThread @connection.py:843 - Connection built: host=shwetha-workstation.usersys.redhat.com port=8443 handler=/candlepin auth=basic username=admin
2016-11-08 04:18:37,052 [INFO] subscription-manager:3691:MainThread @hwprobe.py:918 - collected virt facts: virt.is_guest=True, virt.host_type=kvm, virt.uuid=183bead8-fe47-4919-a21c-a75885c3ba64
2016-11-08 04:18:42,354 [INFO] subscription-manager:3691:MainThread @managerlib.py:77 - Consumer created: {'consumer_name': 'rhel69-shwetha', 'uuid': '44e317cb-860a-4bb1-9442-2d1b52ba2f42'}
2016-11-08 04:18:42,362 [INFO] subscription-manager:3691:MainThread @connection.py:843 - Connection built: host=shwetha-workstation.usersys.redhat.com port=8443 handler=/candlepin auth=identity_cert ca_dir=/etc/rhsm/ca/ verify=False
2016-11-08 04:18:42,414 [INFO] subscription-manager:3691:MainThread @managercli.py:399 - Server Versions: {'rules-version': '5.20', 'candlepin': '2.0.19-1', 'server-type': 'Red Hat Subscription Management'}
2016-11-08 04:18:42,447 [INFO] subscription-manager:3691:MainThread @cache.py:398 - Server does not support packages, skipping profile upload.
2016-11-08 04:18:42,617 [WARNING] subscription-manager:3691:MainThread @managercli.py:203 - Error during auto-attach.
2016-11-08 04:18:42,617 [ERROR] subscription-manager:3691:MainThread @managercli.py:204 - Autobind is not enabled for owner 'admin'.
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/subscription_manager/managercli.py", line 199, in autosubscribe
    ents = cp.bind(consumer_uuid)  # new style
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 1208, in bind
    return self.conn.request_post(method)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 711, in request_post
    return self._request("POST", method, params)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 619, in _request
    self.validateResponse(result, request_type, handler)
  File "/usr/lib64/python2.6/site-packages/rhsm/connection.py", line 672, in validateResponse
    raise RestlibException(response['status'], error_msg, response.get('headers'))
RestlibException: Autobind is not enabled for owner 'admin'.
2016-11-08 04:18:42,618 [INFO] subscription-manager:3691:MainThread @managercli.py:1204 - System registered, updating entitlements if needed
2016-11-08 04:18:42,717 [INFO] subscription-manager:3691:MainThread @entcertlib.py:131 - certs updated:
Total updates: 0
Found (local) serial# []
Expected (UEP) serial# []
Added (new)
  <NONE>
Deleted (rogue):
  <NONE>
2016-11-08 04:18:42,831 [INFO] subscription-manager:3691:MainThread @cert_sorter.py:205 - Product status: valid_products= partial_products= expired_products= unentitled_producs=69 future_products= valid_until=None
2016-11-08 04:18:42,938 [INFO] subscription-manager:3691:MainThread @managercli.py:218 - Attempted to auto-attach/heal the system.
2016-11-08 04:18:43,114 [INFO] rhsmd:3735:MainThread @rhsmd:261 - rhsmd started
2016-11-08 04:18:43,173 [INFO] rhsmd:3735:MainThread @connection.py:843 - Connection built: host=shwetha-workstation.usersys.redhat.com port=8443 handler=/candlepin auth=identity_cert ca_dir=/etc/rhsm/ca/ verify=False
2016-11-08 04:18:43,274 [INFO] rhsmd:3735:MainThread @cert_sorter.py:205 - Product status: valid_products= partial_products= expired_products= unentitled_producs=69 future_products= valid_until=None

Comment 10 errata-xmlrpc 2017-03-21 10:55:44 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.

https://rhn.redhat.com/errata/RHSA-2017-0698.html


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