Have one list of reboot task_states
We now have two places we list valid task_states for a soft reboot. Let's just have one. Do a similar thing to hard reboot states at the time to be consistent. Change-Id: I87932894b3b7b2b5cc86552e322611e5701297da
This commit is contained in:
parent
91addc87c6
commit
8fc69b76ce
@ -860,10 +860,8 @@ class ComputeManager(manager.Manager):
|
||||
# again, then we've just become a hard reboot. That means the
|
||||
# task state for the instance needs to change so that we're in one
|
||||
# of the expected task states for a hard reboot.
|
||||
soft_types = [task_states.REBOOT_STARTED,
|
||||
task_states.REBOOT_PENDING,
|
||||
task_states.REBOOTING]
|
||||
if instance.task_state in soft_types and reboot_type == 'HARD':
|
||||
if (instance.task_state in task_states.soft_reboot_states and
|
||||
reboot_type == 'HARD'):
|
||||
instance.task_state = task_states.REBOOT_PENDING_HARD
|
||||
instance.save()
|
||||
|
||||
@ -3017,14 +3015,11 @@ class ComputeManager(manager.Manager):
|
||||
# acknowledge the request made it to the manager
|
||||
if reboot_type == "SOFT":
|
||||
instance.task_state = task_states.REBOOT_PENDING
|
||||
expected_states = (task_states.REBOOTING,
|
||||
task_states.REBOOT_PENDING,
|
||||
task_states.REBOOT_STARTED)
|
||||
expected_states = task_states.soft_reboot_states
|
||||
else:
|
||||
instance.task_state = task_states.REBOOT_PENDING_HARD
|
||||
expected_states = (task_states.REBOOTING_HARD,
|
||||
task_states.REBOOT_PENDING_HARD,
|
||||
task_states.REBOOT_STARTED_HARD)
|
||||
expected_states = task_states.hard_reboot_states
|
||||
|
||||
context = context.elevated()
|
||||
LOG.info("Rebooting instance", instance=instance)
|
||||
|
||||
|
@ -119,3 +119,7 @@ UNSHELVING = fields.InstanceTaskState.UNSHELVING
|
||||
|
||||
ALLOW_REBOOT = [None, REBOOTING, REBOOT_PENDING, REBOOT_STARTED, RESUMING,
|
||||
REBOOTING_HARD, UNPAUSING, PAUSING, SUSPENDING]
|
||||
|
||||
# These states indicate a reboot
|
||||
soft_reboot_states = (REBOOTING, REBOOT_PENDING, REBOOT_STARTED)
|
||||
hard_reboot_states = (REBOOTING_HARD, REBOOT_PENDING_HARD, REBOOT_STARTED_HARD)
|
||||
|
@ -601,10 +601,9 @@ def get_reboot_type(task_state, current_power_state):
|
||||
"""Checks if the current instance state requires a HARD reboot."""
|
||||
if current_power_state != power_state.RUNNING:
|
||||
return 'HARD'
|
||||
soft_types = [task_states.REBOOT_STARTED, task_states.REBOOT_PENDING,
|
||||
task_states.REBOOTING]
|
||||
reboot_type = 'SOFT' if task_state in soft_types else 'HARD'
|
||||
return reboot_type
|
||||
if task_state in task_states.soft_reboot_states:
|
||||
return 'SOFT'
|
||||
return 'HARD'
|
||||
|
||||
|
||||
def get_machine_ips():
|
||||
|
Loading…
x
Reference in New Issue
Block a user