Get updated vol status in volume.api.reserve.
A race condtion was discovered where a nova volume attach could easily be performed twice for the same volume. Although the cinder attach update would fail, this occured after the BDM updates were made and in essence the attach to the compute instance had already been issued. This change simply forces a get from the DB of the volume-ref in the reserve call and checks if an attach is already in progress. Fixes bug: 1096983 Change-Id: Ie0e4156d691ee92b6981078ef0ba62f8c4cdf0c8
This commit is contained in:
@@ -416,7 +416,15 @@ class API(base.Base):
|
||||
|
||||
@wrap_check_policy
|
||||
def reserve_volume(self, context, volume):
|
||||
self.update(context, volume, {"status": "attaching"})
|
||||
#NOTE(jdg): check for Race condition bug 1096983
|
||||
#explicitly get updated ref and check
|
||||
volume = self.db.volume_get(context, volume['id'])
|
||||
if volume['status'] == 'available':
|
||||
self.update(context, volume, {"status": "attaching"})
|
||||
else:
|
||||
msg = _("Volume status must be available to reserve")
|
||||
LOG.error(msg)
|
||||
raise exception.InvalidVolume(reason=msg)
|
||||
|
||||
@wrap_check_policy
|
||||
def unreserve_volume(self, context, volume):
|
||||
|
Reference in New Issue
Block a user