Python3: decode error in rbd.py _get_pool_stats()

Bug #1771552 reported by Thomas Goirand
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Eric Harney

Bug Description

When Cinder is configured with RBD backend, and when using Python 3, it just fails in _get_pool_stats():

   File "/usr/lib/python3/dist-packages/oslo_service/service.py", line 729, in run_service
     service.start()
   File "/usr/lib/python3/dist-packages/cinder/service.py", line 225, in start
     service_id=Service.service_id)
   File "/usr/lib/python3/dist-packages/cinder/volume/manager.py", line 457, in init_host
     self.driver.init_capabilities()
   File "/usr/lib/python3/dist-packages/cinder/volume/driver.py", line 713, in init_capabilities
     stats = self.get_volume_stats(True)
   File "/usr/lib/python3/dist-packages/cinder/volume/drivers/rbd.py", line 508, in get_volume_stats
     self._update_volume_stats()
   File "/usr/lib/python3/dist-packages/cinder/volume/drivers/rbd.py", line 491, in _update_volume_stats
     free_capacity, total_capacity = self._get_pool_stats()
   File "/usr/lib/python3/dist-packages/cinder/volume/drivers/rbd.py", line 434, in _get_pool_stats
     df_data = json.loads(df_outbuf)
   File "/usr/lib/python3.5/json/__init__.py", line 312, in loads
     s.__class__.__name__))
 TypeError: the JSON object must be str, not 'bytes'

The solution is to simply call .decode("UTF-8"). I'm following-up with a patch.

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

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

Changed in cinder:
assignee: nobody → Thomas Goirand (thomas-goirand)
status: New → In Progress
Changed in cinder:
assignee: Thomas Goirand (thomas-goirand) → Eric Harney (eharney)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/568813
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=d156030338ba10980b85704602e5085fffb32124
Submitter: Zuul
Branch: master

commit d156030338ba10980b85704602e5085fffb32124
Author: Thomas Goirand <email address hidden>
Date: Wed May 16 13:07:36 2018 +0200

    Fix rbd driver json loading

    It looks like rbd.py sometimes gets some bytes, not strings, probably
    this happens with the latest version of Ceph, and that's an issue only
    with Python 3. I'm not sure why, but what I know, is that it's completely
    breaking Debian with Python 3 and ceph Luminous release.

    Convert byte buffers coming from Ceph to strings.

    Co-Authored-By: Eric Harney <email address hidden>
    Change-Id: I5cdb4e766655a866699a18f1e367971fd1d310af
    Closes-Bug: #1771552

Changed in cinder:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 13.0.0.0b3

This issue was fixed in the openstack/cinder 13.0.0.0b3 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/660989

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/queens)

Reviewed: https://review.opendev.org/660989
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=0b18f8e47f23fec654509e06110f6bb98a86d968
Submitter: Zuul
Branch: stable/queens

commit 0b18f8e47f23fec654509e06110f6bb98a86d968
Author: Thomas Goirand <email address hidden>
Date: Wed May 16 13:07:36 2018 +0200

    Fix rbd driver json loading

    It looks like rbd.py sometimes gets some bytes, not strings, probably
    this happens with the latest version of Ceph, and that's an issue only
    with Python 3. I'm not sure why, but what I know, is that it's completely
    breaking Debian with Python 3 and ceph Luminous release.

    Convert byte buffers coming from Ceph to strings.

    Co-Authored-By: Eric Harney <email address hidden>
    Change-Id: I5cdb4e766655a866699a18f1e367971fd1d310af
    Closes-Bug: #1771552
    (cherry picked from commit d156030338ba10980b85704602e5085fffb32124)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 12.0.8

This issue was fixed in the openstack/cinder 12.0.8 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.