From 95dc5d0ab558604df7d8ef31eba8f9efaee9c474 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 5 Apr 2019 15:16:46 +0100 Subject: [PATCH] Stop handling 'InstanceUnknownCell' exception This was only raised by cells v1 code and therefore no longer needs to be handled. A future change will remove the exception itself. Part of blueprint remove-cells-v1 Change-Id: I1dd6abcc2be17ff76f108e7ff3771314f33259c6 Signed-off-by: Stephen Finucane --- nova/api/openstack/compute/admin_actions.py | 4 ---- nova/api/openstack/compute/admin_password.py | 2 -- nova/api/openstack/compute/create_backup.py | 2 -- nova/api/openstack/compute/deferred_delete.py | 5 +---- nova/api/openstack/compute/evacuate.py | 2 -- nova/api/openstack/compute/floating_ips.py | 2 -- nova/api/openstack/compute/migrate_server.py | 2 -- nova/api/openstack/compute/multinic.py | 4 ---- nova/api/openstack/compute/pause_server.py | 6 ++---- nova/api/openstack/compute/remote_consoles.py | 12 ++++-------- nova/api/openstack/compute/rescue.py | 4 ---- nova/api/openstack/compute/server_metadata.py | 11 ----------- nova/api/openstack/compute/servers.py | 16 ---------------- nova/api/openstack/compute/shelve.py | 6 ------ nova/api/openstack/compute/suspend_server.py | 4 ---- nova/api/openstack/compute/volumes.py | 5 +---- .../openstack/compute/test_deferred_delete.py | 13 ------------- 17 files changed, 8 insertions(+), 92 deletions(-) diff --git a/nova/api/openstack/compute/admin_actions.py b/nova/api/openstack/compute/admin_actions.py index 49eddda7e0ee..84624554ac82 100644 --- a/nova/api/openstack/compute/admin_actions.py +++ b/nova/api/openstack/compute/admin_actions.py @@ -44,8 +44,6 @@ class AdminActionsController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.reset_network(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) @@ -59,8 +57,6 @@ class AdminActionsController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.inject_network_info(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/admin_password.py b/nova/api/openstack/compute/admin_password.py index 407e9436056d..52fdf5a79640 100644 --- a/nova/api/openstack/compute/admin_password.py +++ b/nova/api/openstack/compute/admin_password.py @@ -47,8 +47,6 @@ class AdminPasswordController(wsgi.Controller): password = body['changePassword']['adminPass'] try: self.compute_api.set_admin_password(context, instance, password) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except (exception.InstancePasswordSetFailed, exception.SetAdminPasswdNotSupported, exception.InstanceAgentNotEnabled) as e: diff --git a/nova/api/openstack/compute/create_backup.py b/nova/api/openstack/compute/create_backup.py index 9b2f59cd3f3f..bf88454b4082 100644 --- a/nova/api/openstack/compute/create_backup.py +++ b/nova/api/openstack/compute/create_backup.py @@ -68,8 +68,6 @@ class CreateBackupController(wsgi.Controller): try: image = self.compute_api.backup(context, instance, image_name, backup_type, rotation, extra_properties=props) - except exception.InstanceUnknownCell as e: - raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'createBackup', id) diff --git a/nova/api/openstack/compute/deferred_delete.py b/nova/api/openstack/compute/deferred_delete.py index 4b6f26193835..4728204d3498 100644 --- a/nova/api/openstack/compute/deferred_delete.py +++ b/nova/api/openstack/compute/deferred_delete.py @@ -39,8 +39,6 @@ class DeferredDeleteController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.restore(context, instance) - except exception.InstanceUnknownCell as error: - raise webob.exc.HTTPNotFound(explanation=error.format_message()) except exception.QuotaError as error: raise webob.exc.HTTPForbidden(explanation=error.format_message()) except exception.InstanceInvalidState as state_error: @@ -59,8 +57,7 @@ class DeferredDeleteController(wsgi.Controller): 'project_id': instance.project_id}) try: self.compute_api.force_delete(context, instance) - except (exception.InstanceNotFound, - exception.InstanceUnknownCell) as e: + except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/evacuate.py b/nova/api/openstack/compute/evacuate.py index 2f26d5d703aa..b90588e20960 100644 --- a/nova/api/openstack/compute/evacuate.py +++ b/nova/api/openstack/compute/evacuate.py @@ -132,8 +132,6 @@ class EvacuateController(wsgi.Controller): try: self.compute_api.evacuate(context, instance, host, on_shared_storage, password, force) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'evacuate', id) diff --git a/nova/api/openstack/compute/floating_ips.py b/nova/api/openstack/compute/floating_ips.py index 3f42129d65a4..b148cc528358 100644 --- a/nova/api/openstack/compute/floating_ips.py +++ b/nova/api/openstack/compute/floating_ips.py @@ -272,8 +272,6 @@ class FloatingIPActionController(wsgi.Controller): except exception.NoFloatingIpInterface: msg = _('l3driver call to add floating IP failed') raise webob.exc.HTTPBadRequest(explanation=msg) - except exception.InstanceUnknownCell as e: - raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.FloatingIpNotFoundForAddress: msg = _('floating IP not found') raise webob.exc.HTTPNotFound(explanation=msg) diff --git a/nova/api/openstack/compute/migrate_server.py b/nova/api/openstack/compute/migrate_server.py index 2aeb03810b49..1e149836cda9 100644 --- a/nova/api/openstack/compute/migrate_server.py +++ b/nova/api/openstack/compute/migrate_server.py @@ -139,8 +139,6 @@ class MigrateServerController(wsgi.Controller): self.compute_api.live_migrate(context, instance, block_migration, disk_over_commit, host, force, async_) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except (exception.NoValidHost, exception.ComputeServiceUnavailable, exception.InvalidHypervisorType, diff --git a/nova/api/openstack/compute/multinic.py b/nova/api/openstack/compute/multinic.py index e554192ed30d..4c01d96e4947 100644 --- a/nova/api/openstack/compute/multinic.py +++ b/nova/api/openstack/compute/multinic.py @@ -47,8 +47,6 @@ class MultinicController(wsgi.Controller): network_id = body['addFixedIp']['networkId'] try: self.compute_api.add_fixed_ip(context, instance, network_id) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.NoMoreFixedIps as e: raise exc.HTTPBadRequest(explanation=e.format_message()) @@ -67,7 +65,5 @@ class MultinicController(wsgi.Controller): try: self.compute_api.remove_fixed_ip(context, instance, address) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.FixedIpNotFoundForSpecificInstance as e: raise exc.HTTPBadRequest(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/pause_server.py b/nova/api/openstack/compute/pause_server.py index ee6852e02bfa..35238f9f7ca4 100644 --- a/nova/api/openstack/compute/pause_server.py +++ b/nova/api/openstack/compute/pause_server.py @@ -44,8 +44,7 @@ class PauseServerController(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'pause', id) - except (exception.InstanceUnknownCell, - exception.InstanceNotFound) as e: + except exception.InstanceNotFound as e: raise exc.HTTPNotFound(explanation=e.format_message()) except NotImplementedError: common.raise_feature_not_supported() @@ -65,8 +64,7 @@ class PauseServerController(wsgi.Controller): except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'unpause', id) - except (exception.InstanceUnknownCell, - exception.InstanceNotFound) as e: + except exception.InstanceNotFound as e: raise exc.HTTPNotFound(explanation=e.format_message()) except NotImplementedError: common.raise_feature_not_supported() diff --git a/nova/api/openstack/compute/remote_consoles.py b/nova/api/openstack/compute/remote_consoles.py index 625a8083d6ef..342f6f7f6373 100644 --- a/nova/api/openstack/compute/remote_consoles.py +++ b/nova/api/openstack/compute/remote_consoles.py @@ -52,8 +52,7 @@ class RemoteConsolesController(wsgi.Controller): console_type) except exception.ConsoleTypeUnavailable as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) - except (exception.InstanceUnknownCell, - exception.InstanceNotFound) as e: + except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @@ -81,8 +80,7 @@ class RemoteConsolesController(wsgi.Controller): console_type) except exception.ConsoleTypeUnavailable as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) - except (exception.InstanceUnknownCell, - exception.InstanceNotFound) as e: + except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @@ -112,8 +110,7 @@ class RemoteConsolesController(wsgi.Controller): console_type) except exception.ConsoleTypeUnavailable as e: raise webob.exc.HTTPBadRequest(explanation=e.format_message()) - except (exception.InstanceUnknownCell, - exception.InstanceNotFound) as e: + except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) @@ -138,8 +135,7 @@ class RemoteConsolesController(wsgi.Controller): output = self.compute_api.get_serial_console(context, instance, console_type) - except (exception.InstanceUnknownCell, - exception.InstanceNotFound) as e: + except exception.InstanceNotFound as e: raise webob.exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceNotReady as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) diff --git a/nova/api/openstack/compute/rescue.py b/nova/api/openstack/compute/rescue.py index d1f64953e728..93d0a756ec8c 100644 --- a/nova/api/openstack/compute/rescue.py +++ b/nova/api/openstack/compute/rescue.py @@ -61,8 +61,6 @@ class RescueController(wsgi.Controller): self.compute_api.rescue(context, instance, rescue_password=password, rescue_image_ref=rescue_image_ref) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -89,8 +87,6 @@ class RescueController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.unrescue(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/server_metadata.py b/nova/api/openstack/compute/server_metadata.py index b0b0fbf77316..f042623a6acf 100644 --- a/nova/api/openstack/compute/server_metadata.py +++ b/nova/api/openstack/compute/server_metadata.py @@ -108,16 +108,10 @@ class ServerMetadataController(wsgi.Controller): server, metadata, delete) - - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) - except exception.QuotaError as error: raise exc.HTTPForbidden(explanation=error.format_message()) - except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) - except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'update metadata', server_id) @@ -150,13 +144,8 @@ class ServerMetadataController(wsgi.Controller): server = common.get_instance(self.compute_api, context, server_id) try: self.compute_api.delete_instance_metadata(context, server, id) - - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) - except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) - except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'delete metadata', server_id) diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 7856839b8cb8..30158dcf0208 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -852,8 +852,6 @@ class ServersController(wsgi.Controller): instance = self._get_server(context, req, id) try: self.compute_api.confirm_resize(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.MigrationNotFound: msg = _("Instance has not been resized.") raise exc.HTTPBadRequest(explanation=msg) @@ -872,8 +870,6 @@ class ServersController(wsgi.Controller): instance = self._get_server(context, req, id) try: self.compute_api.revert_resize(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.MigrationNotFound: msg = _("Instance has not been resized.") raise exc.HTTPBadRequest(explanation=msg) @@ -927,8 +923,6 @@ class ServersController(wsgi.Controller): try: self.compute_api.resize(context, instance, flavor_id, **kwargs) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.QuotaError as error: raise exc.HTTPForbidden( explanation=error.format_message()) @@ -967,8 +961,6 @@ class ServersController(wsgi.Controller): except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except (exception.InstanceIsLocked, exception.AllocationDeleteFailed) as e: raise exc.HTTPConflict(explanation=e.format_message()) @@ -1093,8 +1085,6 @@ class ServersController(wsgi.Controller): except exception.InstanceNotFound: msg = _("Instance could not be found") raise exc.HTTPNotFound(explanation=msg) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.ImageNotFound: msg = _("Cannot find image for rebuild") raise exc.HTTPBadRequest(explanation=msg) @@ -1188,8 +1178,6 @@ class ServersController(wsgi.Controller): instance, image_name, extra_properties=metadata) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'createImage', id) @@ -1262,8 +1250,6 @@ class ServersController(wsgi.Controller): self.compute_api.start(context, instance) except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'start', id) @@ -1282,8 +1268,6 @@ class ServersController(wsgi.Controller): self.compute_api.stop(context, instance) except (exception.InstanceNotReady, exception.InstanceIsLocked) as e: raise webob.exc.HTTPConflict(explanation=e.format_message()) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, 'stop', id) diff --git a/nova/api/openstack/compute/shelve.py b/nova/api/openstack/compute/shelve.py index a606cdda9d04..ba17ff0a3fe2 100644 --- a/nova/api/openstack/compute/shelve.py +++ b/nova/api/openstack/compute/shelve.py @@ -45,8 +45,6 @@ class ShelveController(wsgi.Controller): 'project_id': instance.project_id}) try: self.compute_api.shelve(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -64,8 +62,6 @@ class ShelveController(wsgi.Controller): instance = common.get_instance(self.compute_api, context, id) try: self.compute_api.shelve_offload(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -98,8 +94,6 @@ class ShelveController(wsgi.Controller): try: self.compute_api.unshelve(context, instance) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/suspend_server.py b/nova/api/openstack/compute/suspend_server.py index 61f89d35dd9f..269f2afa5146 100644 --- a/nova/api/openstack/compute/suspend_server.py +++ b/nova/api/openstack/compute/suspend_server.py @@ -38,8 +38,6 @@ class SuspendServerController(wsgi.Controller): target={'user_id': server.user_id, 'project_id': server.project_id}) self.compute_api.suspend(context, server) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: @@ -56,8 +54,6 @@ class SuspendServerController(wsgi.Controller): server = common.get_instance(self.compute_api, context, id) try: self.compute_api.resume(context, server) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InstanceIsLocked as e: raise exc.HTTPConflict(explanation=e.format_message()) except exception.InstanceInvalidState as state_error: diff --git a/nova/api/openstack/compute/volumes.py b/nova/api/openstack/compute/volumes.py index b01fb50b3b9c..cad3b4456f81 100644 --- a/nova/api/openstack/compute/volumes.py +++ b/nova/api/openstack/compute/volumes.py @@ -335,8 +335,7 @@ class VolumeAttachmentController(wsgi.Controller): device = self.compute_api.attach_volume( context, instance, volume_id, device, tag=tag, supports_multiattach=supports_multiattach) - except (exception.InstanceUnknownCell, - exception.VolumeNotFound) as e: + except exception.VolumeNotFound as e: raise exc.HTTPNotFound(explanation=e.format_message()) except (exception.InstanceIsLocked, exception.DevicePathInUse, @@ -448,8 +447,6 @@ class VolumeAttachmentController(wsgi.Controller): self.compute_api.detach_volume(context, instance, volume) except exception.InvalidVolume as e: raise exc.HTTPBadRequest(explanation=e.format_message()) - except exception.InstanceUnknownCell as e: - raise exc.HTTPNotFound(explanation=e.format_message()) except exception.InvalidInput as e: raise exc.HTTPBadRequest(explanation=e.format_message()) except exception.InstanceIsLocked as e: diff --git a/nova/tests/unit/api/openstack/compute/test_deferred_delete.py b/nova/tests/unit/api/openstack/compute/test_deferred_delete.py index 5e1e401ec139..9cff6a438412 100644 --- a/nova/tests/unit/api/openstack/compute/test_deferred_delete.py +++ b/nova/tests/unit/api/openstack/compute/test_deferred_delete.py @@ -104,19 +104,6 @@ class DeferredDeleteExtensionTestV21(test.NoDBTestCase): self.assertIn('Instance fake_uuid could not be found', ex.explanation) - @mock.patch.object(compute_api.API, 'get') - @mock.patch.object(compute_api.API, 'force_delete', - side_effect=exception.InstanceUnknownCell( - instance_uuid='fake_uuid')) - def test_force_delete_instance_cellunknown(self, mock_force_delete, - mock_get): - req = fakes.HTTPRequest.blank('/v2/fake/servers/fake_uuid/action') - ex = self.assertRaises(webob.exc.HTTPNotFound, - self.extension._force_delete, - req, 'fake_uuid', '') - self.assertIn('Cell is not known for instance fake_uuid', - ex.explanation) - @mock.patch.object(compute_api.API, 'get') @mock.patch.object(compute_api.API, 'restore') def test_restore(self, mock_restore, mock_get):