Nova EC2 /images returned mapping has wrong keys for euca-describe-images

Bug #712782 reported by Christian Berendt
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Devin Carlen

Bug Description

I'm trying to put a new image like described in the documentation on http://glance.openstack.org/client.html.

I started glance_registry on port 9191 and used swift as the default storage.

No I get the following error from glance_registry:

DEBUG:routes.middleware:Match dict: {'action': u'create', 'controller': <glance.registry.server.ImageController object at 0xc50110>}
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib64/python2.6/site-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib64/python2.6/site-packages/glance/common/wsgi.py", line 239, in __call__
    result = method(**arg_dict)
  File "/usr/lib64/python2.6/site-packages/glance/registry/server.py", line 106, in create
    image_data = json.loads(req.body)['image']
  File "/usr/lib64/python2.6/json/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.6/json/decoder.py", line 319, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.6/json/decoder.py", line 338, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

This is the python code I used:

#!/usr/bin/python

from glance.client import Client

c = Client("lemon.colo.b1-systems.de", 9191)

print c.get_images()

meta = {'name': 'Ubuntu 10.10 5G',
        'type': 'machine',
        'is_public': True,
        'properties': {'distro': 'Ubuntu 10.10'}}

new_meta = c.add_image(meta, open('/root/ubuntu-10.10-server-uec-amd64.tar.gz'))

print 'Stored image. Got identifier: %s' % new_meta['id']

Related branches

Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi!

Could you try using the bin/glance-upload tool and tell me if you get the same error? Thanks!

Also, please specify what version of Glance you are using...

-jay

Revision history for this message
Christian Berendt (berendt) wrote :
Download full text (3.4 KiB)

I'm using Glance 0.1.7.

/usr/bin/python /usr/bin/glance-api --verbose --api_host=FQDN --default_store=swift
tcp 0 0 172.19.134.24:9292 0.0.0.0:* LISTEN 0 1972934 18364/python

glance-upload --host FQDN ../ubuntu-10.10-server-uec-amd64.tar.gz testing

I tried glance-upload, now getting the following error:

Matched POST /images
DEBUG:routes.middleware:Matched POST /images
Route path: '/images', defaults: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
DEBUG:routes.middleware:Route path: '/images', defaults: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
Match dict: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
DEBUG:routes.middleware:Match dict: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib64/python2.6/site-packages/routes/middleware.py", line 131, in __call__
    response = self.app(environ, start_response)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 159, in __call__
    return resp(environ, start_response)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 147, in __call__
    resp = self.call_func(req, *args, **self.kwargs)
  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 208, in call_func
    return self.func(req, *args, **kwargs)
  File "/usr/lib64/python2.6/site-packages/glance/common/wsgi.py", line 239, in __call__
    result = method(**arg_dict)
  File "/usr/lib64/python2.6/site-packages/glance/server.py", line 325, in create
    image_meta = self._reserve(req)
  File "/usr/lib64/python2.6/site-packages/glance/server.py", line 186, in _reserve
    image_meta = registry.add_image_metadata(image_meta)
  File "/usr/lib64/python2.6/site-packages/glance/registry/__init__.py", line 54, in add_image_metadata
    return c.add_image(image_data)
  File "/usr/lib64/python2.6/site-packages/glance/registry/client.py", line 85, in add_image
    res = self.do_request("POST", "/images", body)
  File "/usr/lib64/python2.6/site-packages/glance/client.py", line 162, in do_request
    "server. Got error: %s" % e)
ClientConnectionError: Unable to connect to server. Got error: [Errno 111] ECONNREFUSED

Traceback (most recent call last):
  File "/usr/bin/glance-upload", line 85, in <module>
    main()
  File "/usr/bin/glance-upload", line 79, in main
    new_meta = client.add_image(meta, f)
  File "/usr/lib64/python2.6/site-packages/glance/client.py", line 259, in add_image
    res = self.do_request("POST", "/images", body, headers)
  File "/usr/lib64/python2.6/site-packages/glance/client.py", line 158, in do_request
    raise Exception("Unknown error occurred! %s" % res.__dict__)
