Reset power state upon adoption failure
When adoption fails, we should back out the power state so we don't accidently save a state that shouldn't be preserved due to the failure. Change-Id: I4647d0141fc639d49ccb0ef195577f18cd35bd30 Story: 2007901 Task: 40447
This commit is contained in:
parent
bc60f08a59
commit
44d66d351f
@ -1764,6 +1764,8 @@ class ConductorManager(base_manager.BaseConductorManager):
|
||||
msg = (_('Error while attempting to adopt node %(node)s: '
|
||||
'%(err)s.') % {'node': node.uuid, 'err': err})
|
||||
LOG.error(msg)
|
||||
# Wipe power state from being preserved as it is likely invalid.
|
||||
node.power_state = states.NOSTATE
|
||||
node.last_error = msg
|
||||
task.process_event('fail')
|
||||
|
||||
|
@ -7061,7 +7061,13 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||
self._start_service()
|
||||
node = obj_utils.create_test_node(
|
||||
self.context, driver='fake-hardware',
|
||||
provision_state=states.ADOPTING)
|
||||
provision_state=states.ADOPTING,
|
||||
power_state=states.POWER_ON)
|
||||
# NOTE(TheJulia): When nodes are created for adoption, they
|
||||
# would have no power state. Under normal circumstances
|
||||
# during validate the node object is updated with power state
|
||||
# however we need to make sure that we wipe preserved state
|
||||
# as part of failure handling.
|
||||
task = task_manager.TaskManager(self.context, node.uuid)
|
||||
|
||||
self.service._do_adoption(task)
|
||||
@ -7075,6 +7081,7 @@ class DoNodeAdoptionTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||
self.assertFalse(mock_start_console.called)
|
||||
self.assertTrue(mock_boot_validate.called)
|
||||
self.assertIn('is_whole_disk_image', task.node.driver_internal_info)
|
||||
self.assertEqual(states.NOSTATE, node.power_state)
|
||||
|
||||
@mock.patch('ironic.drivers.modules.fake.FakeBoot.validate', autospec=True)
|
||||
@mock.patch('ironic.drivers.modules.fake.FakeConsole.start_console',
|
||||
|
@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes the preservation of potentially incorrect power state
|
||||
information when adoption process fails. Power state is now
|
||||
wiped as part of the failure handling process instead of
|
||||
being preserved.
|
Loading…
Reference in New Issue
Block a user