diff options
author | Zuul <zuul@review.opendev.org> | 2020-10-08 20:07:32 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2020-10-08 20:07:32 +0000 |
commit | 9b6e996d258d4420f6ae8353e7a75468e0e284ce (patch) | |
tree | cca0c57c2c65be3203a47d7439726f9cc5489e94 /ironic | |
parent | 8448d3909ca3588b617084a1a13ed3344679dfbe (diff) | |
parent | 3c4884903ddf72fc28648656b6532f6e3dfe9d30 (diff) | |
download | ironic-9b6e996d258d4420f6ae8353e7a75468e0e284ce.tar.gz |
Merge "Wiping agent tokens on reboot via API - take 2" into stable/victoria
Diffstat (limited to 'ironic')
-rw-r--r-- | ironic/conductor/utils.py | 4 | ||||
-rw-r--r-- | ironic/tests/unit/conductor/test_utils.py | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py index 473c3d478..a20431089 100644 --- a/ironic/conductor/utils.py +++ b/ironic/conductor/utils.py @@ -288,8 +288,8 @@ def node_power_action(task, new_state, timeout=None): # NOTE(dtantsur): wipe token on shutting down, otherwise a reboot in # fast-track (or an accidentally booted agent) will cause subsequent # actions to fail. - if target_state in (states.POWER_OFF, states.SOFT_POWER_OFF, - states.REBOOT, states.SOFT_REBOOT): + if new_state in (states.POWER_OFF, states.SOFT_POWER_OFF, + states.REBOOT, states.SOFT_REBOOT): wipe_internal_info_on_power_off(node) node.save() diff --git a/ironic/tests/unit/conductor/test_utils.py b/ironic/tests/unit/conductor/test_utils.py index a449bf8de..c096a5426 100644 --- a/ironic/tests/unit/conductor/test_utils.py +++ b/ironic/tests/unit/conductor/test_utils.py @@ -278,10 +278,13 @@ class NodePowerActionTestCase(db_base.DbTestCase): @mock.patch.object(fake.FakePower, 'get_power_state', autospec=True) def test_node_power_action_power_reboot(self, get_power_mock, reboot_mock): """Test for reboot a node.""" + dii = {'agent_secret_token': 'token', + 'agent_cached_deploy_steps': ['steps']} node = obj_utils.create_test_node(self.context, uuid=uuidutils.generate_uuid(), driver='fake-hardware', - power_state=states.POWER_ON) + power_state=states.POWER_ON, + driver_internal_info=dii) task = task_manager.TaskManager(self.context, node.uuid) conductor_utils.node_power_action(task, states.REBOOT) @@ -292,6 +295,7 @@ class NodePowerActionTestCase(db_base.DbTestCase): self.assertEqual(states.POWER_ON, node['power_state']) self.assertIsNone(node['target_power_state']) self.assertIsNone(node['last_error']) + self.assertNotIn('agent_secret_token', node['driver_internal_info']) @mock.patch.object(fake.FakePower, 'get_power_state', autospec=True) def test_node_power_action_invalid_state(self, get_power_mock): |