Running "swift list --lh" with out a bucket causes type error in python

Bug #1349528 reported by ray
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
python-swiftclient
Fix Released
Undecided
Unassigned

Bug Description

Running "swift list --lh" without specifying a container generates type error as seen below.
We are running ubuntu 14.04 with the python-swiftclient 1:2.0.3-0ubuntu1 form the repos. We are running Ceph's librados gateway version 0.82-524-gbf04897 as a our swift endpoint. I do not have a openstack swift endpoint store to test to see if the client behaves the same way

To reproduce just run "swift list --lh" and see below error. I had to sanitize the debug output by replacing the tokens, url, and container.name with XXXXX, YYYYY,ZZZZ.

---------------------
Ubuntu 14.04
ii python-swiftclient 1:2.0.3-0ubuntu1 all Client library for Openstack Swift API.
ceph version 0.82-524-gbf04897 (bf048976f50bd0142f291414ea893ef0f205b51a)

$ swift list --lh
Traceback (most recent call last):
  File "/usr/bin/swift", line 1479, in <module>
    globals()['st_%s' % args[0]](parser, argv[1:], thread_manager)
  File "/usr/bin/swift", line 584, in st_list
    utc = gmtime(float(meta.get('x-timestamp')))
TypeError: float() argument must be a string or a number

$ swift list --lh XXX.YYYY
0

swift --debug list --lh
DEBUG:urllib3.connectionpool:Setting read timeout to <object object at 0x7ff2bebf6090>
DEBUG:urllib3.connectionpool:"HEAD /swift/v1/YYYY.YYYY HTTP/1.1" 204 0
DEBUG:swiftclient:REQ: curl -i http://XXXXX/swift/v1/XXX -I -H "X-Auth-Token: ZZZZZZ"
DEBUG:swiftclient:RESP STATUS: 204 No Content
DEBUG:swiftclient:RESP HEADERS: [('x-container-object-count', '0'), ('server', 'Apache/2.2.22 (Ubuntu)'), ('x-container-bytes-used-actual', '0'), ('x-container-bytes-used', '0'), ('date', 'Mon, 28 Jul 2014 18:14:14 GMT'), ('content-type', 'text/plain; charset=utf-8')]
Traceback (most recent call last):
  File "/usr/bin/swift", line 1479, in <module>
    globals()['st_%s' % args[0]](parser, argv[1:], thread_manager)
  File "/usr/bin/swift", line 584, in st_list
    utc = gmtime(float(meta.get('x-timestamp')))
TypeError: float() argument must be a string or a number

Changed in python-swiftclient:
status: New → Confirmed
Revision history for this message
Ashish Chandra (ashish-chandra) wrote :

The issue can be seen only when using Ceph RadosGW. With openstack swift endpoint store we get the output as expected.

ashish@openstack-master:~$ swift list
new_cont
ashish@openstack-master:~$ swift list --lh
    5 165K 2014-07-28 11:17:09 new_cont
    5 165K

But with Ceph RadosGW we have:

ashish@firefly-master:~$ swift list --lh
Traceback (most recent call last):
  File "/usr/local/bin/swift", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/opt/stack/python-swiftclient/bin/swift", line 24, in <module>
    sys.exit(main())
  File "/opt/stack/python-swiftclient/swiftclient/shell.py", line 1600, in main
    globals()['st_%s' % args[0]](parser, argv[1:], thread_manager)
  File "/opt/stack/python-swiftclient/swiftclient/shell.py", line 602, in st_list
    utc = gmtime(float(meta.get('x-timestamp')))
TypeError: float() argument must be a string or a number

Revision history for this message
Jiri Suchomel (jsuchome) wrote :

This seems to be a bug in radosgw. For an ugly workaround, something like this could help

584,585c584,589
< utc = gmtime(float(meta.get('x-timestamp')))
< datestamp = strftime('%Y-%m-%d %H:%M:%S', utc)
---
> timestamp = meta.get('x-timestamp')
> if timestamp is None:
> datestamp = '????-??-?? ??:??:??'
> else:
> utc = gmtime(float(timestamp))
> datestamp = strftime('%Y-%m-%d %H:%M:%S', utc)

For nicer workaround, there could be iteration over existing object to find the latest modification. But I'm not sure it's worthy.

Revision history for this message
Christian Schwede (cschwede) wrote :

As already said in the review (https://review.openstack.org/#/c/124856/), this is something that should be fixed in radosgw, not as a workaround in python-swiftclient. IMO the list result should include the x-timestamp value, otherwise there is a difference to the Swift API and this should not be handled on the client side.

Apart from that iterating over all the objects just to get the latest timestamp might be okay if you only have a few objects, but not if there are tens of thousands or even more objects.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-swiftclient (master)

Reviewed: https://review.openstack.org/124856
Committed: https://git.openstack.org/cgit/openstack/python-swiftclient/commit/?id=21fb6f6798015f9f3b9744cf660bdf01822f4b54
Submitter: Jenkins
Branch: master

commit 21fb6f6798015f9f3b9744cf660bdf01822f4b54
Author: Jiří Suchomel <email address hidden>
Date: Mon Sep 29 22:13:06 2014 +0200

    Do not crash with "swift list --lh" for Ceph RadosGW.

    If 'x-timestamp' header is not present in 'swift list' result,
    date string cannot be correctly generated. Check for correct
    exception to catch this case and return a special string value.
    This is just a workaround for faulty RadosGW behavior.

    Change-Id: I172843a2668e33efac00924906ff0dca3e790050
    Closes-Bug: 1349528

Changed in python-swiftclient:
status: Confirmed → Fix Committed
Changed in python-swiftclient:
status: Fix Committed → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/python-swiftclient 2.4.0

This issue was fixed in the openstack/python-swiftclient 2.4.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.