Bug 700122

Summary: Consumer List from pulp-admin fails on RHEL5 (date parsing issue)
Product: [Retired] Pulp Reporter: Todd Sanders <tsanders>
Component: z_otherAssignee: Jay Dobies <jason.dobies>
Status: CLOSED CURRENTRELEASE QA Contact: Preethi Thomas <pthomas>
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: jason.dobies
Target Milestone: ---Keywords: Triaged
Target Release: Sprint 23   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-16 12:09:40 UTC Type: ---
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: 647488    

Description Todd Sanders 2011-04-27 14:15:16 UTC
Description of problem:

Traceback:

Traceback (most recent call last):
File "/usr/bin/pulp-admin", line 174, in ?
admin.main()
File "/usr/lib/python2.4/site-packages/pulp/client/cli/base.py", line 137, in main
command.main(args[1:])
File "/usr/lib/python2.4/site-packages/pulp/client/core/base.py", line 118, in main
action.main(args[1:])
File "/usr/lib/python2.4/site-packages/pulp/client/core/base.py", line 226, in main
self.run()
File "/usr/lib/python2.4/site-packages/pulp/client/core/consumer.py", line 92, in run
last_heartbeat = json_utils.parse_iso_date(stat[1])
File "/usr/lib/python2.4/site-packages/pulp/client/json_utils.py", line 48, in parse_iso_date
return datetime.strptime(iso_str[:19], ISOFORMAT)
AttributeError: type object 'datetime.datetime' has no attribute 'strptime'

Issue relates to datetime.datetime.strptime() being introduced in python 2.5.  Looks like something fairly new we added to pulp with this commit (4/7/11):  http://git.fedorahosted.org/git/?p=pulp.git;a=commitdiff;h=1a927fde705ac13de95004e7524018cf006806be

Comment 1 Todd Sanders 2011-04-27 14:19:54 UTC
<jortel> alcy:  when you get a chance, I believe this: http://www.fpaste.org/n8dI/ is the patch you need.

   1. diff --git a/src/pulp/client/json_utils.py b/src/pulp/client/json_utils.py
   2. index 1b7af72..e5d8782 100644
   3. --- a/src/pulp/client/json_utils.py
   4. +++ b/src/pulp/client/json_utils.py
   5. @@ -17,6 +17,7 @@
   6. Utilities for parsing and formatting of JSON values.
   7. '''
   8.
   9. +import time
  10. from datetime import datetime
  11.
  12. ISOFORMAT = '%Y-%m-%dT%H:%M:%S'
  13. @@ -45,4 +46,4 @@ def parse_iso_date(iso_str):
  14. @return: python object representing the date
  15. @rtype: L{datetime.datetime} instance
  16. """
  17. - return datetime.strptime(iso_str[:19], ISOFORMAT)
  18. + return datetime(*(time.strptime(iso_str[:19], ISOFORMAT)[0:6]))

Comment 2 Todd Sanders 2011-04-27 14:21:16 UTC
We need to patch the CR10 Build.  This means from tag, as there have already been numerous commits to master.

Comment 3 Jay Dobies 2011-04-27 19:33:10 UTC
commit	8a9562f6d9a3741d2220b64914e8e612c04437ba
tree	fccf733a0d27f426271c473dd89bd657242eaa37


700122 - Fixed ISO date formatting for python 2.4 compatibility.


src/pulp/client/json_utils.py
test/unit/test_json_utils.py


Added a unit test for this as well so we can take advantage of our hudson builders to detect these sorts of incompabilities.

Comment 4 Jay Dobies 2011-04-27 20:11:37 UTC
Fixed in Pulp 0.172, grinder 0.96.

Comment 5 Preethi Thomas 2011-04-28 17:43:58 UTC
verified

[root@pulp-qe-rhel5 ~]# pulp-admin consumer list
+------------------------------------------+
            Consumer Information
+------------------------------------------+
[root@pulp-qe-rhel5 ~]# pulp-admin consumer list
+------------------------------------------+
            Consumer Information
+------------------------------------------+

Id                 	rhel5-client             
Description        	None                     
Subscribed Repos   	[]                       
Agent:
   Responding      	Yes                      
   Last Heartbeat  	2011-04-28 17:31:24      
Additional info    	                         

[root@pulp-qe-rhel5 ~]# rpm -q pulp
pulp-0.0.172-1
[root@pulp-qe-rhel5 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 5.5 (Tikanga)

Comment 6 Preethi Thomas 2011-08-16 12:09:40 UTC
Closing with Community Release 15

pulp-0.0.223-4.

Comment 7 Preethi Thomas 2011-08-16 12:22:04 UTC
Closing with Community Release 15

pulp-0.0.223-4.