Remove Stein compute compat checks for volume type support
Support for boot from volume where nova creates the volume with a specified volume type was added in Stein [1] and an API validation check was added to only allow that if the computes were upgraded to Stein [2]. Now that we're in Ussuri and don't need to support pre-Stein computes we can drop that API compat check. [1] Icc301230fe7c8e3ebbbcc7f4a807e562db7f93e3 [2] I45bd42908d44a0f05e1231febab926b23232b57b Change-Id: If9c459a9a0aa752c478949e4240286cbdb146494
This commit is contained in:
parent
56d3f4657c
commit
4ac308f0ae
|
@ -771,8 +771,7 @@ class ServersController(wsgi.Controller):
|
|||
except (exception.PortInUse,
|
||||
exception.InstanceExists,
|
||||
exception.NetworkAmbiguous,
|
||||
exception.NoUniqueMatch,
|
||||
exception.VolumeTypeSupportNotYetAvailable) as error:
|
||||
exception.NoUniqueMatch) as error:
|
||||
raise exc.HTTPConflict(explanation=error.format_message())
|
||||
|
||||
# If the caller wanted a reservation_id, return it
|
||||
|
|
|
@ -104,7 +104,6 @@ AGGREGATE_ACTION_UPDATE_META = 'UpdateMeta'
|
|||
AGGREGATE_ACTION_DELETE = 'Delete'
|
||||
AGGREGATE_ACTION_ADD = 'Add'
|
||||
MIN_COMPUTE_ABORT_QUEUED_LIVE_MIGRATION = 34
|
||||
MIN_COMPUTE_VOLUME_TYPE = 36
|
||||
MIN_COMPUTE_SYNC_COMPUTE_STATUS_DISABLED = 38
|
||||
|
||||
# FIXME(danms): Keep a global cache of the cells we find the
|
||||
|
@ -1505,16 +1504,6 @@ class API(base.Base):
|
|||
raise exception.VolumeTypeNotFound(
|
||||
id_or_name=volume_type_id_or_name)
|
||||
|
||||
@staticmethod
|
||||
def _check_compute_supports_volume_type(context):
|
||||
# NOTE(brinzhang): Checking the minimum nova-compute service
|
||||
# version across the deployment. Just make sure the volume
|
||||
# type can be supported when the bdm.volume_type is requested.
|
||||
min_compute_version = objects.service.get_minimum_version_all_cells(
|
||||
context, ['nova-compute'])
|
||||
if min_compute_version < MIN_COMPUTE_VOLUME_TYPE:
|
||||
raise exception.VolumeTypeSupportNotYetAvailable()
|
||||
|
||||
def _validate_bdm(self, context, instance, instance_type,
|
||||
block_device_mappings, supports_multiattach=False):
|
||||
# Make sure that the boot indexes make sense.
|
||||
|
@ -1536,22 +1525,9 @@ class API(base.Base):
|
|||
raise exception.InvalidBDMBootSequence()
|
||||
|
||||
volume_types = None
|
||||
volume_type_is_supported = False
|
||||
for bdm in block_device_mappings:
|
||||
volume_type = bdm.volume_type
|
||||
if volume_type:
|
||||
if not volume_type_is_supported:
|
||||
# The following method raises
|
||||
# VolumeTypeSupportNotYetAvailable if the minimum
|
||||
# nova-compute service version across the deployment is
|
||||
# not new enough to support creating volumes with a
|
||||
# specific type.
|
||||
self._check_compute_supports_volume_type(context)
|
||||
# Set the flag to avoid calling
|
||||
# _check_compute_supports_volume_type more than once in
|
||||
# this for loop.
|
||||
volume_type_is_supported = True
|
||||
|
||||
if not volume_types:
|
||||
# In order to reduce the number of hit cinder APIs,
|
||||
# initialize our cache of volume types.
|
||||
|
|
|
@ -287,14 +287,6 @@ class MultiattachNotSupportedOldMicroversion(Invalid):
|
|||
'compute API version 2.60.')
|
||||
|
||||
|
||||
class VolumeTypeSupportNotYetAvailable(NovaException):
|
||||
# This exception indicates the deployment is not yet new enough to support
|
||||
# volume type, so a 409 HTTPConflict response is generally used
|
||||
# for handling this in the API.
|
||||
msg_fmt = _("Volume type support is not yet available.")
|
||||
code = 409
|
||||
|
||||
|
||||
class MultiattachToShelvedNotSupported(Invalid):
|
||||
msg_fmt = _("Attaching multiattach volumes is not supported for "
|
||||
"shelved-offloaded instances.")
|
||||
|
|
|
@ -6838,10 +6838,7 @@ class ServersControllerCreateTestV267(ServersControllerCreateTest):
|
|||
return super(ServersControllerCreateTestV267, self)._test_create_extra(
|
||||
*args, **kwargs)
|
||||
|
||||
@mock.patch('nova.objects.Service.get_minimum_version',
|
||||
return_value=compute_api.MIN_COMPUTE_VOLUME_TYPE)
|
||||
def test_create_server_with_trusted_volume_type_pre_2_67_fails(self,
|
||||
get_min_ver):
|
||||
def test_create_server_with_trusted_volume_type_pre_2_67_fails(self):
|
||||
"""Make sure we can't use volume_type before 2.67"""
|
||||
self.body['server'].update(
|
||||
{'block_device_mapping_v2': self.block_device_mapping_v2})
|
||||
|
@ -6866,18 +6863,6 @@ class ServersControllerCreateTestV267(ServersControllerCreateTest):
|
|||
self.assertIn('Volume type fake-lvm-1 could not be found',
|
||||
six.text_type(ex))
|
||||
|
||||
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
|
||||
return_value=compute_api.MIN_COMPUTE_VOLUME_TYPE - 1)
|
||||
def test_check_volume_type_new_inst_old_compute(self, get_min_version):
|
||||
"""Trying to boot from volume with a volume_type but not all computes
|
||||
are upgraded will result in a 409 error.
|
||||
"""
|
||||
params = {'block_device_mapping_v2': self.block_device_mapping_v2}
|
||||
ex = self.assertRaises(webob.exc.HTTPConflict,
|
||||
self._test_create_extra, params)
|
||||
self.assertIn('Volume type support is not yet available',
|
||||
six.text_type(ex))
|
||||
|
||||
def test_create_instance_with_volume_type_empty_string(self):
|
||||
"""Test passing volume_type='' which is accepted but not used."""
|
||||
self.block_device_mapping_v2[0]['volume_type'] = ''
|
||||
|
|
|
@ -4288,12 +4288,8 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
self.context, objects.Instance(), objects.Flavor(),
|
||||
bdms)
|
||||
|
||||
@mock.patch.object(objects.service, 'get_minimum_version_all_cells',
|
||||
return_value=compute_api.MIN_COMPUTE_VOLUME_TYPE)
|
||||
def test_validate_bdm_with_volume_type_name_is_specified(
|
||||
self, mock_get_min_version):
|
||||
"""Test _check_requested_volume_type and
|
||||
_check_compute_supports_volume_type methods are used.
|
||||
def test_validate_bdm_with_volume_type_name_is_specified(self):
|
||||
"""Test _check_requested_volume_type method is used.
|
||||
"""
|
||||
instance = self._create_instance_obj()
|
||||
instance_type = self._create_flavor()
|
||||
|
@ -4329,16 +4325,13 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
with test.nested(
|
||||
mock.patch.object(cinder.API, 'get_all_volume_types',
|
||||
return_value=volume_types),
|
||||
mock.patch.object(compute_api.API,
|
||||
'_check_compute_supports_volume_type'),
|
||||
mock.patch.object(compute_api.API,
|
||||
'_check_requested_volume_type')) as (
|
||||
get_all_vol_types, vol_type_supported, vol_type_requested):
|
||||
get_all_vol_types, vol_type_requested):
|
||||
|
||||
self.compute_api._validate_bdm(self.context, instance,
|
||||
instance_type, bdms)
|
||||
|
||||
vol_type_supported.assert_called_once_with(self.context)
|
||||
get_all_vol_types.assert_called_once_with(self.context)
|
||||
|
||||
vol_type_requested.assert_any_call(bdms[0], volume_type,
|
||||
|
@ -4377,10 +4370,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||
bdms)
|
||||
mock_get_image.assert_called_once_with(self.context, image_id)
|
||||
|
||||
@mock.patch.object(objects.service, 'get_minimum_version_all_cells',
|
||||
return_value=compute_api.MIN_COMPUTE_VOLUME_TYPE)
|
||||
def test_the_specified_volume_type_id_assignment_to_name(
|
||||
self, mock_get_min_version):
|
||||
def test_the_specified_volume_type_id_assignment_to_name(self):
|
||||
"""Test _check_requested_volume_type method is called, if the user
|
||||
is using the volume type ID, assign volume_type to volume type name.
|
||||
"""
|
||||
|
@ -6395,22 +6385,7 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
|
|||
self.compute_api.attach_volume,
|
||||
self.context, instance, uuids.volumeid)
|
||||
|
||||
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
|
||||
return_value=compute_api.MIN_COMPUTE_VOLUME_TYPE - 1)
|
||||
def test_check_compute_supports_volume_type_new_inst_old_compute(
|
||||
self, get_min_version):
|
||||
"""Tests that _check_compute_supports_volume_type fails if trying to
|
||||
specify a volume type to create a new instance but the nova-compute
|
||||
service version are not all upgraded yet.
|
||||
"""
|
||||
self.assertRaises(exception.VolumeTypeSupportNotYetAvailable,
|
||||
self.compute_api._check_compute_supports_volume_type,
|
||||
self.context)
|
||||
|
||||
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
|
||||
return_value=compute_api.MIN_COMPUTE_VOLUME_TYPE)
|
||||
def test_validate_bdm_check_volume_type_raise_not_found(
|
||||
self, get_min_version):
|
||||
def test_validate_bdm_check_volume_type_raise_not_found(self):
|
||||
"""Tests that _validate_bdm will fail if the requested volume type
|
||||
name or id does not match the volume types in Cinder.
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue