Browse Source

Merge "Reset power state upon adoption failure"

changes/48/739448/13
Zuul 4 days ago
committed by Gerrit Code Review
parent
commit
888f766cee
3 changed files with 17 additions and 1 deletions
  1. +2
    -0
      ironic/conductor/manager.py
  2. +8
    -1
      ironic/tests/unit/conductor/test_manager.py
  3. +7
    -0
      releasenotes/notes/unsave-power-state-on-adopt-failed-09194c8269c779de.yaml

+ 2
- 0
ironic/conductor/manager.py View File

@@ -1770,6 +1770,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')



+ 8
- 1
ironic/tests/unit/conductor/test_manager.py View File

@@ -7090,7 +7090,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)
@@ -7104,6 +7110,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',


+ 7
- 0
releasenotes/notes/unsave-power-state-on-adopt-failed-09194c8269c779de.yaml View File

@@ -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…
Cancel
Save