From ab4a3bd867423b9131c8db251fecd5618930a6a5 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 17 Jan 2019 16:46:03 +0100 Subject: [PATCH] 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 --- ironic_inspector/conductor/manager.py | 6 +++++- ironic_inspector/conf/default.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ironic_inspector/conductor/manager.py b/ironic_inspector/conductor/manager.py index c4ab9584f..dc6aecedc 100644 --- a/ironic_inspector/conductor/manager.py +++ b/ironic_inspector/conductor/manager.py @@ -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() diff --git a/ironic_inspector/conf/default.py b/ironic_inspector/conf/default.py index 5567fb5d5..2c66f70a0 100644 --- a/ironic_inspector/conf/default.py +++ b/ironic_inspector/conf/default.py @@ -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',