Allow to configure cache clean up period

Add new option "IRONIC_INSPECTOR_CLEAN_UP_PERIOD" to devstack
plugin, which allow to configure clean up time of node cache.

The periodics.periodic_task decorator application on
main.py:periodic_clean_up and main.py:periodic_update is postponed
until after the inspector.conf file is read.

Change-Id: Ic6563990c789b1d1c3b72088860a4d13a3d57f29
Closes-Bug: #1639286
This commit is contained in:
Anton Arefiev 2016-11-02 21:35:27 +02:00 committed by dparalen
parent cb8db157e4
commit 2401f0cb10
3 changed files with 19 additions and 6 deletions

View File

@ -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"

View File

@ -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)

View File

@ -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