Remove ironic running check from inspector startup
This patch removes the check when the inspector starts that ensures that ironic is already running, because it could lead to problems when bringing up services in a distributed environment where order and timing isn't guaranteed. Change-Id: I2a8ee74db781a087a8ecb0c73ddc461a6b326101 Closes-Bug: #1462993
This commit is contained in:
parent
8fe115abbb
commit
a48bb89c11
10
example.conf
10
example.conf
|
@ -117,16 +117,6 @@
|
|||
# Its value may be silently ignored in the future.
|
||||
#identity_uri =
|
||||
|
||||
# Number of attempts to do when trying to connect to Ironic on start
|
||||
# up. (integer value)
|
||||
# Deprecated group/name - [discoverd]/ironic_retry_attempts
|
||||
#ironic_retry_attempts = 5
|
||||
|
||||
# Amount of time between attempts to connect to Ironic on start up.
|
||||
# (integer value)
|
||||
# Deprecated group/name - [discoverd]/ironic_retry_period
|
||||
#ironic_retry_period = 5
|
||||
|
||||
# Method to use for authentication: noauth or keystone. (string value)
|
||||
# Allowed values: keystone, noauth
|
||||
#auth_strategy = keystone
|
||||
|
|
|
@ -50,16 +50,6 @@ IRONIC_OPTS = [
|
|||
'DEPRECATED: use [keystone_authtoken]/identity_uri.',
|
||||
deprecated_group='discoverd',
|
||||
deprecated_for_removal=True),
|
||||
cfg.IntOpt('ironic_retry_attempts',
|
||||
default=5,
|
||||
help='Number of attempts to do when trying to connect to '
|
||||
'Ironic on start up.',
|
||||
deprecated_group='discoverd'),
|
||||
cfg.IntOpt('ironic_retry_period',
|
||||
default=5,
|
||||
help='Amount of time between attempts to connect to Ironic '
|
||||
'on start up.',
|
||||
deprecated_group='discoverd'),
|
||||
cfg.StrOpt('auth_strategy',
|
||||
default='keystone',
|
||||
choices=('keystone', 'noauth'),
|
||||
|
|
|
@ -112,32 +112,6 @@ def periodic_clean_up(period): # pragma: no cover
|
|||
eventlet.greenthread.sleep(period)
|
||||
|
||||
|
||||
def check_ironic_available():
|
||||
"""Try to make sure we can reach Ironic.
|
||||
|
||||
Ensure that:
|
||||
1. Keystone access is configured properly
|
||||
2. Keystone has already started
|
||||
3. Ironic has already started
|
||||
"""
|
||||
attempts = CONF.ironic.ironic_retry_attempts
|
||||
assert attempts >= 0
|
||||
retry_period = CONF.ironic.ironic_retry_period
|
||||
LOG.debug('Trying to connect to Ironic')
|
||||
for i in range(attempts + 1): # one attempt always required
|
||||
try:
|
||||
utils.get_client().driver.list()
|
||||
except Exception as exc:
|
||||
if i == attempts:
|
||||
raise
|
||||
LOG.warning(_LW('Unable to connect to Ironic or Keystone, retrying'
|
||||
' %(count)d times more: %(exc)s') %
|
||||
{'count': attempts - i, 'exc': exc})
|
||||
else:
|
||||
break
|
||||
eventlet.greenthread.sleep(retry_period)
|
||||
|
||||
|
||||
def init():
|
||||
if CONF.authenticate:
|
||||
utils.add_auth_middleware(app)
|
||||
|
@ -146,7 +120,6 @@ def init():
|
|||
' configuration'))
|
||||
|
||||
node_cache.init()
|
||||
check_ironic_available()
|
||||
|
||||
try:
|
||||
hooks = [ext.name for ext in plugins_base.processing_hooks_manager()]
|
||||
|
|
|
@ -16,7 +16,6 @@ import ssl
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
import eventlet
|
||||
import mock
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
|
@ -136,31 +135,6 @@ class TestApi(test_base.BaseTest):
|
|||
json.loads(res.data.decode('utf-8')))
|
||||
|
||||
|
||||
@mock.patch.object(eventlet.greenthread, 'sleep', autospec=True)
|
||||
@mock.patch.object(utils, 'get_client')
|
||||
class TestCheckIronicAvailable(test_base.BaseTest):
|
||||
def test_ok(self, client_mock, sleep_mock):
|
||||
main.check_ironic_available()
|
||||
client_mock.return_value.driver.list.assert_called_once_with()
|
||||
self.assertFalse(sleep_mock.called)
|
||||
|
||||
def test_2_attempts(self, client_mock, sleep_mock):
|
||||
cli = mock.Mock()
|
||||
client_mock.side_effect = [Exception(), cli]
|
||||
main.check_ironic_available()
|
||||
self.assertEqual(2, client_mock.call_count)
|
||||
cli.driver.list.assert_called_once_with()
|
||||
sleep_mock.assert_called_once_with(
|
||||
CONF.ironic.ironic_retry_period)
|
||||
|
||||
def test_failed(self, client_mock, sleep_mock):
|
||||
attempts = CONF.ironic.ironic_retry_attempts
|
||||
client_mock.side_effect = RuntimeError()
|
||||
self.assertRaises(RuntimeError, main.check_ironic_available)
|
||||
self.assertEqual(1 + attempts, client_mock.call_count)
|
||||
self.assertEqual(attempts, sleep_mock.call_count)
|
||||
|
||||
|
||||
class TestPlugins(unittest.TestCase):
|
||||
@mock.patch.object(example_plugin.ExampleProcessingHook,
|
||||
'before_processing', autospec=True)
|
||||
|
|
Loading…
Reference in New Issue