RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1132981 - registering with an activation key with no installed products does not register cleanly
Summary: registering with an activation key with no installed products does not regist...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: subscription-manager
Version: 6.6
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Chris "Ceiu" Rog
QA Contact: John Sefler
URL:
Whiteboard:
: 1138675 (view as bug list)
Depends On:
Blocks: rhsm-rhel67
TreeView+ depends on / blocked
 
Reported: 2014-08-22 13:25 UTC by Justin Sherrill
Modified: 2015-07-22 06:52 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-07-22 06:52:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:1345 0 normal SHIPPED_LIVE subscription-manager and python-rhsm bug fix and enhancement update 2015-07-20 17:59:53 UTC

Description Justin Sherrill 2014-08-22 13:25:16 UTC
Description of problem:

If you are on a system with no installed products, registering with an activation key registers fine but prints:

"No Products Installed"

and then exits with a non-zero exit code.

Example:

[root@dhcp129-239 ~]# subscription-manager register --activationkey=asdf --force --org="Default_Organization"
The system with UUID a3116495-d1da-4e05-8c24-b1c1f29303a2 has been unregistered
The system has been registered with ID: 58b17960-454b-4ef5-81f4-250d9e4891f2 
No products installed.
[root@dhcp129-239 ~]# echo $?
1


Version-Release number of selected component (if applicable):
subscription-manager-1.12.3-1.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. rm -rf /etc/pki/products/   (or just use centos)
2. With that version of subscription manager, register with an activation key


Actual results:
Non-zero exit code

Expected results:
Exit code of 1

Additional info:

Comment 1 John Sefler 2014-08-22 13:33:48 UTC
The "No Products Installed" behavior looks like a consequence of bug 1123014

Comment 2 Justin Sherrill 2014-08-22 14:42:59 UTC
Sorry, should be:


Expected results:
Exit code of 0

Comment 3 Pavel Studeník 2014-09-08 10:02:57 UTC
Same problem exists when you try to register system by consumerid

subscription-manager register --org="Default_Organization" --consumerid="34f08233-e625-4f8b-abd5-792651ffc9e7"  --username=<USER> --password=<PASS>

echo $?
>> 1

Comment 4 Stephen Benjamin 2014-09-09 14:15:02 UTC
*** Bug 1138675 has been marked as a duplicate of this bug. ***

Comment 5 Bryan Kearney 2014-11-03 19:48:24 UTC
Moving bugs to 6.7

Comment 6 Bryan Kearney 2014-11-03 19:49:21 UTC
Moving bugs to 6.7

Comment 7 Bryan Kearney 2014-11-03 19:54:10 UTC
Moving bugs to 6.7

Comment 8 John Sefler 2014-12-08 16:14:54 UTC
(In reply to Pavel Studeník from comment #3)
> Same problem exists when you try to register system by consumerid
> 
> subscription-manager register --org="Default_Organization"
> --consumerid="34f08233-e625-4f8b-abd5-792651ffc9e7"  --username=<USER>
> --password=<PASS>
> 
> echo $?
> >> 1

The erroneous exitCode from registering with a consumerid is not the same problem as comment 0; no activation key is involved.   This issue has been fixed by bug 1145835.

Comment 9 Chris "Ceiu" Rog 2014-12-08 16:41:17 UTC
commit afd16e96d89ff38f74c60fd23613b67e27da17c5
Author: Chris Rog <crog>
Date:   Mon Dec 8 11:17:15 2014 -0500

    1132981: Fixed exit code when registering system with no products installed
    
    - When registering a system that does not have any products installed via
      consumerid or activation key, the system will no longer return an exit
      code of 1.

Comment 10 John Sefler 2014-12-11 23:20:56 UTC
(In reply to Chris Rog from comment #9)
> commit afd16e96d89ff38f74c60fd23613b67e27da17c5

shows the following code change...

 def show_autosubscribe_output(uep):
     installed_status = get_installed_product_status(inj.require(inj.PROD_DIR),
             inj.require(inj.ENT_DIR), uep)
+
     if not installed_status:
-        print _("No products installed.")
-        return 1
+        # Returning an error code here breaks registering when no products are installed, and the
+        # AttachCommand already performs this check before calling.
+        return 0


I disagree with this change for two reasons:

1. It is a regression of long-time behavior bug 689608 which explicitly asks for a non-zero exit code when no entitlements are granted during an auto subscribe.  I suspect that Justin's activation key contained an "auto-attach" field which is why his activation key was trying to auto subscribe.  If yes, then the exit code of 1 is working as designed and the feedback of "No products installed." is a clue to tell him why.

2. It is a regression of usability bug 962545 which explicitly added "No products installed." as feedback during a call to subscription-manager register --autosubscribe

In my opinion, commit afd16e96d89ff38f74c60fd23613b67e27da17c5 should be reverted and the response to this bug is close it, working as designed, because the next guy who tries to register with an activation key that contains an auto-attach=true attribute and gets no entitlements with no feedback and an exit code of zero is going to question...  "Why didn't my activation key give me a subscription?".

Comment 11 Justin Sherrill 2014-12-11 23:48:10 UTC
John,

I do not believe that the activation key had auto-attach set to true.  I will do testing though to verify.  Regardless, I'm not sure that auto-attach should be considered 'failure' if there are no installed products.  In that situation auto-attach is a no-op and should not fail.  the way I see all installed products (none) properly had a subscription attached so the system is 'green'.  If it had a single installed product for which a subscription could not be found then it should fail.  But i could see where that is up for debate.

I think that https://bugzilla.redhat.com/show_bug.cgi?id=689608 was making an assumption that all systems would have installed products, which is not the case for cent os and rhel derivatives that katello supports. 

-Justin

Comment 12 Justin Sherrill 2014-12-11 23:48:50 UTC
I would say that it should still print a warning if no products are installed.

Comment 13 John Sefler 2014-12-12 16:50:50 UTC
(In reply to Justin Sherrill from comment #12)
> I would say that it should still print a warning if no products are

QE agreed

I would also say that we are overloading the meaning of the exit code value which is very difficult to understand since a non-zero does not necessarily imply a failure as Justin interpreted it in comment 0.  The exit code of 1 in comment 0 was supposed to be interpreted to mean that no entitlements were granted as a result of the transaction (as designed in bug 689608).  Moreover, we also are combining two operations (register and subscribe) into one call that returns one exit code.  I don't think there is any correct answer here other than to stop making decisions on the exit code from registering with activationkey/autosubscribe options.

Comment 14 Chris "Ceiu" Rog 2014-12-19 15:24:38 UTC
commit b9e42b05ebd3529c25dc18a520e3f7a85db1b939
Author: Chris Rog <crog>
Date:   Fri Dec 12 12:30:37 2014 -0500

    1132981: Reverted removal of warning message

Comment 16 Shwetha Kallesh 2015-04-24 06:50:26 UTC
exit code is now 0,hence marking verified!!

[root@dhcp35-236 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.49-1
subscription management rules: 5.15
subscription-manager: 1.14.5-1.el6
python-rhsm: 1.14.2-1.el6


[root@dhcp35-236 ~]# subscription-manager register --force --activationkey Test_key2 --org donaldduck
The system has been registered with ID: 1fc6846b-4f30-432f-aecb-ca13bce56609 
2 local certificates have been deleted.

No products installed.
[root@dhcp35-236 ~]# echo $?
0

Comment 17 errata-xmlrpc 2015-07-22 06:52:21 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/RHBA-2015-1345.html


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