Merge "Ignore fake nodes in the power sync loop"

This commit is contained in:
Zuul 2022-03-09 15:50:41 +00:00 committed by Gerrit Code Review
commit e3221673ee
2 changed files with 13 additions and 2 deletions

View File

@ -3653,7 +3653,8 @@ def do_sync_power_state(task, count):
# Also make sure to cache the current boot_mode and secure_boot states
utils.node_cache_boot_mode(task)
if node.power_state and node.power_state == power_state:
if ((node.power_state and node.power_state == power_state)
or (node.power_state is None and power_state is None)):
# No action is needed
return 0
@ -3663,7 +3664,8 @@ def do_sync_power_state(task, count):
node = task.node
# Repeat all checks with exclusive lock to avoid races
if node.power_state and node.power_state == power_state:
if ((node.power_state and node.power_state == power_state)
or (node.power_state is None and power_state is None)):
# Node power state was updated to the correct value
return 0
elif node.provision_state in SYNC_EXCLUDED_STATES or node.maintenance:

View File

@ -4992,6 +4992,15 @@ class ManagerDoSyncPowerStateTestCase(db_base.DbTestCase):
self.assertFalse(node_power_action.called)
self.assertFalse(self.task.upgrade_lock.called)
def test_state_unchanged_for_fake_node(self, node_power_action):
self._do_sync_power_state(None, None)
self.power.validate.assert_called_once_with(self.task)
self.power.get_power_state.assert_called_once_with(self.task)
self.assertIsNone(self.node.power_state)
self.assertFalse(node_power_action.called)
self.assertFalse(self.task.upgrade_lock.called)
@mock.patch.object(nova, 'power_update', autospec=True)
def test_state_not_set(self, mock_power_update, node_power_action):
self._do_sync_power_state(None, states.POWER_ON)