non string user metadata causes 500 error in nova-api

Bug #1240319 reported by Michael Chapman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Matt Riedemann

Bug Description

Using grizzly on U12.04.

When using python-novaclient to make a nova boot call, if metadata is entered that is not of a string type, nova-api will have an error when it attempts to store it in the db.

For example:

novaclient.servers.create(... ..., meta={'test': ['a', 'list', 'of', 'things']}, ... ...)

description: updated
Revision history for this message
Matt Riedemann (mriedem) wrote :

What version of novaclient?

Revision history for this message
Matt Riedemann (mriedem) wrote :

Do you have a stack trace in the compute log?

tags: added: novaclient
Revision history for this message
Matt Riedemann (mriedem) wrote :

Looking at the latest novaclient code, I don't see it validating the meta value, it just lists this in the docstring for the _boot method:

        :param meta: A dict of arbitrary key/value metadata to store for this
                     server. A maximum of five entries is allowed, and both
                     keys and values must be 255 characters or less.

It doesn't valid the type, size or length of the dict in the client. Looks like the nova compute API validates the metadata in the request:

https://github.com/openstack/nova/blob/master/nova/compute/api.py#L402

Looking at the latest code, it's checking that the metadata value is a dict with a number of entries per the quota limits, and checks the entries length to make sure they are less than 255 (characters), but they don't check that the key/value pairs are strings.

Changed in nova:
status: New → Confirmed
Matt Riedemann (mriedem)
Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
Matt Riedemann (mriedem)
tags: added: api
removed: novaclient
tags: added: grizzly-backport-potential havana-backport-potential
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/56793

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/56793
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=18a6f7ced0f5d2c6293ca06470a7fab45a11e833
Submitter: Jenkins
Branch: master

commit 18a6f7ced0f5d2c6293ca06470a7fab45a11e833
Author: Matt Riedemann <email address hidden>
Date: Sat Nov 16 14:04:32 2013 -0800

    Enforce metadata string type on key/value pairs

    The compute API is currently enforcing quota limits for user metadata
    and length restrictions on the dict entries, but is not enforcing that
    they are string types. This patch adds the checks for string type on the
    keys and values in the metadata dict.

    Closes-Bug: #1240319

    Change-Id: Ic4aacc342cf37d929871287e6e4917f4f48b63e8

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-2
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Alan Pevec (apevec)
tags: removed: grizzly-backport-potential
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-2 → 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.