Sending empty allocations list on a PUT /allocations/{consumer_uuid} results in 500

Bug #1708260 reported by Chris Dent
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Chris Dent
Ocata
Fix Committed
Medium
Chris Dent

Bug Description

If you send an empty allocation list to the placement server:

- name: put an allocation empty list
  PUT: /allocations/599ffd2d-526a-4b2e-8683-f13ad25f9958
  request_headers:
      content-type: application/json
  data:
      allocations: []

You'll get a 500 response because of an Index error when consumer_id = allocs[0].consumer_id.

Instead we should never reach this code. There should either be a schema violation, because we should have at least one allocation, or if we're willing to accept an empty list and do nothing, w should skip the call to the database.

Tags: placment
Revision history for this message
Sean Dague (sdague) wrote :

My feeling is this should be a 400 returned to the user, because this is probably not what they intended (maybe they typoed an assignment on their side)

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/490195

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
Matt Riedemann (mriedem) wrote :

This is a latent issue so I'm going to remove the pike-rc-potential tag.

tags: removed: pike-rc-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/490195
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=9155da345e5d6d1aee293bc66f746da52bca4c79
Submitter: Jenkins
Branch: master

commit 9155da345e5d6d1aee293bc66f746da52bca4c79
Author: Chris Dent <email address hidden>
Date: Wed Aug 2 21:21:12 2017 +0100

    [placement] Require at least one allocation when PUT

    When doing a PUT to /allocations/{consumer_uuid} if the list of
    allocations is empty there is a 500 error coming from an uncaught
    IndexError.

    Adjust the schema to require at least one allocation. If no allocations
    are provided in the list, the response will be a 400.

    This doesn't require a microversion because it is changing a 500 to
    a useful response.

    Change-Id: I361fa1e534d7b20c985558e272b672b84c6fe439
    Closes-Bug: #1708260

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

Fix proposed to branch: stable/ocata
Review: https://review.openstack.org/491487

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

Reviewed: https://review.openstack.org/491487
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=c95cd011d01f7e5cbd10346223be995f6507f9e7
Submitter: Jenkins
Branch: stable/ocata

commit c95cd011d01f7e5cbd10346223be995f6507f9e7
Author: Chris Dent <email address hidden>
Date: Wed Aug 2 21:21:12 2017 +0100

    [placement] Require at least one allocation when PUT

    When doing a PUT to /allocations/{consumer_uuid} if the list of
    allocations is empty there is a 500 error coming from an uncaught
    IndexError.

    Adjust the schema to require at least one allocation. If no allocations
    are provided in the list, the response will be a 400.

    This doesn't require a microversion because it is changing a 500 to
    a useful response.

    Change-Id: I361fa1e534d7b20c985558e272b672b84c6fe439
    Closes-Bug: #1708260
    (cherry picked from commit 9155da345e5d6d1aee293bc66f746da52bca4c79)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 16.0.0.0rc1

This issue was fixed in the openstack/nova 16.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 15.0.7

This issue was fixed in the openstack/nova 15.0.7 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.