V2 API wrong type error

Bug #1124350 reported by Janis Gengeris
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
High
Julien Danjou

Bug Description

When making the following call against v2 API:

http://172.16.16.5:8777/v2/meters/cpu_util/statistics?q[0].field=project_id&q[0].op=eq&q[0].value=979ebc48904d46dfa3caa55930dc32ae&q[1].field=timestamp&q[1].op=gt&q[1].value=2013-02-13T16:00:00

HTTP 500 status code is returned in response. Response body:
{
  "error_message" : "{\"debuginfo\": null, \"faultcode\": \"Server\", \"faultstring\": \"count: Wrong type. Expected '<type 'int'>', got '<type 'float'>'\"}"
}

Log from API server:
2013-02-13 17:30:21,656 ERROR [wsme.api][MainThread] Server-side error: "count: Wrong type. Expected '<type 'int'>', got '<type 'float'>'". Detail:
Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/wsmeext/pecan.py", line 68, in callfunction
    result = f(self, *args, **kwargs)

  File "/opt/stack/ceilometer/ceilometer/api/controllers/v2.py", line 390, in statistics
    **computed)

  File "/opt/stack/ceilometer/ceilometer/api/controllers/v2.py", line 297, in __init__
    super(Statistics, self).__init__(**kwds)

  File "/usr/local/lib/python2.7/dist-packages/wsme/types.py", line 552, in __init__
    setattr(self, key, value)

  File "/usr/local/lib/python2.7/dist-packages/wsme/types.py", line 326, in __set__
    raise ValueError("%s: %s" % (self.name, e))

ValueError: count: Wrong type. Expected '<type 'int'>', got '<type 'float'>'

Julien Danjou (jdanjou)
Changed in ceilometer:
assignee: nobody → Julien Danjou (jdanjou)
importance: Undecided → High
Revision history for this message
Julien Danjou (jdanjou) wrote :

What's the storage backend you're using?

Revision history for this message
Janis Gengeris (janisg) wrote :

Mongo

Revision history for this message
Julien Danjou (jdanjou) wrote :

Rah, I don't see where this come from. The problem seems to be count is returned as a float, but nowhere there's something playing with a float. Count is just += 1 each time in the map reduce and returned as it is. In the unit tests, I do see that count is always returned as an integer by pymongo, either using MIM or MongoDB.

Any chance you can print what's the storage driver returns around line 390 in v2.py?

Revision history for this message
Janis Gengeris (janisg) wrote :

These are the contents of **computed, that is passed to Statistics on line 388.

{ u'avg': 3.221239598055515,
    u'count': 251.0,
    u'duration': 75612.0,
    u'max': 5.790748524185662,
    u'min': 0.0,
    u'sum': 808.5311391119343,
    u'timestamp_max': datetime.datetime(2013, 2, 14, 13, 29, 14),
    u'timestamp_min': datetime.datetime(2013, 2, 13, 16, 29, 2)}

Revision history for this message
Julien Danjou (jdanjou) wrote :

Thanks, that helps. So pymongo (?) converts this integer into a float for no apparent reason. Which version of pymongo do you have?

Revision history for this message
Julien Danjou (jdanjou) wrote :

Also, I think we don't have API unit tests running on real MongoDB with CEILOMETER_TEST_LIVE=1, we need to fix that.

Revision history for this message
Julien Danjou (jdanjou) wrote :

Got it, running the API tests against a real MongoDB reproduces this.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ceilometer (master)

Fix proposed to branch: master
Review: https://review.openstack.org/21969

Changed in ceilometer:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ceilometer (master)

Reviewed: https://review.openstack.org/21969
Committed: http://github.com/openstack/ceilometer/commit/79b2b43530743f6ebb341aec0e37920dfee373f1
Submitter: Jenkins
Branch: master

commit 79b2b43530743f6ebb341aec0e37920dfee373f1
Author: Julien Danjou <email address hidden>
Date: Thu Feb 14 15:20:48 2013 +0100

    mongodb: make count an integer explicitely

    This fixes bug #1124350

    Change-Id: I389a3f228fd3e1718d242189d9579a3b56852ca1
    Signed-off-by: Julien Danjou <email address hidden>

Changed in ceilometer:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: none → grizzly-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in ceilometer:
milestone: grizzly-3 → 2013.1
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.