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
(cherry picked from commit 5b785569b6)
This commit is contained in:
Julia Kreger 2020-06-03 10:24:43 -07:00 committed by Dmitry Tantsur
parent 475682f9b9
commit 9f9a9abfbd
3 changed files with 17 additions and 4 deletions

View File

@ -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:

View File

@ -888,8 +888,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
@ -917,8 +918,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):

View File

@ -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.