It is possible to cold migrate a stopped server. If, however, the
cold migrate is scheduled to the instance's current host and the
compute driver does not support cold migrating to the same host,
then UnableToMigrateToSelf was being raised from _prep_resize. If
_reschedule_resize_or_reraise re-raises that exception, then
_error_out_instance_on_exception in prep_resize handles it and
sets the instance vm_state to ACTIVE. This is wrong since the
instance power state is unchanged at this point and the instance
is actually stopped.
This fixes the problem by wrapping UnableToMigrateToSelf in
InstanceFaultRollback and raises that from _prep_resize, and
_error_out_instance_on_exception is called with the initial
vm_state (STOPPED in this case) so when _error_out_instance_on_exception
handles the InstanceFaultRollback exception it sets the instance
vm_state to STOPPED (what it already was) rather than ACTIVE.
There were no existing unit tests for the UnableToMigrateToSelf
case in _prep_resize so those are added here.
Conflicts:
nova/tests/unit/compute/test_compute_mgr.py
NOTE(mriedem): The conflict is due to some unit tests from change
I734cc01dce13f9e75a16639faf890ddb1661b7eb not being in Stein.
Change-Id: I17543ecb572934ecc7d0bbc7a4ad2f537fa499bc
Closes-Bug: #1811235
(cherry picked from commit d1931ac063)