Bug 1030604

Summary: subscription-manager repo-override should unwrap error list and print it to stderr
Product: Red Hat Enterprise Linux 7 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Michael Stead <mstead>
Status: CLOSED CURRENTRELEASE QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: ckozak, fsharath, mstead
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 10:25:23 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: 863175    

Description John Sefler 2013-11-14 19:10:38 UTC
Description of problem:
The new subscription-manager repo-override module should unwrap the error list and print it to stderr (not stdout) as demonstrated below...


Version-Release number of selected component (if applicable):
[root@jsefler-7 ~]# rpm -q subscription-manager
subscription-manager-1.10.7-1.git.0.15d737b.el7.x86_64


How reproducible:


Steps to Reproduce:
1. register and attach a subscription that provides yum repos, then using one of the valid repoids, call...

[root@jsefler-7 ~]# subscription-manager repo-override --repo=awesomeos-ppc --repo=foo --add=baseurl:https://cdn.redhat.com/foo-testing 1>/tmp/stdout 2>/tmp/stderr
[root@jsefler-7 ~]# echo $?
255
[root@jsefler-7 ~]# cat /tmp/stderr
[root@jsefler-7 ~]# cat /tmp/stdout
[The value for name 'baseurl' is not allowed to be overridden., The value for name 'baseurl' is not allowed to be overridden.]
[root@jsefler-7 ~]#

Actual results:
above


Expected results:
The 255 exit code is expected
The [The value for name 'baseurl' is not allowed to be overridden., The value for name 'baseurl' is not allowed to be overridden.] should not be printed as a list.  This should be unwrapped and unique values should be printed to stderr (not stdout) delimited by a new line.

Comment 1 Michael Stead 2013-11-22 19:12:03 UTC
This will be a two part fix -- one for subscription-manager and one for candlepin.

On candlepin, a BadRequestException was being created and thrown with a List.toString() as the message which produced the "[..., ...]" message string. Also, the messages in that list were being duplicated as seen above which isn't very useful.

The Fix: Invalid overrides are collected in a set and a single message will be returned in the following format:

"Not allowed to override values for: NAME1, NAME2, ..."


Changes were required in subscription-manager to changed the error code and to print to stderr.

As requested by jsefler (irc), it will now return a code of 1 instead of 255, and will write to stderr.

Component version and pull request numbers to follow once reviewed and committed.

Comment 2 Michael Stead 2013-12-04 16:25:18 UTC
candlepin pull request (currently merged and in master branch):
https://github.com/candlepin/candlepin/pull/439

subscription-manager pull request (waiting on review and merge):
https://github.com/candlepin/subscription-manager/pull/836

Comment 3 Michael Stead 2013-12-04 18:43:32 UTC
Error code and stderr printing available in:
subscription-manager-1.10.8-1

Proper message formatting available in:
candlepin-0.8.34-1+

Comment 5 John Sefler 2013-12-06 19:32:30 UTC
Testing Version...
[root@jsefler-7 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.8.33-1
subscription-manager: 1.10.8-1.el7
python-rhsm: 1.10.8-1.el7


[root@jsefler-7 ~]# subscription-manager repo-override --repo=repo1 --repo=repo2 --repo=repo3 --add=baseurl:https://cdn.redhat.com/foo-testing --add=name:repoName --add=enabled:1 --add=label:repoLabel 1>/tmp/stdout 2>/tmp/stderr
[root@jsefler-7 ~]# echo $?
1
[root@jsefler-7 ~]# cat /tmp/stderr
Not allowed to override values for: name, label, baseurl
[root@jsefler-7 ~]# cat /tmp/stdout
[root@jsefler-7 ~]# 


VERIFIED: The feedback message is now nicely unwrapped and rendered uniquely.

For the sake of consistency with exitCode/stdout/stderr behavior from other subscription-manager commands, I would suggest that we keep the exitCode of 1 (which indicates the call was not completely successful (usually exitCode=0), but we were also not crashing and burning (usually exitCode=255)).  However, let's move the feedback message to stdout since stderr is usually accompanied by exitCode 255.

FAILEDQA: Move the message from stderr to stdout.

Comment 6 Michael Stead 2013-12-06 19:45:08 UTC
Awaiting PR Review:

https://github.com/candlepin/subscription-manager/pull/844

Print error to stdout, and exit with code 1.

Comment 7 Michael Stead 2014-01-06 14:30:49 UTC
Available:

subscription-manager-1.10.9-1+

Comment 8 Sharath Dwaral 2014-01-24 17:40:49 UTC
Version

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.2-1
subscription-manager: 1.10.11-1.git.2.e96f6cd.el7
python-rhsm: 1.10.11-1.git.0.17362f9.el7

Verification

# subscription-manager repo-override --repo=repo1 --repo=repo2 --repo=repo3 --add=baseurl:https://cdn.redhat.com/foo-testing --add=name:repoName --add=enabled:1 --add=label:repoLabel > /tmp/stdout 2> /tmp/stderr

# echo $?
1

# cat /tmp/stdout
Not allowed to override values for: name, label, baseurl

# cat /tmp/stderr 
# 


Message displayed in stdout
Exit code is 1

VERIFIED

Comment 9 Ludek Smid 2014-06-13 10:25:23 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.