Nova not always using get to access driver capabilites dict

Bug #1746608 reported by Eric Berglund
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Eric Berglund

Bug Description

When accessing the capabilities dict [1], nova should be using dict.get(). Since many compute drivers override the capabilities dictionary,

capabilites['capability']

will fail with a KeyError if their dictionary has not been updated to include the capability. By using get() it will default instead of throwing the KeyError.

[1] https://github.com/openstack/nova/blob/5251f18d87/nova/virt/driver.py#L124-L134

Eric Berglund (esberglu)
Changed in nova:
assignee: nobody → Eric Berglund (esberglu)
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/539715

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

Reviewed: https://review.openstack.org/539715
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=2dd322a64291c20da33f28fd5c302ff27e70eae4
Submitter: Zuul
Branch: master

commit 2dd322a64291c20da33f28fd5c302ff27e70eae4
Author: esberglu <email address hidden>
Date: Wed Jan 31 16:29:57 2018 -0600

    Use dict.get() when accessing capabilities dict

    Many compute drivers override the driver capabilities dict [1]. The
    code should be using dict.get() to avoid throwing KeyErrors if the
    overriding dictionaries do not have the corresponding keys. If the
    key is not found it will be assumed the the capability is not supported
    and default to false. This ensures that no drivers are broken because
    they are missing a capability.

    [1] https://github.com/openstack/nova/blob/5251f18d87/nova/virt/driver.py#L124-L134

    Change-Id: I1fa04fa110f2c65e10c065c61f2f0f58c1fad646
    Closes-Bug: #1746608

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 18.0.0.0b1

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

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.