Bug 1030604 - subscription-manager repo-override should unwrap error list and print it to stderr
subscription-manager repo-override should unwrap error list and print it to s...
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: subscription-manager (Show other bugs)
7.0
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Michael Stead
John Sefler
:
Depends On:
Blocks: rhsm-rhel70
  Show dependency treegraph
 
Reported: 2013-11-14 14:10 EST by John Sefler
Modified: 2014-06-17 20:28 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-13 06:25:23 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Sefler 2013-11-14 14:10:38 EST
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 14:12:03 EST
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 11:25:18 EST
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 13:43:32 EST
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 14:32:30 EST
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 14:45:08 EST
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 09:30:49 EST
Available:

subscription-manager-1.10.9-1+
Comment 8 Sharath Dwaral 2014-01-24 12:40:49 EST
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 06:25:23 EDT
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.

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