ceilometer image collector is not JSON serializable

Bug #1610376 reported by David Höppner
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloudkitty
Fix Released
Undecided
Guillaume Espanel

Bug Description

The image collector in cloudkitty/collector/ceilometer.py
fails with an JSON serialization error. The image resource is
not transformed in cloudkitty/transformer/ceilometer.py.

2016-08-05 17:28:12.738 32649 CRITICAL cloudkitty [-] TypeError: <Resource {u'user_id': None, u'links': [{u'href': u'http://127.0.0.1:8777/v2/resources/1f8440ce-
a865-4a44-86b3-9b45836d64e2', u'rel': u'self'}, {u'href': u'http://127.0.0.1:8777/v2/meters/image.size?q.field=resource_id&q.value=1f8440ce-a865-4a44-86b3-9b4583
6d64e2', u'rel': u'image.size'}, {u'href': u'http://127.0.0.1:8777/v2/meters/image?q.field=resource_id&q.value=1f8440ce-a865-4a44-86b3-9b45836d64e2', u'rel': u'i
mage'}, {u'href': u'http://127.0.0.1:8777/v2/meters/image.serve?q.field=resource_id&q.value=1f8440ce-a865-4a44-86b3-9b45836d64e2', u'rel': u'image.serve'}, {u'hr
ef': u'http://127.0.0.1:8777/v2/meters/image.download?q.field=resource_id&q.value=1f8440ce-a865-4a44-86b3-9b45836d64e2', u'rel': u'image.download'}], u'resource_
id': u'1f8440ce-a865-4a44-86b3-9b45836d64e2', u'source': u'openstack', u'last_sample_timestamp': u'2016-08-05T17:27:26.620705', u'first_sample_timestamp': u'2016
-08-05T16:07:14.542137', u'project_id': u'bbb825ef02184f68a0773bf2213a063d', u'metadata': {u'status': u'active', u'name': u'16.04', u'deleted': u'False', u'check
sum': u'4b78f51628454b723650103ce99fe636', u'created_at': u'2016-08-05T16:06:58.000000', u'disk_format': u'raw', u'updated_at': u'2016-08-05T16:07:14.000000', u'
properties.description': u'None', u'protected': u'False', u'container_format': u'bare', u'min_disk': u'0', u'is_public': u'False', u'deleted_at': u'None', u'min_
ram': u'0', u'size': u'320274432'}}> is not JSON serializable
2016-08-05 17:28:12.738 32649 ERROR cloudkitty Traceback (most recent call last):
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/usr/local/bin/cloudkitty-processor", line 10, in <module>
2016-08-05 17:28:12.738 32649 ERROR cloudkitty sys.exit(main())
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/opt/stack/cloudkitty/cloudkitty/cli/processor.py", line 28, in main
2016-08-05 17:28:12.738 32649 ERROR cloudkitty processor.process()
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/opt/stack/cloudkitty/cloudkitty/orchestrator.py", line 293, in process
2016-08-05 17:28:12.738 32649 ERROR cloudkitty worker.run()
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/opt/stack/cloudkitty/cloudkitty/orchestrator.py", line 212, in run
2016-08-05 17:28:12.738 32649 ERROR cloudkitty self._storage.append(data, self._tenant_id)
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/opt/stack/cloudkitty/cloudkitty/storage/__init__.py", line 227, in append
2016-08-05 17:28:12.738 32649 ERROR cloudkitty self._dispatch(data, tenant_id)
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/opt/stack/cloudkitty/cloudkitty/storage/sqlalchemy/__init__.py", line 69, in _dispatch
2016-08-05 17:28:12.738 32649 ERROR cloudkitty self._append_time_frame(service, frame, tenant_id)
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/opt/stack/cloudkitty/cloudkitty/storage/sqlalchemy/__init__.py", line 154, in _append_time_frame
2016-08-05 17:28:12.738 32649 ERROR cloudkitty desc = json.dumps(frame['desc'])
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/usr/lib/python2.7/json/__init__.py", line 243, in dumps
2016-08-05 17:28:12.738 32649 ERROR cloudkitty return _default_encoder.encode(obj)
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/usr/lib/python2.7/json/encoder.py", line 207, in encode
2016-08-05 17:28:12.738 32649 ERROR cloudkitty chunks = self.iterencode(o, _one_shot=True)
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/usr/lib/python2.7/json/encoder.py", line 270, in iterencode
2016-08-05 17:28:12.738 32649 ERROR cloudkitty return _iterencode(o, 0)
2016-08-05 17:28:12.738 32649 ERROR cloudkitty File "/usr/lib/python2.7/json/encoder.py", line 184, in default
2016-08-05 17:28:12.738 32649 ERROR cloudkitty raise TypeError(repr(o) + " is not JSON serializable")

David Höppner (0xffea)
Changed in cloudkitty:
assignee: nobody → David Höppner (0xffea)
Revision history for this message
xiaosuiba (xiaosuiba-b) wrote :

I got this problem too, hope u guys could fix it ASAP :)

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

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

Changed in cloudkitty:
status: New → In Progress
Revision history for this message
zhangguoqing (474751729-o) wrote :

It seems that network.bw.in, network.bw.out and network.floating also have the same problems, and I have fix them at https://review.openstack.org/#/c/355869/. good catch. :)

Revision history for this message
zhangguoqing (474751729-o) wrote :

The reason is ceilometer has switched to use Glance v2 in image pollsters.(https://review.openstack.org/#/c/349849/)
So the sample of image has not image_metadata attribute any longer.

Changed in cloudkitty:
assignee: David Höppner (0xffea) → Guillaume Espanel (guillaume-espanel)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cloudkitty (master)

Reviewed: https://review.openstack.org/359179
Committed: https://git.openstack.org/cgit/openstack/cloudkitty/commit/?id=161b9f593926a46412cdef5ba30353fb0a361d02
Submitter: Jenkins
Branch: master

commit 161b9f593926a46412cdef5ba30353fb0a361d02
Author: David Höppner <email address hidden>
Date: Tue Aug 23 14:48:13 2016 +0200

    ceilometer image collector is not JSON serializable

    Added a map and a method to the ceilometer transformer to
    serialize images.

    Change-Id: I29b991857851621b3632093159332d6be7a9053a
    Signed-off-by: David Höppner <email address hidden>
    Closes-Bug: #1610376
    Co-Authored-By: Guillaume Espanel <email address hidden>

Changed in cloudkitty:
status: In Progress → Fix Released
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.