Race conditions attaching/detaching volumes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack Compute (nova) |
Confirmed
|
Medium
|
Han Guangyu |
Bug Description
For cinder volume attach and detach operations Nova is properly using os-brick's `guard_connection` as a context manager to protect against race conditions the the local disconnection of the volume and the call to cinder to unmap/unexport the volume with other volumes' local connection and map/export.
This is the code:
def detach(self, context, instance, volume_api, virt_driver,
volume = self._get_
# Let OS-Brick handle high level locking that covers the local os-brick
# detach and the Cinder call to call unmap the volume. Not all volume
# backends or hosts require locking.
with brick_utils.
@update_db
def attach(self, context, instance, volume_api, virt_driver,
volume = self._get_
# Let OS-Brick handle high level locking that covers the call to
# Cinder that exports & maps the volume, and for the local os-brick
# attach. Not all volume backends or hosts require locking.
with brick_utils.
But there are many other places where Nova does attach or detach not using those 2 methods (`detach` and `attach`).
One example is when we delete an instance that has cinder volumes attached, another one is when finishing an instance live migration.
Nova needs to always use the `guard_connection` context manager.
There are places where it will be easy to fix such as the `_remove_
But there are others where it looks like it will be harder like `_shutdown_
Changed in nova: | |
assignee: | nobody → Han Guangyu (han-guangyu) |
Tagged as low-hanging-fruit as new contributors could add the context manager easily first, and then ask us how to modify the other methods.