Comment 32 for bug 1821594

Reviewed: https://review.opendev.org/661349
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=5600309a1fc38f0f98629608d3f41eacf66d714a
Submitter: Zuul
Branch: stable/queens

commit 5600309a1fc38f0f98629608d3f41eacf66d714a
Author: Matt Riedemann <email address hidden>
Date: Wed May 15 12:27:17 2019 -0400

    [stable-only] Delete allocations even if _confirm_resize raises (part 2)

    The backport https://review.opendev.org/#/c/652153/ to fix
    bug 1821594 did not account for how the _delete_allocation_after_move
    method before Stein is tightly coupled to the migration status
    being set to "confirmed" which is what the _confirm_resize method
    does after self.driver.confirm_migration returns.

    However, if self.driver.confirm_migration raises an exception
    we still want to cleanup the allocations held on the source node
    and for that we call _delete_allocation_after_move. But because
    of that tight coupling before Stein, we need to temporarily
    mutate the migration status to "confirmed" to get the cleanup
    method to do what we want.

    This isn't a problem starting in Stein because change
    I0851e2d54a1fdc82fe3291fb7e286e790f121e92 removed that
    tight coupling on the migration status, so this is a stable
    branch only change.

    Note that we don't call self.reportclient.delete_allocation_for_instance
    directly since before Stein we still need to account for a
    migration that does not move the source node allocations to the
    migration record, and that logic is in _delete_allocation_after_move.

    A simple unit test assertion is added here but the functional
    test added in change I9d6478f492351b58aa87b8f56e907ee633d6d1c6
    will assert the bug is fixed properly before Stein.

    Change-Id: I933687891abef4878de09481937d576ce5899511
    Closes-Bug: #1821594
    (cherry picked from commit dac3239e92fc1865cacc17bbfbd2316072a9d26e)