diff options
author | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-07-08 14:03:36 +0200 |
---|---|---|
committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-07-15 10:54:31 +0200 |
commit | 2d4d375358c8eb923a0a3bcee211ac53b991e54b (patch) | |
tree | c81217398e3c4fdac2092676d05f942471626383 /ironic/conductor/utils.py | |
parent | 54ab27b0ee7be7f946b5f9cba784782abb91ead1 (diff) | |
download | ironic-2d4d375358c8eb923a0a3bcee211ac53b991e54b.tar.gz |
Wipe agent token during reboot or power off
Otherwise a reboot during fast-track will leave the newly booted
agent without an ability to request a token.
Change-Id: I963276efae5599bfed6cbb4df18e8dd3bd1b9839
Diffstat (limited to 'ironic/conductor/utils.py')
-rw-r--r-- | ironic/conductor/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ironic/conductor/utils.py b/ironic/conductor/utils.py index fac2f7f3e..60bc4a542 100644 --- a/ironic/conductor/utils.py +++ b/ironic/conductor/utils.py @@ -284,6 +284,13 @@ def node_power_action(task, new_state, timeout=None): driver_internal_info = node.driver_internal_info driver_internal_info['last_power_state_change'] = str( timeutils.utcnow().isoformat()) + # 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 not is_agent_token_pregenerated(node): + driver_internal_info.pop('agent_secret_token', False) node.driver_internal_info = driver_internal_info node.save() |