diff --git a/devstack/plugin.sh b/devstack/plugin.sh index d1d2a080e..f96ebeb6a 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -22,6 +22,7 @@ IRONIC_INSPECTOR_COLLECTORS=${IRONIC_INSPECTOR_COLLECTORS:-default,logs,pci-devi IRONIC_INSPECTOR_RAMDISK_LOGDIR=${IRONIC_INSPECTOR_RAMDISK_LOGDIR:-$IRONIC_INSPECTOR_DATA_DIR/ramdisk-logs} IRONIC_INSPECTOR_ALWAYS_STORE_RAMDISK_LOGS=${IRONIC_INSPECTOR_ALWAYS_STORE_RAMDISK_LOGS:-True} IRONIC_INSPECTOR_TIMEOUT=${IRONIC_INSPECTOR_TIMEOUT:-600} +IRONIC_INSPECTOR_CLEAN_UP_PERIOD=${IRONIC_INSPECTOR_CLEAN_UP_PERIOD:-} # These should not overlap with other ranges/networks IRONIC_INSPECTOR_INTERNAL_IP=${IRONIC_INSPECTOR_INTERNAL_IP:-172.24.42.254} IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE=${IRONIC_INSPECTOR_INTERNAL_SUBNET_SIZE:-24} @@ -207,7 +208,9 @@ function configure_inspector { inspector_iniset processing node_not_found_hook "$IRONIC_INSPECTOR_NODE_NOT_FOUND_HOOK" fi inspector_iniset DEFAULT timeout $IRONIC_INSPECTOR_TIMEOUT - + if [ -n "$IRONIC_INSPECTOR_CLEAN_UP_PERIOD" ]; then + inspector_iniset DEFAULT clean_up_period "$IRONIC_INSPECTOR_CLEAN_UP_PERIOD" + fi get_or_create_service "ironic-inspector" "baremetal-introspection" "Ironic Inspector baremetal introspection service" get_or_create_endpoint "baremetal-introspection" "$REGION_NAME" \ "$IRONIC_INSPECTOR_URI" "$IRONIC_INSPECTOR_URI" "$IRONIC_INSPECTOR_URI" diff --git a/ironic_inspector/main.py b/ironic_inspector/main.py index 0ff3f6e93..ccc49e670 100644 --- a/ironic_inspector/main.py +++ b/ironic_inspector/main.py @@ -324,8 +324,6 @@ def handle_404(error): return error_response(error, code=404) -@periodics.periodic(spacing=CONF.firewall.firewall_update_period, - enabled=CONF.firewall.manage_firewall) def periodic_update(): # pragma: no cover try: firewall.update_filters() @@ -333,7 +331,6 @@ def periodic_update(): # pragma: no cover LOG.exception(_LE('Periodic update of firewall rules failed')) -@periodics.periodic(spacing=CONF.clean_up_period) def periodic_clean_up(): # pragma: no cover try: if node_cache.clean_up(): @@ -438,9 +435,17 @@ class Service(object): if CONF.firewall.manage_firewall: firewall.init() + periodic_update_ = periodics.periodic( + spacing=CONF.firewall.firewall_update_period, + enabled=CONF.firewall.manage_firewall + )(periodic_update) + periodic_clean_up_ = periodics.periodic( + spacing=CONF.clean_up_period + )(periodic_clean_up) + self._periodics_worker = periodics.PeriodicWorker( - callables=[(periodic_update, None, None), - (periodic_clean_up, None, None)], + callables=[(periodic_update_, None, None), + (periodic_clean_up_, None, None)], executor_factory=periodics.ExistingExecutor(utils.executor())) utils.executor().submit(self._periodics_worker.start) diff --git a/releasenotes/notes/fix-periodic-tasks-configuration-edd167f0146e60b5.yaml b/releasenotes/notes/fix-periodic-tasks-configuration-edd167f0146e60b5.yaml new file mode 100644 index 000000000..2e3871d39 --- /dev/null +++ b/releasenotes/notes/fix-periodic-tasks-configuration-edd167f0146e60b5.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + The configuration of the ``periodic_clean_up`` and ``periodic_update`` tasks + is now applied after the file ``inspector.conf`` is read