From 9eb3dc7ed44d99652a17238724842e3067d46120 Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Mon, 29 Apr 2013 23:17:41 +0200 Subject: Reset migrating task state for MigrationError exceptions Create an exception type for pre-check errors and add it to the list of exceptions for which instance task state is reset to ACTIVE to avoid cases where an instance get stuck in MIGRATING state. Convert existing instances of raise MigrationError in scheduler and driver pre-checks to have them raise the new MigrationPreCheckError exception instead. In addition, also make sure that expected exceptions are passed over RPC silently. Resolves bug 1171526. Change-Id: I00fa0962e555f895dd98861684ec7767fed3b37b --- nova/virt/libvirt/driver.py | 2 +- nova/virt/xenapi/vmops.py | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index dc0af8539..c365c5fdd 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2968,7 +2968,7 @@ class LibvirtDriver(driver.ComputeDriver): "Disk of instance is too large(available" " on destination host:%(available)s " "< need:%(necessary)s)") - raise exception.MigrationError(reason=reason % locals()) + raise exception.MigrationPreCheckError(reason=reason % locals()) def _compare_cpu(self, cpu_info): """Checks the host cpu is compatible to a cpu given by xml. diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 48413ed7c..e7dd3cff0 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -1625,7 +1625,7 @@ class VMOps(object): except KeyError: reason = _('Destination host:%(hostname)s must be in the same ' 'aggregate as the source server') - raise exception.MigrationError(reason=reason % locals()) + raise exception.MigrationPreCheckError(reason=reason % locals()) def _ensure_host_in_aggregate(self, context, hostname): self._get_host_uuid_from_aggregate(context, hostname) @@ -1644,7 +1644,8 @@ class VMOps(object): pifs = self._session.call_xenapi('PIF.get_all_records_where', expr) if len(pifs) != 1: - raise exception.MigrationError('No suitable network for migrate') + msg = _('No suitable network for migrate') + raise exception.MigrationPreCheckError(reason=msg) nwref = pifs[pifs.keys()[0]]['network'] try: @@ -1655,7 +1656,8 @@ class VMOps(object): options) except self._session.XenAPI.Failure as exc: LOG.exception(exc) - raise exception.MigrationError(_('Migrate Receive failed')) + msg = _('Migrate Receive failed') + raise exception.MigrationPreCheckError(reason=msg) return migrate_data def check_can_live_migrate_destination(self, ctxt, instance_ref, @@ -1703,8 +1705,8 @@ class VMOps(object): "VM.assert_can_migrate", vm_ref, migrate_data) except self._session.XenAPI.Failure as exc: LOG.exception(exc) - raise exception.MigrationError(_('VM.assert_can_migrate' - 'failed')) + msg = _('VM.assert_can_migrate failed') + raise exception.MigrationPreCheckError(reason=msg) return dest_check_data def _generate_vdi_map(self, destination_sr_ref, vm_ref): -- cgit