Stop introspection if set boot device failed
At the beginning of introspection, ironic inspector sets boot device and reboot node through ironic, currently it only stops when reboot the node is failed. Actually the node is not guaranteed to reboot with pxe in either case. This patch eliminates the descripency, so that if anything goes wrong, it will be exposed early. Change-Id: I416e42137e59e04f7fd282aa309f2f89cf574209 Story: #2002977 Task: #22985
This commit is contained in:
parent
7991f12e17
commit
1ad6f69593
@ -106,15 +106,15 @@ def _background_introspect_locked(node_info, ironic):
|
|||||||
ironic.node.set_boot_device(node_info.uuid, 'pxe',
|
ironic.node.set_boot_device(node_info.uuid, 'pxe',
|
||||||
persistent=False)
|
persistent=False)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
LOG.warning('Failed to set boot device to PXE: %s',
|
raise utils.Error(_('Failed to set boot device to PXE: %s') % exc,
|
||||||
exc, node_info=node_info)
|
node_info=node_info)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ironic.node.set_power_state(node_info.uuid, 'reboot')
|
ironic.node.set_power_state(node_info.uuid, 'reboot')
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise utils.Error(_('Failed to power on the node, check it\'s '
|
raise utils.Error(_('Failed to power on the node, check it\'s '
|
||||||
'power management configuration: %s'),
|
'power management configuration: %s') % exc,
|
||||||
exc, node_info=node_info)
|
node_info=node_info)
|
||||||
LOG.info('Introspection started successfully',
|
LOG.info('Introspection started successfully',
|
||||||
node_info=node_info)
|
node_info=node_info)
|
||||||
else:
|
else:
|
||||||
|
@ -122,7 +122,6 @@ class TestIntrospect(BaseTest):
|
|||||||
|
|
||||||
def test_power_failure(self, client_mock, start_mock):
|
def test_power_failure(self, client_mock, start_mock):
|
||||||
cli = self._prepare(client_mock)
|
cli = self._prepare(client_mock)
|
||||||
cli.node.set_boot_device.side_effect = exceptions.BadRequest()
|
|
||||||
cli.node.set_power_state.side_effect = exceptions.BadRequest()
|
cli.node.set_power_state.side_effect = exceptions.BadRequest()
|
||||||
start_mock.return_value = self.node_info
|
start_mock.return_value = self.node_info
|
||||||
|
|
||||||
@ -163,6 +162,28 @@ class TestIntrospect(BaseTest):
|
|||||||
self.node_info.acquire_lock.assert_called_once_with()
|
self.node_info.acquire_lock.assert_called_once_with()
|
||||||
self.node_info.release_lock.assert_called_once_with()
|
self.node_info.release_lock.assert_called_once_with()
|
||||||
|
|
||||||
|
def test_set_boot_device_failure(self, client_mock, start_mock):
|
||||||
|
cli = self._prepare(client_mock)
|
||||||
|
cli.node.set_boot_device.side_effect = exceptions.BadRequest()
|
||||||
|
start_mock.return_value = self.node_info
|
||||||
|
|
||||||
|
introspect.introspect(self.node.uuid)
|
||||||
|
|
||||||
|
cli.node.get.assert_called_once_with(self.uuid)
|
||||||
|
|
||||||
|
start_mock.assert_called_once_with(self.uuid,
|
||||||
|
bmc_address=self.bmc_address,
|
||||||
|
manage_boot=True,
|
||||||
|
ironic=cli)
|
||||||
|
cli.node.set_boot_device.assert_called_once_with(self.uuid,
|
||||||
|
'pxe',
|
||||||
|
persistent=False)
|
||||||
|
cli.node.set_power_state.assert_not_called()
|
||||||
|
start_mock.return_value.finished.assert_called_once_with(
|
||||||
|
introspect.istate.Events.error, error=mock.ANY)
|
||||||
|
self.node_info.acquire_lock.assert_called_once_with()
|
||||||
|
self.node_info.release_lock.assert_called_once_with()
|
||||||
|
|
||||||
def test_no_macs(self, client_mock, start_mock):
|
def test_no_macs(self, client_mock, start_mock):
|
||||||
cli = self._prepare(client_mock)
|
cli = self._prepare(client_mock)
|
||||||
self.node_info.ports.return_value = []
|
self.node_info.ports.return_value = []
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Stops introspection when setting boot device is failed, as the node is
|
||||||
|
not guarenteed to perform a PXE boot in this case.
|
Loading…
Reference in New Issue
Block a user