DeltaCloud
  1. DeltaCloud
  2. DTACLOUD-382

JSON parser incompatibility between 1.9.3p194 and 1.9.3p286

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Component/s: CIMI/Frontend
    • Labels:
    • Environment:
      deltacloud-core HEAD (ea5fda91da9f8c061c2c2fa0a267c84501c743fa)

      json_pure-1.7.5

      Description

      I found strange problem with JSON parser under 1.9.3 MRI ruby when you try to create a new Machine.

      Requirements:

      ~/code/core/server › rbenv versions

      • 1.9.3-p194 (set by /home/mfojtik/code/core/server/.rbenv-version)
        1.9.3-p286

      How to reproduce:

      1. Use 1.9.3p194, start Deltacloud API with CIMI frontend, then:

      $ curl -v -X POST --user 'mockuser:mockpassword' -H 'Content-Type: application/json' -d @machine.json http://localhost:3001/cimi/machines

      Results: Everything works perfectly, Machine is created and JSON is returned to console.

      2. Use 1.9.3p286, start Deltacloud API with CIMI frontend, then:

      $ curl -v -X POST --user 'mockuser:mockpassword' -H 'Content-Type: application/json' -d @machine.json http://localhost:3001/cimi/machines

      Result:

      E, 2012-11-28T11:48:55.665131 #11346 ERROR – 500: [TypeError] wrong argument type JSON::Pure::Generator::State (expected Data)

      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:316:in `to_json'
      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:316:in `block in json_transform'
      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:309:in `each'
      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:309:in `json_transform'
      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:291:in `to_json'
      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/gems/1.9.1/gems/json_pure-1.7.5/lib/json/pure/generator.rb:257:in `generate'
      /home/mfojtik/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/json/common.rb:216:in `generate'
      /home/mfojtik/code/core/server/lib/cimi/models/base.rb:232:in `to_json'
      /home/mfojtik/code/core/server/lib/cimi/models/base.rb:243:in `to_json'
      /home/mfojtik/code/core/server/lib/cimi/collections/machines.rb:58:in `block (5 levels) in <class:Machines>'

      The Machine objects looks like this:

      #<CIMI::Model::Machine:0x000000044423f8 @attribute_values={:id=>"http://localhost:3001/cimi/machines/inst9", :name=>"myMachine1", :description=>"My very first machine", :created=>"2012-11-28T11:48:55+01:00", :property=>

      {"foo"=>"bar", "life"=>"is life", "machine_image"=>"http://localhost:3001/cimi/machine_images/img1", "credential"=>"http://localhost:3001/cimi/credentials"}

      , :state=>"STARTED", :cpu=>"1", :memory=>1781760, :disks=>#<Class::DiskCollection:0x00000004441c28 @attribute_values={:id=>nil, :href=>"http://localhost:3001/cimi/machines/inst9/disks", :count=>nil, :disks=>[], :operations=>nil}>, :volumes=>#<Class::MachineVolumeCollection:0x000000044416d8 @attribute_values={:id=>nil, :href=>"http://localhost:3001/cimi/machines/inst9/volumes", :count=>nil, :machine_volumes=>[], :operations=>nil}>, :meters=>nil, :operations=>[{:href=>"http://localhost:3001/cimi/machines/inst9/restart", :rel=>"http://schemas.dmtf.org/cimi/1/action/restart"}, {:href=>"http://localhost:3001/cimi/machines/inst9/stop", :rel=>"http://schemas.dmtf.org/cimi/1/action/stop"}, {:href=>"http://localhost:3001/cimi/machine_images", :rel=>"http://schemas.dmtf.org/cimi/1/action/capture"}]}>

      (nothing suspicious).

      I think this is caused by something they added to p286, but I was unable to track the problem down.

      NOTE: This bug is affecting *ALL* JSON output, not just create.

      PS: The @machine.json file:

      {
      "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate",
      "name": "myMachine1",
      "description": "My very first machine",
      "properties":

      { "foo": "bar", "life": "is life" }

      ,
      "machineTemplate": {
      "machineConfig":

      { "href": " http://localhost:3001/cimi/machine_configurations/m1-small" }

      ,
      "machineImage":

      { "href": " http://localhost:3001/cimi/machine_images/img1" }

      }
      }

        Activity

        Hide
        Michal Fojtik added a comment -

        OK, I'm kind of fixed this issue by removing all "require 'json'" and replacing that with one "require 'json/pure'" in deltacloud_rack.rb. Everything seems to work again with this 'fix'.

        Patch sent to mailing list.

        Show
        Michal Fojtik added a comment - OK, I'm kind of fixed this issue by removing all "require 'json'" and replacing that with one "require 'json/pure'" in deltacloud_rack.rb. Everything seems to work again with this 'fix'. Patch sent to mailing list.
        Hide
        Michal Fojtik added a comment -

        Patch pushed.

        Show
        Michal Fojtik added a comment - Patch pushed.
        Hide
        Ronelle Landy added a comment -

        Closing this issue as fixed in Deltacloud commit version: b546ce8f6fe14a73ae406f495b372be2dc8d7a10

        Verified that, with a Deltacloud gem install,

        >> cat deltacloud_rack.rb |grep json
        require 'json/pure'

        Only json/pure is required and used.

        Latest default version of ruby in Fedora 17 is:
        ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

        Show
        Ronelle Landy added a comment - Closing this issue as fixed in Deltacloud commit version: b546ce8f6fe14a73ae406f495b372be2dc8d7a10 Verified that, with a Deltacloud gem install, >> cat deltacloud_rack.rb |grep json require 'json/pure' Only json/pure is required and used. Latest default version of ruby in Fedora 17 is: ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]

          People

          • Assignee:
            Michal Fojtik
            Reporter:
            Michal Fojtik
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development