Revert "Power off before inspection"
This reverts commit 34b264ef08
.
Parial-Bug: #1897505
Change-Id: Ia0623e9183cd5c774397bf233b87dcc4d33c2566
This commit is contained in:
parent
34b264ef08
commit
b4f008f08e
@ -288,28 +288,3 @@ def lookup_node(macs=None, bmc_addresses=None, introspection_data=None,
|
||||
'node1': node, 'node2': node2})
|
||||
|
||||
return node or node2
|
||||
|
||||
|
||||
def _wait_for_power_state(node, state, ironic):
|
||||
timeout = CONF.power_timeout
|
||||
for count in openstack.utils.iterate_timeout(
|
||||
timeout,
|
||||
"Timed out waiting for node %(node)s to reach power "
|
||||
"state %(state)s." % {'node': node, 'state': state}):
|
||||
latest_node = ironic.get_node(node)
|
||||
if latest_node.power_state == state:
|
||||
return
|
||||
|
||||
|
||||
def set_power_state(node, state, ironic=None, wait=True):
|
||||
if ironic is None:
|
||||
ironic = get_client()
|
||||
|
||||
try:
|
||||
ironic.set_node_power_state(node, state)
|
||||
if wait:
|
||||
_wait_for_power_state(node, state, ironic)
|
||||
except os_exc.SDKException as exc:
|
||||
raise utils.Error(
|
||||
'Failed to set power state for node %(node)s '
|
||||
'Error: %(error)s' % {'node': node, 'error': exc})
|
||||
|
@ -101,9 +101,6 @@ _OPTS = [
|
||||
cfg.BoolOpt('standalone', default=True,
|
||||
help=_('Whether to run ironic-inspector as a standalone '
|
||||
'service. It\'s EXPERIMENTAL to set to False.')),
|
||||
cfg.IntOpt('power_timeout',
|
||||
default=60,
|
||||
help=_('Time in seconds to wait for a node to power-off.')),
|
||||
]
|
||||
|
||||
|
||||
|
@ -64,13 +64,12 @@ def introspect(node_id, manage_boot=True, token=None):
|
||||
|
||||
if manage_boot:
|
||||
try:
|
||||
utils.executor().submit(_do_introspect, node_info, ironic,
|
||||
ironic_node=node)
|
||||
utils.executor().submit(_do_introspect, node_info, ironic)
|
||||
except Exception as exc:
|
||||
msg = _('Failed to submit introspection job: %s')
|
||||
raise utils.Error(msg % exc, node_info=node)
|
||||
else:
|
||||
_do_introspect(node_info, ironic, ironic_node=node)
|
||||
_do_introspect(node_info, ironic)
|
||||
|
||||
|
||||
def _persistent_ramdisk_boot(node):
|
||||
@ -100,7 +99,7 @@ def _wait_for_turn(node_info):
|
||||
|
||||
@node_cache.release_lock
|
||||
@node_cache.fsm_transition(istate.Events.wait)
|
||||
def _do_introspect(node_info, ironic, ironic_node):
|
||||
def _do_introspect(node_info, ironic):
|
||||
node_info.acquire_lock()
|
||||
|
||||
# TODO(dtantsur): pagination
|
||||
@ -123,8 +122,6 @@ def _do_introspect(node_info, ironic, ironic_node):
|
||||
attrs, node_info=node_info)
|
||||
|
||||
if node_info.manage_boot:
|
||||
if ironic_node.power_state == 'power on':
|
||||
ir_utils.set_power_state(node_info.uuid, 'power off')
|
||||
try:
|
||||
ironic.set_node_boot_device(
|
||||
node_info.uuid, 'pxe',
|
||||
|
@ -273,32 +273,3 @@ class TestLookupNode(base.NodeTest):
|
||||
fields=['uuid', 'node_uuid']) for mac in self.macs
|
||||
])
|
||||
self.assertEqual(1, self.ironic.nodes.call_count)
|
||||
|
||||
|
||||
class TestSetPower(base.NodeTest):
|
||||
|
||||
@mock.patch.object(ir_utils, '_wait_for_power_state', autospec=True)
|
||||
def test_set_power_state(self, mock_wait):
|
||||
cli = mock.Mock()
|
||||
cli.set_node_power_state.return_value = None
|
||||
ir_utils.set_power_state('cat_node', 'meow', cli)
|
||||
mock_wait.assert_called_once_with('cat_node', 'meow', mock.ANY)
|
||||
cli.set_node_power_state.assert_called_once_with('cat_node', 'meow')
|
||||
|
||||
@mock.patch.object(ir_utils, '_wait_for_power_state', autospec=True)
|
||||
def test_set_power_state_nowait(self, mock_wait):
|
||||
cli = mock.Mock()
|
||||
cli.set_node_power_state.return_value = None
|
||||
ir_utils.set_power_state('cat_node', 'meow', cli, wait=False)
|
||||
mock_wait.assert_not_called()
|
||||
cli.set_node_power_state.assert_called_once_with('cat_node', 'meow')
|
||||
|
||||
def test__wait_for_power_state(self):
|
||||
cli = mock.Mock()
|
||||
purr_node = mock.Mock()
|
||||
purr_node.power_state = 'purring'
|
||||
meow_node = mock.Mock()
|
||||
meow_node.power_state = 'meow'
|
||||
cli.get_node.side_effect = iter([purr_node, meow_node])
|
||||
ir_utils._wait_for_power_state('cat', 'meow', cli)
|
||||
self.assertEqual(2, cli.get_node.call_count)
|
||||
|
@ -477,39 +477,6 @@ class TestIntrospect(BaseTest):
|
||||
self.assertFalse(cli.set_node_boot_device.called)
|
||||
self.assertFalse(cli.set_node_power_state.called)
|
||||
|
||||
@mock.patch.object(ir_utils, 'set_power_state', autospec=True)
|
||||
def test_ok_power_on(self, mock_set_power, client_mock, start_mock):
|
||||
cli = self._prepare(client_mock)
|
||||
new_node = self.node
|
||||
new_node.power_state = 'power on'
|
||||
cli.get_node.side_effect = iter([new_node,
|
||||
new_node,
|
||||
new_node,
|
||||
new_node,
|
||||
self.node])
|
||||
start_mock.return_value = self.node_info
|
||||
|
||||
introspect.introspect(self.node.uuid)
|
||||
|
||||
cli.get_node.assert_called_once_with(self.uuid)
|
||||
cli.validate_node.assert_called_once_with(self.uuid, required='power')
|
||||
|
||||
start_mock.assert_called_once_with(self.uuid,
|
||||
bmc_address=[self.bmc_address],
|
||||
manage_boot=True,
|
||||
ironic=cli)
|
||||
self.node_info.ports.assert_called_once_with()
|
||||
self.node_info.add_attribute.assert_called_once_with(
|
||||
'mac', self.macs)
|
||||
self.sync_filter_mock.assert_called_with(cli)
|
||||
cli.set_node_boot_device.assert_called_once_with(
|
||||
self.uuid, 'pxe', persistent=False)
|
||||
cli.set_node_power_state.assert_called_once_with(self.uuid,
|
||||
'rebooting')
|
||||
self.node_info.acquire_lock.assert_called_once_with()
|
||||
self.node_info.release_lock.assert_called_once_with()
|
||||
mock_set_power.assert_called_once_with(self.node.uuid, 'power off')
|
||||
|
||||
|
||||
@mock.patch.object(node_cache, 'get_node', autospec=True)
|
||||
@mock.patch.object(ir_utils, 'get_client', autospec=True)
|
||||
|
@ -1,11 +0,0 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue where re-inspection from failed prior introspection
|
||||
attempts that failed due to unrelated reasons, such as networking
|
||||
failures, may fail if inspection is requested is requested while
|
||||
the machine is still powered-on. This is as some hardware will not
|
||||
accept new boot device commands in the Power-On-Self-Test state,
|
||||
which is a state a machine which had a failure in networking may be
|
||||
in. Inspector now powers off the node before performing inspection
|
||||
when it is managing the inspection process.
|
Loading…
Reference in New Issue
Block a user