python3 incompatibility using the python-ironicclient

Bug #1629068 reported by Marc Aubry
20
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Ironic
Invalid
Medium
Unassigned
Newton
Won't Fix
High
Jay Faulkner
ironic-python-agent
Fix Released
High
Tuan
Newton
Won't Fix
High
Tuan
python-ironicclient
Fix Released
High
Maxime Belanger

Bug Description

In python3, when I execute the following code I get "I shouldn't see this"

from ironicclient import client
from ironicclient.common.apiclient.exceptions import Forbidden

kwargs = {'os_auth_token': 'some_bad_token',
          'ironic_url': 'http://baremetal.example.org:6385'}
ironic = client.get_client(1, **kwargs)

Traceback (most recent call last):
    ironic.node.list()
  File "/Users/maubry/github/python-ironicclient/ironicclient/v1/node.py", line 132, in list
    return self._list(self._path(path), "nodes")
  File "/Users/maubry/github/python-ironicclient/ironicclient/common/base.py", line 154, in _list
    resp, body = self.api.json_request('GET', url)
  File "/Users/maubry/github/python-ironicclient/ironicclient/common/http.py", line 391, in json_request
    resp, body_iter = self._http_request(url, method, **kwargs)
  File "/Users/maubry/github/python-ironicclient/ironicclient/common/http.py", line 190, in wrapper
    return func(self, url, method, **kwargs)
  File "/Users/maubry/github/python-ironicclient/ironicclient/common/http.py", line 362, in _http_request
    body_str = ''.join([chunk for chunk in body_iter])
TypeError: sequence item 0: expected str instance, bytes found

Changed in python-ironicclient:
assignee: nobody → Marc Aubry (maubry-i)
status: New → In Progress
Revision history for this message
Dmitry Tantsur (divius) wrote :

Please provide an exact traceback you're getting without "except TypeError"

Changed in python-ironicclient:
status: In Progress → Incomplete
Revision history for this message
Marc Aubry (maubry-i) wrote :

with python 3.4.4

ironic.node.list() using wrong credentials
http://paste.openstack.org/show/583780/

ironic.node.get('some_inexistant_uuid')
http://paste.openstack.org/show/583781/

Dmitry Tantsur (divius)
description: updated
Changed in python-ironicclient:
status: Incomplete → In Progress
importance: Undecided → High
Marc Aubry (maubry-i)
Changed in python-ironicclient:
status: In Progress → Fix Committed
Revision history for this message
Mathieu Mitchell (mat128) wrote :
Revision history for this message
Mathieu Mitchell (mat128) wrote :

This bug affects all stable branches. Anyone knows when py3 support for clients was officially declared?

Ruby Loo (rloo)
Changed in python-ironicclient:
status: Fix Committed → In Progress
Changed in python-ironicclient:
assignee: Marc Aubry (maubry-i) → Maxime Belanger (mbelanger)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-ironicclient (master)

Reviewed: https://review.openstack.org/378050
Committed: https://git.openstack.org/cgit/openstack/python-ironicclient/commit/?id=e512550ab7d61b8bdafd50022dfa8b80a8502922
Submitter: Jenkins
Branch: master

commit e512550ab7d61b8bdafd50022dfa8b80a8502922
Author: Marc Aubry <email address hidden>
Date: Tue Sep 27 17:42:53 2016 -0400

    Fix python3 compatibility when HTTP Error are returned

    When trying to contact Ironic with a bad token, Forbidden exception
    should be raised, in python3 a TypeError is raised due to json
    lib being unable do decode a bytes object.

    In order to be really python3 compatible, the json lib was replaced
    with oslo.serialization module jsontuils since it's the recommended
    migration to python3 guide. This is to ensure that data coming from
    the requests lib can be read even if it's not string any more but
    bytes.
    https://wiki.openstack.org/wiki/Python3

    Change-Id: I27540f58e31817d4de604334bc4c62899d82f4cc
    Closes-Bug: #1629068

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

This issue was fixed in the openstack/python-ironicclient 1.8.0 release.

Tuan (tuanla)
Changed in ironic-python-agent:
assignee: nobody → Tuan (tuanla)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic-python-agent (master)

Reviewed: https://review.openstack.org/363605
Committed: https://git.openstack.org/cgit/openstack/ironic-python-agent/commit/?id=ab41106cf66f779f4b29a113ab1757bc7de66f0c
Submitter: Jenkins
Branch: master

commit ab41106cf66f779f4b29a113ab1757bc7de66f0c
Author: Luong Anh Tuan <email address hidden>
Date: Tue Nov 15 14:36:46 2016 +0700

    Python 3 Compatible JSON

    In order to be really python3 compatible, the json lib was replaced
    with oslo.serialization(1.10 or newer) module jsontuils since it's
    the recommended migration to python3 guide.

    https://wiki.openstack.org/wiki/Python3#Serialization:_base64.2C_JSON.2C_etc.

    Change-Id: I2d8b62e642aba4ccd1b70be7e9b3784a95a6743d
    Closes-Bug: #1629068

Changed in ironic-python-agent:
status: New → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

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

Changed in ironic:
assignee: nobody → Nguyen Hung Phuong (phuongnh)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-ironicclient (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/406263

Changed in ironic-python-agent:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic-python-agent (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/406266

Revision history for this message
Jay Faulkner (jason-oldos) wrote :

I back ported the IPA and python-ironicclient patches to stable/newton. I'd suggest doing the same with the Ironic patch once merged.

Thanks for finding this and working to fix it!

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on ironic-python-agent (stable/newton)

Change abandoned by Jay Faulkner (<email address hidden>) on branch: stable/newton
Review: https://review.openstack.org/406266
Reason: Backport was clearly not clean, added a requirement as well, going to say this isn't worth it and abandon patch.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on python-ironicclient (stable/newton)

Change abandoned by Jay Faulkner (<email address hidden>) on branch: stable/newton
Review: https://review.openstack.org/406263
Reason: After Tony's comment, abandoning the patch.

Revision history for this message
Jay Faulkner (jason-oldos) wrote :

I looked into updating the patch posted by Nguyen (404122), and was not able to get it to pass unit tests. Given there's no evidence of Ironic being impacted in this bug, I'm lowering the priority and will table work on this until we can see some kind of impact.

Changed in ironic:
importance: High → Medium
status: In Progress → Triaged
assignee: Jay Faulkner (jason-oldos) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/ironic-python-agent 2.0.0

This issue was fixed in the openstack/ironic-python-agent 2.0.0 release.

Changed in ironic:
assignee: nobody → Ramamani Yeleswarapu (ramamani-yeleswarapu)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on ironic (master)

Change abandoned by Nguyen Hung Phuong (<email address hidden>) on branch: master
Review: https://review.openstack.org/404122

Changed in ironic:
assignee: Ramamani Yeleswarapu (ramamani-yeleswarapu) → nobody
Changed in ironic:
status: Triaged → Invalid
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.