Hide Forgot
Description of problem: The following stdout message took me a few minutes to comprehend: "Cannot set a service level for a consumer that is not available to its organization." Can we improve that message to something like this: "Service level %s is not available to consumers of organization %s." Version-Release number of selected component (if applicable): [root@jsefler-r63-server ~]# rpm -q subscription-manager subscription-manager-0.99.7-1.git.7.87a8bc4.el6.x86_64 How reproducible: Steps to Reproduce: [root@jsefler-r63-server ~]# subscription-manager register --username testuser1 --password password --org admin --servicelevel foo --autosubscribe The system has been registered with id: 8a9caa4d-04a4-4472-94f0-0c826e6a1eeb Cannot set a service level for a consumer that is not available to its organization. ^^ In my opinion the following is a better message: Service level foo is not available to consumers of organization admin.
[root@jsefler-r63-server ~]# subscription-manager register --username testuser1 --password password --org admin --servicelevel foo --autosubscribe --force The system with UUID 0f8e7036-547e-46f5-b408-e19abefd97d4 has been unregistered The system has been registered with id: b68a8ef3-25a1-439b-ab8a-efa9964ca1b5 Cannot set a service level for a consumer that is not available to its organization. [root@jsefler-r63-server ~]# echo $? 255 [root@jsefler-r63-server ~]# subscription-manager identity Current identity is: b68a8ef3-25a1-439b-ab8a-efa9964ca1b5 name: jsefler-r63-server.usersys.redhat.com org name: Admin Owner org id: 8a90f814359d70fa01359d713c6b0007 [root@jsefler-r63-server ~]# I also believe that the 255 exit code is too extreme since the primary operation (register) actually succeeded, the secondary operation (autosubscribe) was aborted, and the option (servicelevel) failed. As detailed in bug 689608, an exit code of 0 is used to indicate that at least one autosubscribe bind occurred, and an exit code of 1 is used to indicate that no binds occurred. In this case I suggest a new exit code of 2 be returned to indicate the servicelevel setting failed.
[root@jsefler-r63-server ~]# subscription-manager subscribe --auto --servicelevel FOO Cannot set a service level for a consumer that is not available to its organization. [root@jsefler-r63-server ~]# echo $? 255 ^^^ Following the same arguments in comment 1, I think the exit code for this subscribe attempt should also be 2 instead of 255.
I think BK got the message changed already in b302e16f. Have discussed with the team and we're hesitant to make the error code change. The CLI is not designed for fine grained error handling today, all of our exits are either 1 or -1 (255), and this is just inconsistency, they have no specific meanings. Having 2 mean SLA couldn't be set may not be a great idea if every other possible error is 1 or 255. As per the linked bug, 1 does get returned if no bind could be done Going to move to modified for the string change. If the error code is a major issue for any reason then we can discuss and reopen accordingly, but ideally if fine grained error handling via exit codes is required, we should probably plan it out and implement it consistently.
Verifying Version.... [root@jsefler-r63-server ~]# rpm -q subscription-manager subscription-manager-0.99.12-1.git.1.2b349d3.el6.x86_64 [root@jsefler-r63-server ~]# subscription-manager register --username testuser1 --password password --org admin --servicelevel foo --autosubscribe --force The system has been registered with id: 3b2b5b52-da7a-4dee-9a51-6271cb01a17e Service level foo is not available to consumers of organization admin. [root@jsefler-r63-server ~]# echo $? 255 [root@jsefler-r63-server ~]# subscription-manager identity Current identity is: 3b2b5b52-da7a-4dee-9a51-6271cb01a17e name: jsefler-r63-server.usersys.redhat.com org name: Admin Owner org id: 8a90f81436542b200136542b439f0007 ^^^ NOTE THAT THE SYSTEM WAS SUCCESSFULLY REGISTERED DESPITE THE 255 EXIT CODE [root@jsefler-r63-server ~]# subscription-manager subscribe --auto --servicelevel foo Service level foo is not available to consumers of organization admin. [root@jsefler-r63-server ~]# echo $? 255 ^^^ THIS EXIT CODE SEEMS REASONABLE SINCE THE AUTOSUBSCRIBE ATTEMPT FAILED VERIFIED: The error message was clarified for the unavailable service level. VERIFIED: Despite a successful register while specifying an invalid servicelevel, an exit code of 255 is returned. While I believe this exit code is too harsh for this registration case, it does match the exit code of 255 from subscribe --auto --servicelevel foo which is reasonable. For now I am satisfied with this consistent behavior. Moving to VERIFIED
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-2012-0804.html