Bug 1092594 - subscription-manager status --ondate=2000-01-01 is throwing wrong error message
Summary: subscription-manager status --ondate=2000-01-01 is throwing wrong error message
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: subscription-manager
Version: 5.11
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Bryan Kearney
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: rhsm-rhel511
TreeView+ depends on / blocked
 
Reported: 2014-04-29 14:14 UTC by John Sefler
Modified: 2014-09-16 00:22 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-16 00:22:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1225 0 normal SHIPPED_LIVE subscription-manager bug fix and enhancement update 2014-09-16 04:15:23 UTC

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


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