Browse Source

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
tags/8.2.0
Dmitry Tantsur 6 months ago
parent
commit
ab4a3bd867
2 changed files with 8 additions and 1 deletions
  1. 5
    1
      ironic_inspector/conductor/manager.py
  2. 3
    0
      ironic_inspector/conf/default.py

+ 5
- 1
ironic_inspector/conductor/manager.py View File

@@ -133,10 +133,14 @@ def periodic_clean_up():  # pragma: no cover
133 133
     try:
134 134
         if node_cache.clean_up():
135 135
             pxe_filter.driver().sync(ir_utils.get_client())
136
-        sync_with_ironic()
137 136
     except Exception:
138 137
         LOG.exception('Periodic clean up of node cache failed')
139 138
 
139
+    try:
140
+        sync_with_ironic()
141
+    except Exception:
142
+        LOG.exception('Periodic sync of node list with ironic failed')
143
+
140 144
 
141 145
 def sync_with_ironic():
142 146
     ironic = ir_utils.get_client()

+ 3
- 0
ironic_inspector/conf/default.py View File

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

Loading…
Cancel
Save