Prevent abnormal timeout values from breaking sync with ironic

I had a case when an operator set the timeout too a abnormally large
value, which caused OverflowError in the timeout clean_up task, which,
in turn, prevented ironic-inspector from ever running node list sync
with ironic.

This change makes two corrections:
* The timeout configuration is limited to 10 years (0 can still be used
  to disable the timeout completely).
* Errors in the clean_up task do not prevent the node list sync from
  running.

Change-Id: Ie3ad29a4abb9ac58c41b776042f80dff6a9c72d2
Story: #2004807
Task: #28963
This commit is contained in:
Dmitry Tantsur 2019-01-17 16:46:03 +01:00
parent 9a8cb3a49c
commit ab4a3bd867
2 changed files with 8 additions and 1 deletions

View File

@ -133,10 +133,14 @@ def periodic_clean_up(): # pragma: no cover
try:
if node_cache.clean_up():
pxe_filter.driver().sync(ir_utils.get_client())
sync_with_ironic()
except Exception:
LOG.exception('Periodic clean up of node cache failed')
try:
sync_with_ironic()
except Exception:
LOG.exception('Periodic sync of node list with ironic failed')
def sync_with_ironic():
ironic = ir_utils.get_client()

View File

@ -41,6 +41,9 @@ _OPTS = [
'options. "noauth" will disable all authentication.')),
cfg.IntOpt('timeout',
default=3600,
# We're using timedelta which can overflow if somebody sets this
# too high, so limit to a sane value of 10 years.
max=315576000,
help=_('Timeout after which introspection is considered '
'failed, set to 0 to disable.')),
cfg.IntOpt('clean_up_period',