Bug 1092594

Summary: subscription-manager status --ondate=2000-01-01 is throwing wrong error message
Product: Red Hat Enterprise Linux 5 Reporter: John Sefler <jsefler>
Component: subscription-managerAssignee: Bryan Kearney <bkearney>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 5.11CC: alikins, bkearney, fsharath
Target Milestone: rcKeywords: Regression
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-16 00:22:44 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: 1039651    

Description John Sefler 2014-04-29 14:14:10 UTC
Description of problem:
The subscription-manager status --ondate with a past date in valid format is throwing the wrong error.  This appears to work on rhel6 and rhel7, but is failing on rhel5.11.

Version-Release number of selected component (if applicable):
[root@jsefler-5 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 0.9.10-1
subscription-manager: 1.11.3-1.git.12.94c021f.el5
python-rhsm: 1.11.3-2.git.0.5968608.el5


How reproducible:


Steps to Reproduce:
[root@jsefler-5 ~]# subscription-manager status --ondate=2000-01-01
Past dates are not allowed
Date entered is invalid. Date should be in YYYY-MM-DD format (example: 2014-04-29 )


Actual results:
above

Expected results:
should not have been told the format is wrong

Additional info:

Comment 1 RHEL Program Management 2014-04-29 14:18:42 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.

Comment 3 Adrian Likins 2014-04-29 15:38:06 UTC
The python 2.4 sys.exit/Exception this seems to be in play here.

        if self.options.on_date:
              try:
                  # doing it this ugly way for pre python 2.5
                  on_date = datetime.datetime(
                          *(strptime(self.options.on_date, '%Y-%m-%d')[0:6]))
                  if on_date.date() < datetime.datetime.now().date():
                      print (_("Past dates are not allowed"))
                      sys.exit(1)
                  self.sorter = ComplianceManager(on_date)
              except Exception:
                  print(_("Date entered is invalid. Date should be in YYYY-MM-DD format (example: ") + strftime("%Y-%>
                  sys.exit(1)

The first system.exit() raise SystemExit, which the "except Exception" will catch
it, show the "Date entered is invalid. Date should be..." error, and sys.exit again.

Could either check exception type is not SystemExit in the handler, or change to avoid the earlier sys.exit(). Or figure out a more specific exceptions to catch in stead of "Exception".

Comment 4 Adrian Likins 2014-04-29 15:39:47 UTC
except StandardError

instead of

except Exception


would probably work

Comment 5 Carter Kozak 2014-04-29 15:41:53 UTC
commit 4a716dfe6997846afb8769cb99343c6054a917b5
Author: Carter Kozak <ckozak>
Date:   Tue Apr 29 10:42:14 2014 -0400

    1092594: don't catch SystemExit for past dates in "status --ondate=x"

Comment 8 Sharath Dwaral 2014-05-21 19:34:10 UTC
Version:

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.12-1
subscription-manager: 1.11.3-3.el5
python-rhsm: 1.11.3-3.el5

Verfication:

Past Date:

# subscription-manager status --ondate=2008-02-29
Past dates are not allowed

Present date:

# subscription-manager status --ondate=2014-05-21
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

Future Date:

# subscription-manager status --ondate=2016-02-29
+-------------------------------------------+
   System Status Details
+-------------------------------------------+
Overall Status: Current

Invalid Dates:

# subscription-manager status --ondate=2017-04-31
Date entered is invalid. Date should be in YYYY-MM-DD format (example: 2014-05-21 )

# subscription-manager status --ondate=2017-02-29
Date entered is invalid. Date should be in YYYY-MM-DD format (example: 2014-05-21 )


VERIFIED

Comment 11 errata-xmlrpc 2014-09-16 00:22: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.

http://rhn.redhat.com/errata/RHBA-2014-1225.html