From 5b785569b635a3d23509b009c4f575d1800c6f02 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Wed, 3 Jun 2020 10:24:43 -0700 Subject: [PATCH] Fix fast track when exiting cleaning When exiting cleaning, previously the agent token was purged from ironic's database and agents continuing to run would not be able to heartbeat to the conductor. With agent token, this would orphan the agent such that it thought it had an agent token, yet the conductor did not. Change-Id: Id6f8609bcda369649d0f677aceed26ed5e72a313 --- ironic/conductor/cleaning.py | 5 +++-- ironic/tests/unit/conductor/test_cleaning.py | 9 +++++++-- .../notes/fast-track-with-cleaning-438225116a11662d.yaml | 7 +++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fast-track-with-cleaning-438225116a11662d.yaml diff --git a/ironic/conductor/cleaning.py b/ironic/conductor/cleaning.py index 6a188c7a16..e02abdb36d 100644 --- a/ironic/conductor/cleaning.py +++ b/ironic/conductor/cleaning.py @@ -218,12 +218,13 @@ def do_next_clean_step(task, step_index): driver_internal_info.pop('clean_step_index', None) driver_internal_info.pop('cleaning_reboot', None) driver_internal_info.pop('cleaning_polling', None) - driver_internal_info.pop('agent_secret_token', None) - driver_internal_info.pop('agent_secret_token_pregenerated', None) # Remove agent_url if not utils.fast_track_able(task): driver_internal_info.pop('agent_url', None) + driver_internal_info.pop('agent_secret_token', None) + driver_internal_info.pop('agent_secret_token_pregenerated', None) + node.driver_internal_info = driver_internal_info node.save() try: diff --git a/ironic/tests/unit/conductor/test_cleaning.py b/ironic/tests/unit/conductor/test_cleaning.py index 7c3d8c4418..b6f67df922 100644 --- a/ironic/tests/unit/conductor/test_cleaning.py +++ b/ironic/tests/unit/conductor/test_cleaning.py @@ -889,8 +889,9 @@ class DoNodeCleanTestCase(db_base.DbTestCase): self.config(fast_track=True, group='deploy') for info in ({'clean_steps': None, 'clean_step_index': None, - 'agent_url': 'test-url'}, - {'clean_steps': None, 'agent_url': 'test-url'}): + 'agent_url': 'test-url', 'agent_secret_token': 'magic'}, + {'clean_steps': None, 'agent_url': 'test-url', + 'agent_secret_token': 'it_is_a_kind_of_magic'}): # Resume where there are no steps, should be a noop tgt_prov_state = states.MANAGEABLE if manual else states.AVAILABLE @@ -918,8 +919,12 @@ class DoNodeCleanTestCase(db_base.DbTestCase): if fast_track: self.assertEqual('test-url', node.driver_internal_info.get('agent_url')) + self.assertIsNotNone( + node.driver_internal_info.get('agent_secret_token')) else: self.assertNotIn('agent_url', node.driver_internal_info) + self.assertNotIn('agent_secret_token', + node.driver_internal_info) mock_execute.reset_mock() def test__do_next_clean_step_automated_no_steps(self): diff --git a/releasenotes/notes/fast-track-with-cleaning-438225116a11662d.yaml b/releasenotes/notes/fast-track-with-cleaning-438225116a11662d.yaml new file mode 100644 index 0000000000..803977a0fb --- /dev/null +++ b/releasenotes/notes/fast-track-with-cleaning-438225116a11662d.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes a bug in "fast track" where Ironic would delete the ``agent token`` + upon exiting cleaning steps. However, if we are in fast track mode, we can + preserve the token and continue operations with the agent as it is not + powered off during fast track operations.