Exception: Unknown error occurred! {'fp': <socket._fileobject object at 0x7f978ab4b410>, 'status': 500, 'will_close': True,...

Read more...

Revision history for this message
Jay Pipes (jaypipes) wrote : Re: [Bug 712782] Re: getting error "No JSON object could be decoded" while trying to put a new images
Download full text (3.5 KiB)

On Fri, Feb 4, 2011 at 2:09 AM, Christian Berendt
<email address hidden> wrote:
> I'm using Glance 0.1.7.

OK, thanks.

> /usr/bin/python /usr/bin/glance-api --verbose --api_host=FQDN --default_store=swift
> tcp        0      0 172.19.134.24:9292      0.0.0.0:*               LISTEN      0          1972934    18364/python

Not related to this particular bug, but we have not completed the POST
functionality for Swift. Aiming to get this done by 2011-02-21. Please
see https://bugs.launchpad.net/glance/+bug/713126.

Until the above bug is fixed, you may want to start your API node with
--filesystem_store_datadir=/path/to/images instead of
--default_store=swift.

In addition, Cactus has code committed that removes the use of GFlags
and instead uses the standard optparse module, so when you test with
Cactus, please use --filesystem-store-datadir instead of
--filesystem_store_datadir. Just a heads up...

> glance-upload --host FQDN ../ubuntu-10.10-server-uec-amd64.tar.gz
> testing
>
> I tried glance-upload, now getting the following error:
>
> Matched POST /images
> DEBUG:routes.middleware:Matched POST /images
> Route path: '/images', defaults: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
> DEBUG:routes.middleware:Route path: '/images', defaults: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
> Match dict: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
> DEBUG:routes.middleware:Match dict: {'action': u'create', 'controller': <glance.server.Controller object at 0xbc9210>}
> Traceback (most recent call last):
>  File "/usr/lib64/python2.6/site-packages/eventlet/wsgi.py", line 336, in handle_one_response
>    result = self.application(self.environ, start_response)
>  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 159, in __call__
>    return resp(environ, start_response)
>  File "/usr/lib64/python2.6/site-packages/routes/middleware.py", line 131, in __call__
>    response = self.app(environ, start_response)
>  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 159, in __call__
>    return resp(environ, start_response)
>  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 147, in __call__
>    resp = self.call_func(req, *args, **self.kwargs)
>  File "/usr/lib64/python2.6/site-packages/webob/dec.py", line 208, in call_func
>    return self.func(req, *args, **kwargs)
>  File "/usr/lib64/python2.6/site-packages/glance/common/wsgi.py", line 239, in __call__
>    result = method(**arg_dict)
>  File "/usr/lib64/python2.6/site-packages/glance/server.py", line 325, in create
>    image_meta = self._reserve(req)
>  File "/usr/lib64/python2.6/site-packages/glance/server.py", line 186, in _reserve
>    image_meta = registry.add_image_metadata(image_meta)
>  File "/usr/lib64/python2.6/site-packages/glance/registry/__init__.py", line 54, in add_image_metadata
>    return c.add_image(image_data)
>  File "/usr/lib64/python2.6/site-packages/glance/registry/client.py", line 85, in add_image
>    res = self.do_request("POST", "/images", body)
>  File "/usr/lib64/python2.6/site-packages/glance/client.py", line 162, in do_requ...

Read more...

Revision history for this message
Christian Berendt (berendt) wrote : Re: getting error "No JSON object could be decoded" while trying to put a new images

With --filesystem_storage_datadire=/path/ it's working fine, I can now upload and register a new image with glance-upload. I receive the follwing metadata:

Stored image. Got identifier: {u'created_at': u'2011-02-04T17:52:39.121125',
 u'deleted': False,
 u'deleted_at': None,
 u'id': 3,
 u'is_public': True,
 u'location': u'file:///srv/images/3',
 u'name': u'ttylinux',
 u'properties': {u'kernel_id': u'2', u'ramdisk_id': u'1'},
 u'size': 25165824,
 u'status': u'active',
 u'type': u'machine',
 u'updated_at': None}

Ok. Now I configured Nova in /etc/nova/nova.conf:

--glance_host=API-HOST
--glance_port=9292
--image_service=nova.image.glance.GlanceImageService

And run euca-describe-images:

# euca-describe-images
IMAGE 1 None None None private ramdisk
IMAGE 2 None None None private kernel
IMAGE 3 None None None private machine

I fetched the detailled information of all 3 images and all images are set to be public. Why does euca-describe-images show them as private and why don't they have the correct name and why there are missing some information?

[{u'status': u'active', u'name': u'ttylinux-ramdisk', u'deleted': False, u'created_at': u'2011-02-04T17:51:39.410508', u'updated_at': u'2011-02-04T17:51:39.678406', u'properties': {}, u'location': u'file:///srv/images/1', u'is_public': True, u'deleted_at': None, u'type': u'ramdisk', u'id': 1, u'size': 5882349}, {u'status': u'active', u'name': u'ttylinux-vmlinuz', u'deleted': False, u'created_at': u'2011-02-04T17:52:10.732856', u'updated_at': u'2011-02-04T17:52:10.988391', u'properties': {}, u'location': u'file:///srv/images/2', u'is_public': True, u'deleted_at': None, u'type': u'kernel', u'id': 2, u'size': 4404752}, {u'status': u'active', u'name': u'ttylinux', u'deleted': False, u'created_at': u'2011-02-04T17:52:39.121125', u'updated_at': u'2011-02-04T17:52:39.449930', u'properties': {u'kernel_id': u'2', u'ramdisk_id': u'1'}, u'location': u'file:///srv/images/3', u'is_public': True, u'deleted_at': None, u'type': u'machine', u'id': 3, u'size': 25165824}]

Revision history for this message
Jay Pipes (jaypipes) wrote :

"I fetched the detailled information of all 3 images and all images are set to be public. Why does euca-describe-images show them as private and why don't they have the correct name and why there are missing some information?"

:( I'm not sure. euca-describe-images only works with S3-backed image stores. nova-objectstore is the only image service that speaks the S3 protocol. Glance does not. What is weird is why euca-describe-images is returning *any* images at all, since you set nova's image_service to Glance, and not S3 (which is nova-objectstore). Perhaps the nova-objectstore images bucket had some old data in it?

I'm going to ask Devin to see if he thinks that might be the issue...

Revision history for this message
Jay Pipes (jaypipes) wrote :

Hello again, Christian!

Is it at all possible that the euca-describe-images call was picking up previous images that had been stored in nova-objectstore when FLAGS.image_service had not been changed?

-jay

Revision history for this message
Jay Pipes (jaypipes) wrote :

OK, Christian, we think we've figured it out...

Switching this to Nova. Basically, here is the issue.

In euca-describe-images, the display_images() method looks like this:

 image_string = '%s\t%s\t%s\t%s' % (image.id, image.location, image.ownerId, image.state)
 if image.is_public:
       image_string += '\tpublic'
 else:
     image_string += '\tprivate'

The keys returned in the mapping from Nova are not matching with Boto/euca-describe-images is expecting, and therefore the fields appear as None and the is_public setting is not shown properly...

-jay

Changed in glance:
status: New → Confirmed
importance: Undecided → High
affects: glance → nova
summary: - getting error "No JSON object could be decoded" while trying to put a
- new images
+ Nova EC2 /images returned mapping has wrong keys for euca-describe-
+ images
Changed in nova:
assignee: nobody → Devin Carlen (devcamcar)
Revision history for this message
Dan Prince (dan-prince) wrote :

This issues seems to be somewhat related to what I was hitting in #709355 where I was trying to use the Openstack API with the S3ImageService.

The issue is that GlanceImageService and S3ImageService return image dictionaries that have different keys. It would be nice to implement these interfaces such that we don't have to work around the differences between them inside the API controllers (Openstack and EC2).

Devin Carlen (devcamcar)
Changed in nova:
status: Confirmed → In Progress
Thierry Carrez (ttx)
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.2
status: Fix Committed → 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.