jsonutils.py is incompatible with anyjson from 3.3.2 onwards

Bug #1017765 reported by Tim Daly Jr.
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Russell Bryant
horizon (Ubuntu)
Fix Released
High
Unassigned
keystone (Ubuntu)
Fix Released
High
Unassigned
nova (Ubuntu)
Fix Released
High
Unassigned

Bug Description

Newer versions of the python anyjson library support an additional "filedecoder" method:

https://bitbucket.org/runeh/anyjson/changeset/93a0e869c06c

It's just like decoder except it takes a file argument instead of a string. Since nova's jsonutils.py doesn't define a filedecoder, we get a KeyError from anyjson:

  File "/home/openstack/nova/app/nova/openstack/common/jsonutils.py", line 133, in <module>
    anyjson.force_implementation(__name__)
  File "/usr/lib/python2.6/site-packages/anyjson-0.3.3-py2.6.egg/anyjson/__init__.py", line 111, in force_implementation
    implementation = _JsonImplementation(spec)
  File "/usr/lib/python2.6/site-packages/anyjson-0.3.3-py2.6.egg/anyjson/__init__.py", line 63, in __init__
    fdec = modinfo["filedecoder"]

We can simply add the new method. Since it's on the end of the list, it's compatible with older versions of anyjson. I'll submit a patch.

Revision history for this message
Zhongyue Luo (zyluo) wrote :

This patch should be submitted to openstack-common first and then updated to Nova.

Revision history for this message
Tim Daly Jr. (timjr) wrote :

Oh, thanks, didn't know about that.

Revision history for this message
Tim Daly Jr. (timjr) wrote :
Changed in nova:
assignee: nobody → Tim Daly Jr. (timjr)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
assignee: Tim Daly Jr. (timjr) → Russell Bryant (russellb)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/9857
Committed: http://github.com/openstack/nova/commit/12e663a8b0b253970e3bccd373d3d2f3d462f6b6
Submitter: Jenkins
Branch: master

commit 12e663a8b0b253970e3bccd373d3d2f3d462f6b6
Author: Russell Bryant <email address hidden>
Date: Mon Jul 16 12:20:44 2012 -0400

    Sync jsonutils from openstack-common.

    In addition to the following changes from openstack-common, this patch
    includes some tweak to nova unit tests. timeutils.strtime() will raise
    an exception if the year in a datetime object is before 1900.

    Changes from openstack-common:

        commit ce3071437d1871f77c4d8573cbe5f4ea8c817650
        Author: Russell Bryant <email address hidden>
        Date: Mon Jul 16 10:30:25 2012 -0400

            Use strtime() in to_primitive() for datetime objs.

            This patch updates jsonutils.to_primitive() to use timeutils.strtime()
            to convert a datimetime object to a string instead of just using str().
            This ensures that we can easily convert the string back to a datetime
            using timeutils.parse_strtime().

            Required for the nova blueprint no-db-messaging.

        commit 4c9d439ef24f5afdd74aa9153aa8fc772051e6cb
        Author: Tim Daly Jr <email address hidden>
        Date: Tue Jun 26 02:48:42 2012 +0000

            Add 'filedecoder' method to the jsonutils wrapper module.

            Fixes bug #1017765

            After version 3.3.2, the anyjson library will throw a KeyError if
            filedecoder isn't present. The filedecoder is just like the decoder
            except it takes a file instead of a string, like json.load() instead
            of json.loads().

    Change-Id: Ib51f0da8641c035371e09047de9abe3cb83203e9

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I just hit this trying to install keystone on Ubuntu 12.10.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This commit seems to fix the issue.

Changed in keystone (Ubuntu):
status: New → Triaged
importance: Undecided → High
tags: added: rls-q-incoming
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Note that I just modified the files directly within /usr/share, and I adjusted *both* keystone and nova, so I'm guessing the upstream commit may also need to be applied to keystone?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

This also affects horizon.

Changed in horizon (Ubuntu):
status: New → Triaged
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

The fix works on horizon, but then it has other problems.

Changed in nova (Ubuntu):
status: New → Triaged
Thierry Carrez (ttx)
Changed in nova:
milestone: none → folsom-3
status: Fix Committed → Fix Released
James Page (james-page)
Changed in nova (Ubuntu):
importance: Undecided → High
Changed in horizon (Ubuntu):
importance: Undecided → High
Chuck Short (zulcss)
Changed in horizon (Ubuntu):
status: Triaged → Fix Released
Chuck Short (zulcss)
Changed in nova (Ubuntu):
status: Triaged → Fix Released
Changed in keystone (Ubuntu):
status: Triaged → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-3 → 2012.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.