Relaxed validation for v2 doesn't accept null for user_data like legacy v2 does (liberty)

Bug #1582911 reported by Mike Dorman
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Alex Xu
Liberty
Fix Released
High
Matt Riedemann
Mitaka
Fix Released
High
Matt Riedemann

Bug Description

Description
===========
When moving to the relaxed validation [1] implementation of the v2 API under the v2.1 code base, a 'nova boot' request with "user_data": null fails with the error:

  Returning 400 to user: Invalid input for field/attribute user_data. Value: None. None is not of type 'string'

Under the legacy v2 code base, such a request is allowed.

Steps to reproduce
==================
Using the legacy v2 code base under Liberty, make a nova boot call using the following json payload:

{
  "server": {
    "name": "mgdlibertyBBC",
    "flavorRef": "1",
    "imageRef": "626ce751-744f-4830-9d38-5e9e4f70fe3f",
    "user_data": null,
    "metadata": {
      "created_by": "mdorman"
    },
    "security_groups": [
      {
        "name": "default"
      }
    ],
    "availability_zone": "glbt1-dev-lab-zone-1,glbt1-dev-lab-zone-2,",
    "key_name": "lm126135-mdorm"
  }
}

The request succeeds and the instance is created.

However, using the v2 implementation from the v2.1 code base with the same json payload fails:

2016-05-17 12:47:02.336 18296 DEBUG nova.api.openstack.wsgi [req-6d5d4100-7c0c-4ffa-a40c-4a086a473293 mdorman 40e94f951b704545885bdaa987a25154 - - -] Returning 400 to user: Invalid input for field/attribute user_data. Value: None. None is not of type 'string' __call__ /usr/lib/python2.7/site-packages/nova/api/openstack/wsgi.py:1175

Expected result
===============
The behavior of the v2 API in the v2.1 code base should be exactly the same as the legacy v2 code base.

Actual result
=============
Request fails under v2.1 code base, but succeeds under legacy v2 code base.

Environment
===========
Liberty, 12.0.3 tag (stable/liberty branch on 4/13/2016. Latest commit 6fdf1c87b1149e8b395eaa9f4cbf27263cf96ac6)

Logs & Configs
==============
Paste config used for legacy v2 code base (request succeeds):

[composite:osapi_compute]
use = call:nova.api.openstack.urlmap:urlmap_factory
/v1.1: openstack_compute_api_legacy_v2
/v2: openstack_compute_api_legacy_v2
/v2.1: openstack_compute_api_v21

Paste config used for v2.1 code base (request fails):

[composite:osapi_compute]
use = call:nova.api.openstack.urlmap:urlmap_factory
/: oscomputeversions
/v1.1: openstack_compute_api_v21_legacy_v2_compatible
/v2: openstack_compute_api_v21_legacy_v2_compatible
/v2.1: openstack_compute_api_v21

[1] http://specs.openstack.org/openstack/nova-specs/specs/liberty/implemented/api-relax-validation.html

Mike Dorman (mdorman-m)
description: updated
Matt Riedemann (mriedem)
tags: added: api
tags: added: liberty-backport-potential
Matt Riedemann (mriedem)
summary: Relaxed validation for v2 doesn't accept null for user_data like legacy
- v2 does
+ v2 does (liberty)
Revision history for this message
Matt Riedemann (mriedem) wrote :

Looks like it's still an issue for v2.1 in Newton, we have no compat mode check for this it looks like:

https://github.com/openstack/nova/blob/master/nova/api/openstack/compute/schemas/user_data.py

Changed in nova:
status: New → Confirmed
importance: Undecided → High
Alex Xu (xuhj)
Changed in nova:
assignee: nobody → Alex Xu (xuhj)
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/318447

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/318447
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=22c87390a33300b93f0913d4e787662b119a00b9
Submitter: Jenkins
Branch: master

commit 22c87390a33300b93f0913d4e787662b119a00b9
Author: He Jie Xu <email address hidden>
Date: Thu May 19 11:04:10 2016 +0800

    Enable 'null' value for user_data in V2.1 API

    The legacy v2 API allow the 'null' value for user_data. Unfortunately
    the v2.1 API didn't match that in the input validation. This patch
    enables 'null' value, at sametime, it enables for v2.1 compat mode
    also.

    Change-Id: Iae614035efd4b37c214754ad12b17ca224b8fd92
    Closes-Bug: #1582911

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/mitaka)

Fix proposed to branch: stable/mitaka
Review: https://review.openstack.org/323972

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/liberty)

Fix proposed to branch: stable/liberty
Review: https://review.openstack.org/323980

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/mitaka)

Reviewed: https://review.openstack.org/323972
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=2024387ecc0922abe97863c349cf94df1d4462d0
Submitter: Jenkins
Branch: stable/mitaka

commit 2024387ecc0922abe97863c349cf94df1d4462d0
Author: He Jie Xu <email address hidden>
Date: Thu May 19 11:04:10 2016 +0800

    Enable 'null' value for user_data in V2.1 API

    The legacy v2 API allow the 'null' value for user_data. Unfortunately
    the v2.1 API didn't match that in the input validation. This patch
    enables 'null' value, at sametime, it enables for v2.1 compat mode
    also.

    Conflicts:
            api-ref/source/parameters.yaml

    NOTE(mriedem): The conflict is due to the api-ref parameters file
    not existing until Newton. It's just a note in the docs on the
    user_data parameter and isn't required for this backport.

    Change-Id: Iae614035efd4b37c214754ad12b17ca224b8fd92
    Closes-Bug: #1582911
    (cherry picked from commit 22c87390a33300b93f0913d4e787662b119a00b9)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/liberty)

Reviewed: https://review.openstack.org/323980
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=c29ea41ba0706cd1421d127d79b18e0c4fa58da4
Submitter: Jenkins
Branch: stable/liberty

commit c29ea41ba0706cd1421d127d79b18e0c4fa58da4
Author: He Jie Xu <email address hidden>
Date: Thu May 19 11:04:10 2016 +0800

    Enable 'null' value for user_data in V2.1 API

    The legacy v2 API allow the 'null' value for user_data. Unfortunately
    the v2.1 API didn't match that in the input validation. This patch
    enables 'null' value, at sametime, it enables for v2.1 compat mode
    also.

    Change-Id: Iae614035efd4b37c214754ad12b17ca224b8fd92
    Closes-Bug: #1582911
    (cherry picked from commit 22c87390a33300b93f0913d4e787662b119a00b9)
    (cherry picked from commit 2024387ecc0922abe97863c349cf94df1d4462d0)

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/nova 14.0.0.0b1

This issue was fixed in the openstack/nova 14.0.0.0b1 development milestone.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 12.0.4

This issue was fixed in the openstack/nova 12.0.4 release.

Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/nova 13.1.0

This issue was fixed in the openstack/nova 13.1.0 release.

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.