From 26f000ebb91f1cbd54f2bfde53eafdbd60a880a7 Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Tue, 20 Feb 2018 12:47:45 -0500 Subject: [PATCH] Drop API compat handling for old compute error cases Change Ibcb6bf912b3fb69c8631665fef2832906ba338aa dropped the compute RPC API code for checking old computes from the API and raising specific errors if the API is trying to perform some action on an instance running on an old compute that can't handle that action. With that change, the API now expects that computes should be able to handle at least Queens level operations, i.e. the can_send_version checks for those operations in the compute RPC API code would not be False. Since those compute RPC API checks are removed, the handling in the API is dead code now, so we can cleanup that handling. Change-Id: Ibd05139c5f6a0548f17e24d3807746b93d76f446 --- .../openstack/compute/attach_interfaces.py | 2 +- nova/api/openstack/compute/migrate_server.py | 3 +-- .../openstack/compute/server_diagnostics.py | 12 ------------ nova/api/openstack/compute/servers.py | 2 -- nova/api/openstack/compute/volumes.py | 2 +- nova/conductor/manager.py | 2 -- nova/exception.py | 19 +++---------------- .../test_instance.py | 2 +- .../openstack/compute/test_migrate_server.py | 4 ---- .../api/openstack/compute/test_serversV21.py | 7 ------- nova/tests/unit/conductor/test_conductor.py | 1 - 11 files changed, 7 insertions(+), 49 deletions(-) diff --git a/nova/api/openstack/compute/attach_interfaces.py b/nova/api/openstack/compute/attach_interfaces.py index b4ad3b67722c..717b85f132f6 100644 --- a/nova/api/openstack/compute/attach_interfaces.py +++ b/nova/api/openstack/compute/attach_interfaces.py @@ -137,7 +137,7 @@ class InterfaceAttachmentController(wsgi.Controller): exception.PortNotUsable, exception.AttachInterfaceNotSupported, exception.SecurityGroupCannotBeApplied, - exception.TaggedAttachmentNotSupported) as e: + exception.NetworkInterfaceTaggedAttachNotSupported) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except (exception.InstanceIsLocked, exception.FixedIpAlreadyInUse, diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py index a85679ccad33..789e7721e943 100644 --- a/nova/api/openstack/compute/migrate_server.py +++ b/nova/api/openstack/compute/migrate_server.py @@ -115,8 +115,7 @@ class MigrateServerController(wsgi.Controller): exception.InvalidLocalStorage, exception.InvalidSharedStorage, exception.HypervisorUnavailable, - exception.MigrationPreCheckError, - exception.LiveMigrationWithOldNovaNotSupported) as ex: + exception.MigrationPreCheckError) as ex: if async: with excutils.save_and_reraise_exception(): LOG.error("Unexpected exception received from " diff --git a/nova/api/openstack/compute/server_diagnostics.py b/nova/api/openstack/compute/server_diagnostics.py index 2794303581f4..5e091f74c10d 100644 --- a/nova/api/openstack/compute/server_diagnostics.py +++ b/nova/api/openstack/compute/server_diagnostics.py @@ -21,7 +21,6 @@ from nova.api.openstack.compute.views import server_diagnostics from nova.api.openstack import wsgi from nova import compute from nova import exception -from nova.i18n import _ from nova.policies import server_diagnostics as sd_policies @@ -51,16 +50,5 @@ class ServerDiagnosticsController(wsgi.Controller): 'get_diagnostics', server_id) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) - except exception.InstanceDiagnosticsNotSupported: - # NOTE(snikitin): During upgrade we may face situation when env - # has new API and old compute. New compute returns a - # Diagnostics object. Old compute returns a dictionary. So we - # can't perform a request correctly if compute is too old. - msg = _('Compute node is too old. You must complete the ' - 'upgrade process to be able to get standardized ' - 'diagnostics data which is available since v2.48. However ' - 'you are still able to get diagnostics data in ' - 'non-standardized format which is available until v2.47.') - raise webob.exc.HTTPBadRequest(explanation=msg) except NotImplementedError: common.raise_feature_not_supported() diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 9f13c2e58d55..50c1c689aaf9 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -1146,8 +1146,6 @@ class ServersController(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'trigger_crash_dump', id) - except exception.TriggerCrashDumpNotSupported as e: - raise webob.exc.HTTPBadRequest(explanation=e.format_message()) def remove_invalid_options(context, search_options, allowed_search_options): diff --git a/nova/api/openstack/compute/volumes.py b/nova/api/openstack/compute/volumes.py index 27b9af950293..a862c1ad4656 100644 --- a/nova/api/openstack/compute/volumes.py +++ b/nova/api/openstack/compute/volumes.py @@ -348,7 +348,7 @@ class VolumeAttachmentController(wsgi.Controller): except (exception.InvalidVolume, exception.InvalidDevicePath, exception.InvalidInput, - exception.TaggedAttachmentNotSupported, + exception.VolumeTaggedAttachNotSupported, exception.MultiattachNotSupportedOldMicroversion, exception.MultiattachToShelvedNotSupported) as e: raise exc.HTTPBadRequest(explanation=e.format_message()) diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py index 632d0325d99b..e26deb3c8826 100644 --- a/nova/conductor/manager.py +++ b/nova/conductor/manager.py @@ -255,7 +255,6 @@ class ComputeTaskManager(base.Base): exception.HypervisorUnavailable, exception.InstanceInvalidState, exception.MigrationPreCheckError, - exception.LiveMigrationWithOldNovaNotSupported, exception.UnsupportedPolicyException) @targets_cell @wrap_instance_event(prefix='conductor') @@ -432,7 +431,6 @@ class ComputeTaskManager(base.Base): exception.HypervisorUnavailable, exception.InstanceInvalidState, exception.MigrationPreCheckError, - exception.LiveMigrationWithOldNovaNotSupported, exception.MigrationSchedulerRPCError) as ex: with excutils.save_and_reraise_exception(): # TODO(johngarbutt) - eventually need instance actions here diff --git a/nova/exception.py b/nova/exception.py index 4c844347f0f6..3548608e725c 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -298,21 +298,17 @@ class VolumeEncryptionNotSupported(Invalid): "volume %(volume_id)s") -class TaggedAttachmentNotSupported(Invalid): - msg_fmt = _("Tagged device attachment is not yet available.") - - -class VolumeTaggedAttachNotSupported(TaggedAttachmentNotSupported): +class VolumeTaggedAttachNotSupported(Invalid): msg_fmt = _("Tagged volume attachment is not supported for this server " "instance.") -class VolumeTaggedAttachToShelvedNotSupported(TaggedAttachmentNotSupported): +class VolumeTaggedAttachToShelvedNotSupported(VolumeTaggedAttachNotSupported): msg_fmt = _("Tagged volume attachment is not supported for " "shelved-offloaded instances.") -class NetworkInterfaceTaggedAttachNotSupported(TaggedAttachmentNotSupported): +class NetworkInterfaceTaggedAttachNotSupported(Invalid): msg_fmt = _("Tagged network interface attachment is not supported for " "this server instance.") @@ -1821,11 +1817,6 @@ class InvalidWatchdogAction(Invalid): msg_fmt = _("Provided watchdog action (%(action)s) is not supported.") -class LiveMigrationWithOldNovaNotSupported(NovaException): - msg_fmt = _("Live migration with API v2.25 requires all the Mitaka " - "upgrade to be complete before it is available.") - - class SelectionObjectsWithOldRPCVersionNotSupported(NovaException): msg_fmt = _("Requests for Selection objects with alternates are not " "supported in select_destinations() before RPC version 4.5; " @@ -2101,10 +2092,6 @@ class AttachInterfaceNotSupported(Invalid): "instance %(instance_uuid)s.") -class InstanceDiagnosticsNotSupported(Invalid): - msg_fmt = _("Instance diagnostics are not supported by compute node.") - - class InvalidReservedMemoryPagesOption(Invalid): msg_fmt = _("The format of the option 'reserved_huge_pages' is invalid. " "(found '%(conf)s') Please refer to the nova " diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py index 9e3f17bc7055..0d3a515f3be9 100644 --- a/nova/tests/functional/notification_sample_tests/test_instance.py +++ b/nova/tests/functional/notification_sample_tests/test_instance.py @@ -66,7 +66,7 @@ class TestInstanceNotificationSampleWithMultipleCompute( self._wait_for_state_change(self.admin_api, server, 'ACTIVE') @mock.patch('nova.compute.rpcapi.ComputeAPI.pre_live_migration', - side_effect=exception.LiveMigrationWithOldNovaNotSupported()) + side_effect=exception.DestinationDiskExists(path='path')) def _test_live_migration_rollback(self, server, mock_migration): post = { 'os-migrateLive': { diff --git a/nova/tests/unit/api/openstack/compute/test_migrate_server.py b/nova/tests/unit/api/openstack/compute/test_migrate_server.py index 147c5597512f..e940279caa1f 100644 --- a/nova/tests/unit/api/openstack/compute/test_migrate_server.py +++ b/nova/tests/unit/api/openstack/compute/test_migrate_server.py @@ -330,10 +330,6 @@ class MigrateServerTestsV225(MigrateServerTestsV21): self.controller._migrate_live, self.req, fakes.FAKE_UUID, body=body) - def test_migrate_live_migration_with_old_nova_not_supported(self): - self._test_migrate_live_failed_with_exception( - exception.LiveMigrationWithOldNovaNotSupported()) - class MigrateServerTestsV230(MigrateServerTestsV225): force = False diff --git a/nova/tests/unit/api/openstack/compute/test_serversV21.py b/nova/tests/unit/api/openstack/compute/test_serversV21.py index 77a019d316fa..88392a980214 100644 --- a/nova/tests/unit/api/openstack/compute/test_serversV21.py +++ b/nova/tests/unit/api/openstack/compute/test_serversV21.py @@ -2607,13 +2607,6 @@ class ServersControllerTriggerCrashDumpTest(ControllerTest): self.controller._action_trigger_crash_dump, self.req, FAKE_UUID, body=self.body) - @mock.patch.object(compute_api.API, 'trigger_crash_dump', - side_effect=exception.TriggerCrashDumpNotSupported) - def test_trigger_crash_dump_not_supported(self, mock_trigger_crash_dump): - self.assertRaises(webob.exc.HTTPBadRequest, - self.controller._action_trigger_crash_dump, - self.req, FAKE_UUID, body=self.body) - class ServersControllerUpdateTestV219(ServersControllerUpdateTest): def _get_request(self, body=None): diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py index 10d8403ee44a..4d917511a786 100644 --- a/nova/tests/unit/conductor/test_conductor.py +++ b/nova/tests/unit/conductor/test_conductor.py @@ -2132,7 +2132,6 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase): state='', method=''), exc.DestinationHypervisorTooOld(), exc.HypervisorUnavailable(host='dummy'), - exc.LiveMigrationWithOldNovaNotSupported(), exc.MigrationPreCheckError(reason='dummy'), exc.InvalidSharedStorage(path='dummy', reason='dummy'), exc.NoValidHost(reason='dummy'),