Potential AttributeError in _get_servers if FlavorNotFound

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

Bug Description

In the Nova servers API (v2 and v3), this line could fail with an AtributeError if there is a FlavorNotFound exception above it:

https://github.com/openstack/nova/blob/2014.1.b3/nova/api/openstack/compute/servers.py#L611

That code should either check if instance_list is empty first or set instance_list to an empty InstanceList object if FlavorNotFound is hit.

Matt Riedemann (mriedem)
Changed in nova:
importance: Undecided → Low
status: New → Triaged
assignee: nobody → Matt Riedemann (mriedem)
Revision history for this message
Matt Riedemann (mriedem) wrote :
tags: added: 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/82607

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

Reviewed: https://review.openstack.org/82607
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=32d948124adeb4615ba141164a1c191eed11598d
Submitter: Jenkins
Branch: master

commit 32d948124adeb4615ba141164a1c191eed11598d
Author: Matt Riedemann <email address hidden>
Date: Mon Mar 24 14:12:49 2014 -0700

    Don't attempt to fill faults for instance_list if FlavorNotFound

    When getting a list of servers with details, if a FlavorNotFound is
    raised from the compute API the local instance_list variable is set to
    an empty list, but later instance_list.fill_faults() is called on it
    assuming it is an InstanceList object, which will cause an
    AttributeError.

    This patch just checks to see if instance_list is empty before calling
    fill_faults since InstanceList.fill_faults assumes the list is not empty
    when called, so it's not trivial to simply create an empty InstanceList
    here and set it to the instance_list variable.

    The new test cases use testtools.matchers.HasLength and while seeing
    if testtools was imported I noticed it (along with mox) was in the
    wrong import group, so also fixed the order there.

    This patch also fixes the test_get_server_details_empty unit test to
    actually call the detail method rather than index.

    Closes-Bug: #1296940

    Change-Id: I9f85c2a0b70f41e5bba2da05a2339caf2a8efc3e

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