summaryrefslogtreecommitdiff
path: root/nova/virt/block_device.py
diff options
context:
space:
mode:
authorIldiko Vancsa <ildiko.vancsa@ericsson.com>2016-06-28 16:05:53 +0200
committerMatt Riedemann <mriedem.os@gmail.com>2017-02-26 20:34:05 -0500
commit63805735c25a54ad1b9b97e05080c1a6153d8e22 (patch)
tree9b54a44f56465108550a49359d7a21d23baeeee2 /nova/virt/block_device.py
parent8b498ce199ac4acd94eb33a7f47c05ee0c743c34 (diff)
downloadnova-63805735c25a54ad1b9b97e05080c1a6153d8e22.tar.gz
Remove check_attach
This patch finishes to remove the 'check_attach' call from Nova completely. As Cinder already performs the required checks as part of the 'reserve_volume' (os-reserve) call it is unnecessary to check the statemachine in Nova also and it can lead to race conditions. The missing 'reserve_volume' call is added to the BFV flow. In case of build failure the volume will be locked in 'attaching' state until the instance in ERROR state is cleaned up. We also check AZ for each volume attach operation which we haven't done for unshelve. A release note is added to enable 'cross_az_attach' in case the user does not care about AZ. The compute service version had to be bumped as the old computes still perform 'check_attach', which will fail when the API reserves the volume and the volume state moves to 'attaching'. If the computes are not new enough the old check will be called as opposed to 'reserve_volume'. Closes-Bug: #1581230 Change-Id: I3a3caa4c566ecc132aa2699f8c7e5987bbcc863a
Diffstat (limited to 'nova/virt/block_device.py')
-rw-r--r--nova/virt/block_device.py21
1 files changed, 9 insertions, 12 deletions
diff --git a/nova/virt/block_device.py b/nova/virt/block_device.py
index 1da9d09912..d8c07aea98 100644
--- a/nova/virt/block_device.py
+++ b/nova/virt/block_device.py
@@ -244,10 +244,10 @@ class DriverVolumeBlockDevice(DriverBlockDevice):
@update_db
def attach(self, context, instance, volume_api, virt_driver,
- do_check_attach=True, do_driver_attach=False, **kwargs):
+ do_driver_attach=False, **kwargs):
volume = volume_api.get(context, self.volume_id)
- if do_check_attach:
- volume_api.check_attach(context, volume, instance=instance)
+ volume_api.check_availability_zone(context, volume,
+ instance=instance)
volume_id = volume['id']
context = context.elevated()
@@ -367,7 +367,7 @@ class DriverSnapshotBlockDevice(DriverVolumeBlockDevice):
_proxy_as_attr = set(['volume_size', 'volume_id', 'snapshot_id'])
def attach(self, context, instance, volume_api,
- virt_driver, wait_func=None, do_check_attach=True):
+ virt_driver, wait_func=None):
if not self.volume_id:
av_zone = _get_volume_create_az_value(instance)
@@ -382,8 +382,7 @@ class DriverSnapshotBlockDevice(DriverVolumeBlockDevice):
# Call the volume attach now
super(DriverSnapshotBlockDevice, self).attach(
- context, instance, volume_api, virt_driver,
- do_check_attach=do_check_attach)
+ context, instance, volume_api, virt_driver)
class DriverImageBlockDevice(DriverVolumeBlockDevice):
@@ -392,7 +391,7 @@ class DriverImageBlockDevice(DriverVolumeBlockDevice):
_proxy_as_attr = set(['volume_size', 'volume_id', 'image_id'])
def attach(self, context, instance, volume_api,
- virt_driver, wait_func=None, do_check_attach=True):
+ virt_driver, wait_func=None):
if not self.volume_id:
av_zone = _get_volume_create_az_value(instance)
vol = volume_api.create(context, self.volume_size,
@@ -404,8 +403,7 @@ class DriverImageBlockDevice(DriverVolumeBlockDevice):
self.volume_id = vol['id']
super(DriverImageBlockDevice, self).attach(
- context, instance, volume_api, virt_driver,
- do_check_attach=do_check_attach)
+ context, instance, volume_api, virt_driver)
class DriverBlankBlockDevice(DriverVolumeBlockDevice):
@@ -414,7 +412,7 @@ class DriverBlankBlockDevice(DriverVolumeBlockDevice):
_proxy_as_attr = set(['volume_size', 'volume_id', 'image_id'])
def attach(self, context, instance, volume_api,
- virt_driver, wait_func=None, do_check_attach=True):
+ virt_driver, wait_func=None):
if not self.volume_id:
vol_name = instance.uuid + '-blank-vol'
av_zone = _get_volume_create_az_value(instance)
@@ -426,8 +424,7 @@ class DriverBlankBlockDevice(DriverVolumeBlockDevice):
self.volume_id = vol['id']
super(DriverBlankBlockDevice, self).attach(
- context, instance, volume_api, virt_driver,
- do_check_attach=do_check_attach)
+ context, instance, volume_api, virt_driver)
def _convert_block_devices(device_type, block_device_mapping):