This change adds the synchronized decorator to the stop function and
_sync_instance_power_state to address a race condition when powering
off and updating the database for an instance. The power off and
database update should be protected so the periodic task sees a
consistent view when it checks power state from the driver and
VM state from the database in order to take action.
In the bug, a stopped instance is in the middle of being rebuilt,
and while it is in the process of being returned to the original
STOPPED state, _sync_power_states sees the combination of the
power state from the driver being 'on' and the vm_state from
the database as being STOPPED. This patch aims to ensure power
'off' and vm_state set to STOPPED happen atomically in the
stop_instance function. Thus, the read by _sync_power_states
must also be synced on the instance UUID.
Reviewed: https:/ /review. openstack. org/103174 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=cc5388bbe81 aba635fb757e202 d860aeed98f3e8
Committed: https:/
Submitter: Jenkins
Branch: master
commit cc5388bbe81aba6 35fb757e202d860 aeed98f3e8
Author: melanie witt <email address hidden>
Date: Fri Jun 27 15:45:15 2014 +0000
synchronize 'stop' and power state periodic task
This change adds the synchronized decorator to the stop function and instance_ power_state to address a race condition when powering
_sync_
off and updating the database for an instance. The power off and
database update should be protected so the periodic task sees a
consistent view when it checks power state from the driver and
VM state from the database in order to take action.
In the bug, a stopped instance is in the middle of being rebuilt,
and while it is in the process of being returned to the original
STOPPED state, _sync_power_states sees the combination of the
power state from the driver being 'on' and the vm_state from
the database as being STOPPED. This patch aims to ensure power
'off' and vm_state set to STOPPED happen atomically in the
stop_instance function. Thus, the read by _sync_power_states
must also be synced on the instance UUID.
Change-Id: I8aa83ab8dca358 78cf792ae2d46fe aa9912ffd38
Closes-Bug: #1320628