On each start-up make several attempts to check that Ironic is available
This commit is contained in:
parent
7aa591e391
commit
3d2b2d633b
|
@ -171,6 +171,7 @@ v0.2.2
|
|||
|
||||
* ``/v1/discover`` now does some sync checks (`bug #3`_).
|
||||
* Actually able to start under Python 3.3.
|
||||
* On each start-up make several attempts to check that Ironic is available.
|
||||
|
||||
.. _bug #3: https://github.com/Divius/ironic-discoverd/issues/3
|
||||
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
; Tenant name for accessing Ironic API.
|
||||
;os_tenant_name =
|
||||
|
||||
; Number of attempts to do when trying to connect to Ironic on start up.
|
||||
;ironic_retry_attempts = 5
|
||||
; Amount of time between attempts to connect to Ironic on start up.
|
||||
;ironic_retry_period = 5
|
||||
|
||||
; Interface on which dnsmasq listens, the default is for VM's.
|
||||
;dnsmasq_interface = br-ctlplane
|
||||
; Amount of time in seconds, after which repeat periodic update of firewall.
|
||||
|
|
|
@ -25,7 +25,9 @@ def init_conf():
|
|||
'dnsmasq_interface': 'br-ctlplane',
|
||||
'authenticate': 'true',
|
||||
'firewall_update_period': '15',
|
||||
'ports_for_inactive_interfaces': 'false'})
|
||||
'ports_for_inactive_interfaces': 'false',
|
||||
'ironic_retry_attempts': '5',
|
||||
'ironic_retry_period': '5'})
|
||||
|
||||
|
||||
CONF = None
|
||||
|
|
|
@ -74,6 +74,27 @@ def main():
|
|||
|
||||
interface = discoverd.CONF.get('discoverd', 'dnsmasq_interface')
|
||||
firewall.init(interface)
|
||||
|
||||
# Before proceeding we try to make sure:
|
||||
# 1. Keystone access is configured properly
|
||||
# 2. Keystone has already started
|
||||
# 3. Ironic has already started
|
||||
attempts = discoverd.CONF.getint('discoverd', 'ironic_retry_attempts')
|
||||
assert attempts >= 0
|
||||
retry_period = discoverd.CONF.getint('discoverd', 'ironic_retry_period')
|
||||
LOG.debug('Trying to connect to Ironic')
|
||||
for i in range(attempts + 1): # one attempt always required
|
||||
try:
|
||||
discoverd.get_client().driver.list()
|
||||
except Exception as exc:
|
||||
if i == attempts:
|
||||
raise
|
||||
LOG.error('Unable to connect to Ironic or Keystone, retrying %d '
|
||||
'times more: %s', attempts - i, exc)
|
||||
else:
|
||||
break
|
||||
eventlet.greenthread.sleep(retry_period)
|
||||
|
||||
period = discoverd.CONF.getint('discoverd', 'firewall_update_period')
|
||||
eventlet.greenthread.spawn_n(periodic_update, period)
|
||||
|
||||
|
|
Loading…
Reference in New Issue