not validate a metadata type when creating a vm instance

Bug #1238344 reported by Ken'ichi Ohmichi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Ken'ichi Ohmichi

Bug Description

If specifying non-dict data(string, etc.) as metadata, "create a vm" API returns a HTTP500(Internal Server Error) response:

$ curl -i http://192.168.0.30:8774/v2/248fcd6585b245dfa48d4dee51673f28/servers -X POST -H "X-Auth-Project-Id: demo" -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: MII[..]" -d '{"server": {"min_count": 1, "flavorRef": "42", "name": "vm02", "imageRef": "0483c08f-d4e7-414f-8847-f5855ad816df", "m
ax_count": 1, "metadata": "string"}}'
HTTP/1.1 500 Internal Server Error
Content-Length: 128
Content-Type: application/json; charset=UTF-8
X-Compute-Request-Id: req-4148aefb-34d0-433a-aea4-b4268c8776ce
Date: Thu, 10 Oct 2013 09:30:24 GMT

{"computeFault": {"message": "The server has either erred or is incapable of performing the requested operation.", "code": 500}}
$

The reason is that the API does not validate its metadata type.

The nova-api log is the following:
2013-10-10 18:30:24.226 TRACE nova.api.openstack action_result = self.dispatch(meth, request, action_args)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/wsgi.py", line 1057, in dispatch
2013-10-10 18:30:24.226 TRACE nova.api.openstack return method(req=request, **action_args)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/compute/servers.py", line 923, in create
2013-10-10 18:30:24.226 TRACE nova.api.openstack legacy_bdm=legacy_bdm)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/hooks.py", line 105, in inner
2013-10-10 18:30:24.226 TRACE nova.api.openstack rv = f(*args, **kwargs)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/compute/api.py", line 1220, in create
2013-10-10 18:30:24.226 TRACE nova.api.openstack legacy_bdm=legacy_bdm)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/compute/api.py", line 861, in _create_instance
2013-10-10 18:30:24.226 TRACE nova.api.openstack block_device_mapping, auto_disk_config, reservation_id)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/compute/api.py", line 672, in _validate_and_build_base_options
2013-10-10 18:30:24.226 TRACE nova.api.openstack instance_type, metadata, injected_files)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/compute/api.py", line 626, in _checks_for_create_and_rebuild
2013-10-10 18:30:24.226 TRACE nova.api.openstack self._check_metadata_properties_quota(context, metadata)
2013-10-10 18:30:24.226 TRACE nova.api.openstack File "/opt/stack/nova/nova/compute/api.py", line 406, in _check_metadata_properties_quota
2013-10-10 18:30:24.226 TRACE nova.api.openstack for k, v in metadata.iteritems():
2013-10-10 18:30:24.226 TRACE nova.api.openstack AttributeError: 'unicode' object has no attribute 'iteritems'
2013-10-10 18:30:24.226 TRACE nova.api.openstack

Changed in nova:
assignee: nobody → Ken'ichi Ohmichi (oomichi)
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/51085

Changed in nova:
status: New → In Progress
Revision history for this message
Sean Dague (sdague) wrote :

This is a relatively small patch that removes a 500 server error scenario, so I think a havana backport for 2013.2.1 should be considered.

Changed in nova:
importance: Undecided → Medium
tags: added: havana-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/51085
Committed: http://github.com/openstack/nova/commit/753bed08d1ff224427938c67a6f8922ebac376e4
Submitter: Jenkins
Branch: master

commit 753bed08d1ff224427938c67a6f8922ebac376e4
Author: Ken'ichi Ohmichi <email address hidden>
Date: Fri Oct 11 09:54:38 2013 +0900

    Add a metadata type validation when creating vm

    If specifying non-dict data(string, etc.) as metadata, "create a vm"
    API returns a HTTP500(Internal Server Error) response because it does
    not validate the metadata type.

    This patch adds the metadata type validation, and the API will return
    a HTTP400(Bad Request) response. In addition, this patch removes log.WARNs
    of bad incoming requests because they are just client-side problems not
    server-side.

    Closes-Bug: 1238344
    Change-Id: I8f1d5debf74891e67b17f8128cc0eb0ab7f5c3f5

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.1
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.