Merge "Keep resizing&resized instances when compute init"
This commit is contained in:
@@ -684,21 +684,28 @@ class ComputeManager(manager.Manager):
|
|||||||
evacuated to another host. Check that the instances reported
|
evacuated to another host. Check that the instances reported
|
||||||
by the driver are still associated with this host. If they are
|
by the driver are still associated with this host. If they are
|
||||||
not, destroy them, with the exception of instances which are in
|
not, destroy them, with the exception of instances which are in
|
||||||
the MIGRATING state.
|
the MIGRATING, RESIZE_MIGRATING, RESIZE_MIGRATED, RESIZE_FINISH
|
||||||
|
task state or RESIZED vm state.
|
||||||
"""
|
"""
|
||||||
our_host = self.host
|
our_host = self.host
|
||||||
filters = {'deleted': False}
|
filters = {'deleted': False}
|
||||||
local_instances = self._get_instances_on_driver(context, filters)
|
local_instances = self._get_instances_on_driver(context, filters)
|
||||||
for instance in local_instances:
|
for instance in local_instances:
|
||||||
if instance.host != our_host:
|
if instance.host != our_host:
|
||||||
if instance.task_state in [task_states.MIGRATING]:
|
if (instance.task_state in [task_states.MIGRATING,
|
||||||
|
task_states.RESIZE_MIGRATING,
|
||||||
|
task_states.RESIZE_MIGRATED,
|
||||||
|
task_states.RESIZE_FINISH]
|
||||||
|
or instance.vm_state in [vm_states.RESIZED]):
|
||||||
LOG.debug('Will not delete instance as its host ('
|
LOG.debug('Will not delete instance as its host ('
|
||||||
'%(instance_host)s) is not equal to our '
|
'%(instance_host)s) is not equal to our '
|
||||||
'host (%(our_host)s) but its state is '
|
'host (%(our_host)s) but its task state is '
|
||||||
'(%(task_state)s)',
|
'(%(task_state)s) and vm state is '
|
||||||
|
'(%(vm_state)s)',
|
||||||
{'instance_host': instance.host,
|
{'instance_host': instance.host,
|
||||||
'our_host': our_host,
|
'our_host': our_host,
|
||||||
'task_state': instance.task_state},
|
'task_state': instance.task_state,
|
||||||
|
'vm_state': instance.vm_state},
|
||||||
instance=instance)
|
instance=instance)
|
||||||
continue
|
continue
|
||||||
LOG.info(_('Deleting instance as its host ('
|
LOG.info(_('Deleting instance as its host ('
|
||||||
|
|||||||
@@ -1551,15 +1551,18 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||||||
self._do_test_set_admin_password_driver_error(
|
self._do_test_set_admin_password_driver_error(
|
||||||
exc, vm_states.ACTIVE, None, expected_exception)
|
exc, vm_states.ACTIVE, None, expected_exception)
|
||||||
|
|
||||||
def test_init_host_with_partial_migration(self):
|
def _test_init_host_with_partial_migration(self, task_state=None,
|
||||||
|
vm_state=vm_states.ACTIVE):
|
||||||
our_host = self.compute.host
|
our_host = self.compute.host
|
||||||
instance_1 = objects.Instance(self.context)
|
instance_1 = objects.Instance(self.context)
|
||||||
instance_1.uuid = 'foo'
|
instance_1.uuid = 'foo'
|
||||||
instance_1.task_state = task_states.MIGRATING
|
instance_1.task_state = task_state
|
||||||
|
instance_1.vm_state = vm_state
|
||||||
instance_1.host = 'not-' + our_host
|
instance_1.host = 'not-' + our_host
|
||||||
instance_2 = objects.Instance(self.context)
|
instance_2 = objects.Instance(self.context)
|
||||||
instance_2.uuid = 'bar'
|
instance_2.uuid = 'bar'
|
||||||
instance_2.task_state = None
|
instance_2.task_state = None
|
||||||
|
instance_2.vm_state = vm_states.ACTIVE
|
||||||
instance_2.host = 'not-' + our_host
|
instance_2.host = 'not-' + our_host
|
||||||
|
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
@@ -1580,6 +1583,26 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||||||
destroy.assert_called_once_with(self.context, instance_2, None,
|
destroy.assert_called_once_with(self.context, instance_2, None,
|
||||||
{}, True)
|
{}, True)
|
||||||
|
|
||||||
|
def test_init_host_with_partial_migration_migrating(self):
|
||||||
|
self._test_init_host_with_partial_migration(
|
||||||
|
task_state=task_states.MIGRATING)
|
||||||
|
|
||||||
|
def test_init_host_with_partial_migration_resize_migrating(self):
|
||||||
|
self._test_init_host_with_partial_migration(
|
||||||
|
task_state=task_states.RESIZE_MIGRATING)
|
||||||
|
|
||||||
|
def test_init_host_with_partial_migration_resize_migrated(self):
|
||||||
|
self._test_init_host_with_partial_migration(
|
||||||
|
task_state=task_states.RESIZE_MIGRATED)
|
||||||
|
|
||||||
|
def test_init_host_with_partial_migration_finish_resize(self):
|
||||||
|
self._test_init_host_with_partial_migration(
|
||||||
|
task_state=task_states.RESIZE_FINISH)
|
||||||
|
|
||||||
|
def test_init_host_with_partial_migration_resized(self):
|
||||||
|
self._test_init_host_with_partial_migration(
|
||||||
|
vm_state=vm_states.RESIZED)
|
||||||
|
|
||||||
@mock.patch('nova.compute.manager.ComputeManager._instance_update')
|
@mock.patch('nova.compute.manager.ComputeManager._instance_update')
|
||||||
def test_error_out_instance_on_exception_not_implemented_err(self,
|
def test_error_out_instance_on_exception_not_implemented_err(self,
|
||||||
inst_update_mock):
|
inst_update_mock):
|
||||||
|
|||||||
Reference in New Issue
Block a user