'Delete instance files on failed resize/revert-resize operation
During resize/revert-resize operation, if that instance gets deleted
in-between then instance files might remain either on source or
destination compute node because of race condition.'

@periodic_task.periodic_task(spacing=CONF.instance_delete_interval)
def _cleanup_incomplete_migrations(self, context):

    LOG.debug('Cleaning    up    deleted    instances    with    incomplete    migration    ')
    migration_filters = {'host': CONF.host, 'status': 'error'}
    migrations = objects.MigrationList.get_by_filters(context, migration_filters)
    if (not migrations):
        return
    inst_uuid_from_migrations = set([migration.instance_uuid for migration in migrations])
    inst_filters = {'deleted': True, 'soft_deleted': False, '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:
        if (instance.host != CONF.host):
            for migration in migrations:
                if (instance.uuid == migration.instance_uuid):
                    self.driver.delete_instance_files(instance)
                    try:
                        migration.status = 'failed'
                        with migration.obj_as_admin():
                            migration.save()
                    except exception.MigrationNotFound:
                        LOG.warning('Migration    %s    is    not    found.', migration.id, instance=instance)
                    break
