Remove MIN_COMPUTE_MULTIATTACH conditions in API

nova-compute service version 27 was added in Queens [1]
and the API started relying on it in Queens [2] when
creating a server with a multi-attach volume.

We are long past supporting computes older than Queens
so we can drop that minimum service version check code
from the server create API flow and related error handling.

Note that when attaching a multi-attach volume to a server
the version compatibility was handled in the compute RPC API
reserve_block_device_name method, but that code was removed
in Rocky [3]. However, the volume attach API still has to
handle the MultiattachSupportNotYetAvailable exception if
using cells v1 because it is raised from
ComputeCellsAPI._attach_volume.

[1] Ieec2bbd8a23c861c89bf9922517fa6a5562f1937
[2] I02120ef8767c3f9c9497bff67101e57e204ed6f4
[3] Ibcb6bf912b3fb69c8631665fef2832906ba338aa

Change-Id: I7700f66fd590b617333ae99c1b42986278b36263
This commit is contained in:
Matt Riedemann 2019-04-02 18:20:58 -04:00
parent 2e5d0eda84
commit 544cfedd16
4 changed files with 2 additions and 39 deletions

View File

@ -750,7 +750,6 @@ class ServersController(wsgi.Controller):
exception.InstanceExists,
exception.NetworkAmbiguous,
exception.NoUniqueMatch,
exception.MultiattachSupportNotYetAvailable,
exception.VolumeTypeSupportNotYetAvailable,
exception.CertificateValidationNotYetAvailable) as error:
raise exc.HTTPConflict(explanation=error.format_message())

View File

@ -105,7 +105,6 @@ AGGREGATE_ACTION_UPDATE_META = 'UpdateMeta'
AGGREGATE_ACTION_DELETE = 'Delete'
AGGREGATE_ACTION_ADD = 'Add'
CINDER_V3_ATTACH_MIN_COMPUTE_VERSION = 24
MIN_COMPUTE_MULTIATTACH = 27
MIN_COMPUTE_TRUSTED_CERTS = 31
MIN_COMPUTE_ABORT_QUEUED_LIVE_MIGRATION = 34
MIN_COMPUTE_VOLUME_TYPE = 36
@ -1564,8 +1563,7 @@ class API(base.Base):
bdm.attachment_id = None
except (exception.CinderConnectionFailed,
exception.InvalidVolume,
exception.MultiattachNotSupportedOldMicroversion,
exception.MultiattachSupportNotYetAvailable):
exception.MultiattachNotSupportedOldMicroversion):
raise
except exception.InvalidInput as exc:
raise exception.InvalidVolume(reason=exc.format_message())
@ -4122,11 +4120,6 @@ class API(base.Base):
min_compute_version = \
objects.service.get_minimum_version_all_cells(
context, ['nova-compute'])
# Check to see if the computes have been upgraded to support
# booting from a multiattach volume.
if (volume['multiattach'] and
min_compute_version < MIN_COMPUTE_MULTIATTACH):
raise exception.MultiattachSupportNotYetAvailable()
if min_compute_version >= CINDER_V3_ATTACH_MIN_COMPUTE_VERSION:
# Attempt a new style volume attachment, but fallback to old-style

View File

@ -6418,17 +6418,6 @@ class ServersControllerCreateTestV260(test.NoDBTestCase):
self.assertIn('Multiattach volumes are only supported starting with '
'compute API version 2.60', six.text_type(ex))
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
return_value=compute_api.MIN_COMPUTE_MULTIATTACH - 1)
def test_create_server_with_multiattach_fails_not_available(
self, mock_get_min_version_all_cells):
"""Tests the case that the user tries to boot from volume with a
multiattach volume but before the deployment is fully upgraded.
"""
ex = self.assertRaises(webob.exc.HTTPConflict, self._post_server)
self.assertIn('Multiattach volume support is not yet available',
six.text_type(ex))
class ServersControllerCreateTestV263(ServersControllerCreateTest):
def _create_instance_req(self, certs=None):

View File

@ -6618,26 +6618,8 @@ class ComputeAPIUnitTestCase(_ComputeAPIUnitTestMixIn, test.NoDBTestCase):
self.context, volume, instance, bdm,
supports_multiattach=False)
@mock.patch('nova.objects.service.get_minimum_version_all_cells',
return_value=compute_api.MIN_COMPUTE_MULTIATTACH - 1)
def test_check_attach_and_reserve_volume_multiattach_new_inst_old_compute(
self, get_min_version):
"""Tests that _check_attach_and_reserve_volume fails if trying
to use a multiattach volume to create a new instance but the computes
are not all upgraded yet.
"""
instance = self._create_instance_obj()
delattr(instance, 'id')
volume = {'id': uuids.volumeid, 'multiattach': True}
bdm = objects.BlockDeviceMapping(volume_id=uuids.volumeid,
instance_uuid=instance.uuid)
self.assertRaises(exception.MultiattachSupportNotYetAvailable,
self.compute_api._check_attach_and_reserve_volume,
self.context, volume, instance, bdm,
supports_multiattach=True)
@mock.patch('nova.objects.Service.get_minimum_version',
return_value=compute_api.MIN_COMPUTE_MULTIATTACH)
return_value=compute_api.CINDER_V3_ATTACH_MIN_COMPUTE_VERSION)
@mock.patch('nova.volume.cinder.API.get',
return_value={'id': uuids.volumeid, 'multiattach': True})
@mock.patch('nova.volume.cinder.is_microversion_supported',