Don't wait for too long for IPMI credentials update

When it finishes, it takes only a few seconds.

Change-Id: I2a72985580f75006b403d818addc2707e17f8d3e
Implements: blueprint setup-ipmi-credentials-take2
This commit is contained in:
Dmitry Tantsur 2015-02-16 08:38:26 +01:00
parent b12ba4a7d0
commit c8080163b3
2 changed files with 5 additions and 8 deletions

View File

@ -133,9 +133,7 @@ def _finish_set_ipmi_credentials(ironic, cached_node,
'value': new_password}]
utils.retry_on_conflict(ironic.node.update, cached_node.uuid, patch)
deadline = cached_node.started_at + conf.getint('discoverd', 'timeout')
attempt = 1
while time.time() < deadline:
for attempt in range(_CREDENTIALS_WAIT_RETRIES):
try:
# We use this call because it requires valid credentials.
# We don't care about boot device, obviously.
@ -145,7 +143,6 @@ def _finish_set_ipmi_credentials(ironic, cached_node,
'current error is %s',
cached_node.uuid, attempt, exc)
eventlet.greenthread.sleep(_CREDENTIALS_WAIT_PERIOD)
attempt += 1
else:
_finish(ironic, cached_node)
return

View File

@ -454,12 +454,10 @@ class TestProcessNode(BaseTest):
self.cli.node.get_boot_device.call_count)
@mock.patch.object(node_cache.NodeInfo, 'finished', autospec=True)
@mock.patch.object(time, 'time')
def test_set_ipmi_credentials_timeout(self, time_mock, finished_mock,
def test_set_ipmi_credentials_timeout(self, finished_mock,
filters_mock, post_hook_mock):
conf.CONF.set('discoverd', 'timeout', '100')
self.cached_node.set_option('new_ipmi_credentials', self.new_creds)
time_mock.return_value = self.started_at + 1000
self.cli.node.get_boot_device.side_effect = RuntimeError('boom')
self.assertRaisesRegexp(utils.Error, 'Failed to validate',
self.call)
@ -467,6 +465,8 @@ class TestProcessNode(BaseTest):
self.cli.node.update.assert_any_call(self.uuid, self.patch_before)
self.cli.node.update.assert_any_call(self.uuid, self.patch_credentials)
self.assertEqual(2, self.cli.node.update.call_count)
self.assertEqual(process._CREDENTIALS_WAIT_RETRIES,
self.cli.node.get_boot_device.call_count)
self.assertFalse(self.cli.node.set_power_state.called)
finished_mock.assert_called_once_with(
mock.ANY,