Revert "Optimize _cleanup_incomplete_migrations periodic task"
The change modified instance filtering condition, which filters all deleted instances on current host, which is not as expected by periodic task. The periodic task expects instances, whose instance uuid are associated with migration record. And after filtering we only need to apply the instance deletion logic on instance files where instance.host is not set as current host (CONF.host). This reverts commit099cf53925
. Change-Id: Ic71c939bef86f1e5cb485c6827c69c3d638f2e89 Closes-Bug: 1589821 (cherry picked from commitadcc0e418b
)
This commit is contained in:
parent
5d36cc3669
commit
f77af87cc3
|
@ -6793,28 +6793,29 @@ class ComputeManager(manager.Manager):
|
|||
in migrations])
|
||||
|
||||
inst_filters = {'deleted': True, 'soft_deleted': False,
|
||||
'uuid': inst_uuid_from_migrations, 'host': CONF.host}
|
||||
'uuid': inst_uuid_from_migrations}
|
||||
attrs = ['info_cache', 'security_groups', 'system_metadata']
|
||||
with utils.temporary_mutation(context, read_deleted='yes'):
|
||||
instances = objects.InstanceList.get_by_filters(
|
||||
context, inst_filters, expected_attrs=attrs, use_slave=True)
|
||||
|
||||
for instance in instances:
|
||||
for migration in migrations:
|
||||
if instance.uuid == migration.instance_uuid:
|
||||
# Delete instance files if not cleanup properly either
|
||||
# from the source or destination compute nodes when
|
||||
# the instance is deleted during resizing.
|
||||
self.driver.delete_instance_files(instance)
|
||||
try:
|
||||
migration.status = 'failed'
|
||||
with migration.obj_as_admin():
|
||||
migration.save()
|
||||
except exception.MigrationNotFound:
|
||||
LOG.warning(_LW("Migration %s is not found."),
|
||||
migration.id, context=context,
|
||||
instance=instance)
|
||||
break
|
||||
if instance.host != CONF.host:
|
||||
for migration in migrations:
|
||||
if instance.uuid == migration.instance_uuid:
|
||||
# Delete instance files if not cleanup properly either
|
||||
# from the source or destination compute nodes when
|
||||
# the instance is deleted during resizing.
|
||||
self.driver.delete_instance_files(instance)
|
||||
try:
|
||||
migration.status = 'failed'
|
||||
with migration.obj_as_admin():
|
||||
migration.save()
|
||||
except exception.MigrationNotFound:
|
||||
LOG.warning(_LW("Migration %s is not found."),
|
||||
migration.id, context=context,
|
||||
instance=instance)
|
||||
break
|
||||
|
||||
@messaging.expected_exceptions(exception.InstanceQuiesceNotSupported,
|
||||
exception.QemuGuestAgentNotEnabled,
|
||||
|
|
|
@ -1580,13 +1580,10 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
|||
# files deletion for those instances whose instance.host is not
|
||||
# same as compute host where periodic task is running.
|
||||
for inst in fake_instances:
|
||||
for mig in fake_migrations:
|
||||
if inst.uuid == mig.instance_uuid:
|
||||
self.assertEqual('failed', mig.status)
|
||||
|
||||
# Make sure we filtered the instances by host in the DB query.
|
||||
self.assertEqual(CONF.host,
|
||||
mock_inst_get_by_filters.call_args[0][1]['host'])
|
||||
if inst.host != CONF.host:
|
||||
for mig in fake_migrations:
|
||||
if inst.uuid == mig.instance_uuid:
|
||||
self.assertEqual('failed', mig.status)
|
||||
|
||||
def test_cleanup_incomplete_migrations_dest_node(self):
|
||||
"""Test to ensure instance files are deleted from destination node.
|
||||
|
|
Loading…
Reference in New Issue