Filtering by "metadata.size" in v2/meters/image apparently is not working

Bug #1200577 reported by Alessandro Barabesi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ceilometer
Fix Released
High
Feilong Wang

Bug Description

Requests for samples with metadata.size>0 returns also samples with metadata.size=0

Example:

GET http://10.10.10.10:8777/v2/meters/image

{
 "q": [{
  "field": "project_id",
  "op": "eq",
  "value": "77b461539c8542909f67b29939ec87dd"
 },
 {
  "field": "timestamp",
  "op": "ge",
  "value": "2013-07-11T13:38:00"
 },
 {
  "field": "timestamp",
  "op": "lt",
  "value": "2013-07-11T13:39:00"
 },
 {
  "field": "metadata.size",
  "op": "gt",
  "value": "0"
 }]

}

response:

[{
 "counter_name": "image",
 "user_id": null,
 "resource_id": "4b8db07f-dbb5-4867-a2fd-abe80ea31558",
 "timestamp": "2013-07-11T13:38:35",
 "resource_metadata": {
  "status": "queued",
  "name": "Ist_03_Ale_Test_03_Snap_01",
  "deleted": "False",
  "container_format": "None",
  "created_at": "2013-07-11T13:38:33",
  "disk_format": "None",
  "updated_at": "2013-07-11T13:38:33",
  "protected": "False",
  "checksum": "None",
  "min_disk": "0",
  "is_public": "False",
  "deleted_at": "None",
  "min_ram": "0",
  "size": "0"
 },
 "source": "openstack",
 "counter_unit": "image",
 "counter_volume": 1.0,
 "project_id": "77b461539c8542909f67b29939ec87dd",
 "message_id": "2f5e8030-ea2f-11e2-b991-00259075703e",
 "counter_type": "gauge"
},
{
 "counter_name": "image",
 "user_id": null,
 "resource_id": "44431fb9-000c-4bcf-94ca-41f21d9708fb",
 "timestamp": "2013-07-11T13:38:35",
 "resource_metadata": {
  "status": "active",
  "name": "Ist_01_Ale_Test_03_Snap_02",
  "deleted": "False",
  "container_format": "bare",
  "created_at": "2013-07-11T11:16:41",
  "disk_format": "qcow2",
  "updated_at": "2013-07-11T11:16:56",
  "protected": "False",
  "checksum": "e53eea59ad77acddc989a4470403a9f3",
  "min_disk": "0",
  "is_public": "False",
  "deleted_at": "None",
  "min_ram": "0",
  "size": "14024704"
 },
 "source": "openstack",
 "counter_unit": "image",
 "counter_volume": 1.0,
 "project_id": "77b461539c8542909f67b29939ec87dd",
 "message_id": "2f5e8f80-ea2f-11e2-b991-00259075703e",
 "counter_type": "gauge"
}]

same response using

{
  "field": "metadata.size",
  "op": "ne",
  "value": "0"
}

instead of

 {
  "field": "metadata.size",
  "op": "gt",
  "value": "0"
 }

Feilong Wang (flwang)
Changed in ceilometer:
assignee: nobody → Fei Long Wang (flwang)
Revision history for this message
Alessandro Barabesi (abarabesi) wrote :

I just tested operator "eq"

using

{
  "field": "metadata.size",
  "op": "eq",
  "value": "0"
}

ceilometer returns an empty reply.

Julien Danjou (jdanjou)
Changed in ceilometer:
status: New → Triaged
importance: Undecided → High
Feilong Wang (flwang)
Changed in ceilometer:
status: Triaged → In Progress
Revision history for this message
Feilong Wang (flwang) wrote :

I can recreate this issue. The root cause is the value type of "metadata.size" is string not integer. However, the "metadata.size" is stored as integer in DB. After workaround, it works. Now I'm thinking how to figure out the value type for different meta data.

Revision history for this message
Feilong Wang (flwang) wrote :

After further investigation, I found user will run into same issue when querying a meta data with boolean type, such as "is_public" of image. So we need a better way to determine the value type of meta data to get correct result from DB.

Revision history for this message
Feilong Wang (flwang) wrote :

As for the non "eq" operations of meta data, which are not supported for now. Please take this link https://github.com/openstack/ceilometer/blob/master/ceilometer/api/controllers/v2.py#L184 as reference.

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/38795

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

Reviewed: https://review.openstack.org/38795
Committed: http://github.com/openstack/ceilometer/commit/0236768b7eaa695ecc5cf9f3e91b12afd354232d
Submitter: Jenkins
Branch: master

commit 0236768b7eaa695ecc5cf9f3e91b12afd354232d
Author: Fei Long Wang <email address hidden>
Date: Sat Jul 27 23:44:29 2013 +0800

    Fixes non-string metadata query issue

    Based on current wsme implement, all the metadata query will get
    the metadata value as string type. As a result, all the non-string
    metadata query will not get correct result. Since the data is store
    in database with correct data type. The fix will try to eval the
    value before setting so as to get the correct data type.

    Fixes bug 1200577

    Change-Id: I8114e816da123b9dc08f32f9022db0e1b9fc2e5a

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