Raise specific exception when swapping migration allocations fails
If we fail to find resource allocations for an instance on the source compute node when swapping allocations for a cold migrate / resize operation, we need to raise a specific exception which will eventually be a 500 internal error from the REST API. Using InstanceUnacceptable is incorrect since it extends Invalid which is handled in the resize REST API controller code and returned as a 400 bad request with the message "Instance image invalid" which is not at all the actual failure. As for the actual reason why the instance allocation on the source node is not found, that is a different bug. Change-Id: Id8e2dcf21776f8237a8b63acb23787bb42c9bd13 Closes-Bug: #1729356
This commit is contained in:
parent
f974e3c356
commit
59d42e4c42
|
@ -251,7 +251,7 @@ class ComputeTaskManager(base.Base):
|
|||
exception.MigrationPreCheckError,
|
||||
exception.MigrationPreCheckClientException,
|
||||
exception.LiveMigrationWithOldNovaNotSupported,
|
||||
exception.InstanceUnacceptable,
|
||||
exception.ConsumerAllocationNotFound,
|
||||
exception.UnsupportedPolicyException)
|
||||
@targets_cell
|
||||
@wrap_instance_event(prefix='conductor')
|
||||
|
|
|
@ -47,13 +47,11 @@ def replace_allocation_with_migration(context, instance, migration):
|
|||
orig_alloc = reportclient.get_allocations_for_consumer_by_provider(
|
||||
source_cn.uuid, instance.uuid)
|
||||
if not orig_alloc:
|
||||
LOG.error('Unable to find existing allocations for instance',
|
||||
LOG.error('Unable to find existing allocations for instance on '
|
||||
'source compute node: %s', source_cn.uuid,
|
||||
instance=instance)
|
||||
# A generic error like this will just error out the migration
|
||||
# and do any rollback required
|
||||
raise exception.InstanceUnacceptable(
|
||||
instance_id=instance.uuid,
|
||||
reason=_('Instance has no source node allocation'))
|
||||
raise exception.ConsumerAllocationNotFound(
|
||||
consumer_id=instance.uuid, provider_uuid=source_cn.uuid)
|
||||
|
||||
# FIXME(danms): Since we don't have an atomic operation to adjust
|
||||
# allocations for multiple consumers, we have to have space on the
|
||||
|
|
|
@ -2128,6 +2128,13 @@ class InvalidAllocationConstraintsViolated(InvalidInventory):
|
|||
"amount would violate inventory constraints.")
|
||||
|
||||
|
||||
class ConsumerAllocationNotFound(NovaException):
|
||||
# This is intentionally not extending NotFound because if this
|
||||
# leaks to the REST API it should be considered a 500 internal error.
|
||||
msg_fmt = _('Consumer %(consumer_id)s has no resource allocation '
|
||||
'on provider %(provider_uuid)s.')
|
||||
|
||||
|
||||
class UnsupportedPointerModelRequested(Invalid):
|
||||
msg_fmt = _("Pointer model '%(model)s' requested is not supported by "
|
||||
"host.")
|
||||
|
|
|
@ -210,7 +210,7 @@ class MigrationTaskAllocationUtils(test.NoDBTestCase):
|
|||
instance = objects.Instance(uuid=uuids.instance,
|
||||
host='host', node='node')
|
||||
|
||||
self.assertRaises(exception.InstanceUnacceptable,
|
||||
self.assertRaises(exception.ConsumerAllocationNotFound,
|
||||
migrate.replace_allocation_with_migration,
|
||||
mock.sentinel.context,
|
||||
instance, migration)
|
||||
|
|
Loading…
Reference in New Issue