Race when associating instance_uuid

Bug #1244541 reported by aeva black
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ironic
Fix Released
High
Haomeng,Wang

Bug Description

The association of a Nova instance to an Ironic node represents the "ownership" of that node. This is currently updated by sending a PATCH request to the API service, which will replace the current value of `nodes`.`instance_uuid` with the supplied value. Because this a node property, not a nested property, it is not possible to remove it; instance_uuid can only be replaced.

Even if the Nova driver implements a LBYL approach -- first, GET the node and check that instance_uuid is empty, then PATCH the new value -- it would still be possible for another client (another instance of nova-compute) to PATCH at the same time, leading to unexpected behavior.

Since Ironic does not return an exception when overwriting the instance_uuid, it is not currently possible for the Nova driver to implement a EAFP approach, and there is no way to avoid a race condition here.

aeva black (tenbrae)
Changed in ironic:
status: New → Triaged
importance: Undecided → High
Revision history for this message
aeva black (tenbrae) wrote :

For reference, I solved this in the nova baremetal code with the db.api method bm_node_associate_and_update, here:

http://git.openstack.org/cgit/openstack/nova/tree/nova/virt/baremetal/db/sqlalchemy/api.py#n190

Revision history for this message
Haomeng,Wang (whaom) wrote :

Devananda, ok I will try to port your code to our Ironic, and help me review, thanks.

Haomeng,Wang (whaom)
Changed in ironic:
assignee: nobody → Haomeng,Wang (whaom)
aeva black (tenbrae)
Changed in ironic:
milestone: none → icehouse-2
Haomeng,Wang (whaom)
Changed in ironic:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

Fix proposed to branch: master
Review: https://review.openstack.org/62160

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to ironic (master)

Reviewed: https://review.openstack.org/62160
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=3f858cc6742078fa5c238f6e14dc443897abb7e6
Submitter: Jenkins
Branch: master

commit 3f858cc6742078fa5c238f6e14dc443897abb7e6
Author: Haomeng, Wang <email address hidden>
Date: Sat Dec 14 19:48:36 2013 +0800

    Avoid a race when associating instance_uuid

    Current code can potentially overwrite the instance_uuid without
    exception when multiple dbapi.update_node calls are issued. This
    patch adds a check to dbapi so that the NodeAssociated exception
    will be raised in this case.
    The Nova Ironic driver will handle this exception. This will be
    introduced in a separate patch.

    Change-Id: I28ef5ce55399bde7073ffc111e9bc4400e5577ee
    Partial-Bug: #1244541

Revision history for this message
Haomeng,Wang (whaom) wrote :

The dbapi code patch is merged, and for Ironic nova driver part will covered by this merged patch [1] to catch the exception.NodeAssociated to prevent duplicated instance_uuid population, add review comments already.

[1] https://review.openstack.org/62160
[2] https://review.openstack.org/#/c/51328/8/nova/virt/ironic/driver.py

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