API for baremetal nodes fails if node has no interfaces

Bug #1131430 reported by aeva black
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
aeva black

Bug Description

If a baremetal node is created, but has no interfaces associated with it, API calls to list all nodes, show that node, or delete that node will fail until an interface is associated with it.

These API calls should work regardless of whether the node has any interfaces associated.

Errors from python-novaclient:

$ nova baremetal-node-list
ERROR: The resource could not be found. (HTTP 404) (Request-ID: req-11cc3b25-0b08-4b48-afa8-849a071a6ab9)
$ nova baremetal-node-delete 1
ERROR: No baremetalnode with a name or ID of '1' exists.

Error in nova-api:

2013-02-21 21:52:26.215 TRACE nova.api.openstack File "/opt/stack/nova/nova/api/openstack/compute/contrib/baremetal_nodes.py", line 106, in index
2013-02-21 21:52:26.215 TRACE nova.api.openstack context, node_from_db['id'])
2013-02-21 21:52:26.215 TRACE nova.api.openstack File "/opt/stack/nova/nova/virt/baremetal/db/api.py", line 186, in bm_interface_get_all_by_bm_node_id
2013-02-21 21:52:26.215 TRACE nova.api.openstack return IMPL.bm_interface_get_all_by_bm_node_id(context, bm_node_id)
2013-02-21 21:52:26.215 TRACE nova.api.openstack File "/opt/stack/nova/nova/db/sqlalchemy/api.py", line 95, in wrapper
2013-02-21 21:52:26.215 TRACE nova.api.openstack return f(*args, **kwargs)
2013-02-21 21:52:26.215 TRACE nova.api.openstack File "/opt/stack/nova/nova/virt/baremetal/db/sqlalchemy/api.py", line 428, in bm_interface_get_all_by_bm_node_id
2013-02-21 21:52:26.215 TRACE nova.api.openstack raise exception.NodeNotFound(node_id=bm_node_id)
2013-02-21 21:52:26.215 TRACE nova.api.openstack NodeNotFound: Node 1 could not be found.

The fix is simple: don't raise an exception in bm_interface_get_all_by_bm_node_id when there are no interfaces for that node id.

Tags: baremetal
aeva black (tenbrae)
Changed in nova:
assignee: nobody → Devananda van der Veen (devananda)
Revision history for this message
aeva black (tenbrae) wrote :

Actually, better solution - change the exception handling in nova/api/openstack/compute/contrib/baremetal_nodes.py to catch the right exceptions.

aeva black (tenbrae)
tags: added: baremetal
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/22627

Changed in nova:
status: New → In Progress
Sean Dague (sdague)
Changed in nova:
importance: Undecided → Medium
milestone: none → grizzly-rc1
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/22627
Committed: http://github.com/openstack/nova/commit/3aace2a610d8b5e7027ef141970e23cddba0294d
Submitter: Jenkins
Branch: master

commit 3aace2a610d8b5e7027ef141970e23cddba0294d
Author: Devananda van der Veen <email address hidden>
Date: Thu Feb 21 13:56:25 2013 -0800

    Fix exception handling in baremetal API.

    In patch ab9f8667c63d901f37d1662c5204fb2938be44fe, several
    baremetal/db/api methods' exceptions were changed from InstanceNotFound
    to NodeNotFound. The API extension for baremetal was not updated to
    catch these, and this was not caught by unit testing. This resulted in
    unhandled exceptions within nova-api if any baremetal node lacked an
    associated interface.

    While fixing that bug, a few other unit tests for the baremetal API
    were added, and a missing exception was added to db/api bm_node_destroy.

    Fixes bug 1131430.

    Change-Id: I15f7624723754f9d7b217b609663a2d709acb056

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