Merge "Clean up caches periodically"
This commit is contained in:
commit
143449d3db
@ -72,6 +72,7 @@ from ironic.conductor import utils
|
|||||||
from ironic.conductor import verify
|
from ironic.conductor import verify
|
||||||
from ironic.conf import CONF
|
from ironic.conf import CONF
|
||||||
from ironic.drivers import base as drivers_base
|
from ironic.drivers import base as drivers_base
|
||||||
|
from ironic.drivers.modules import image_cache
|
||||||
from ironic import objects
|
from ironic import objects
|
||||||
from ironic.objects import base as objects_base
|
from ironic.objects import base as objects_base
|
||||||
from ironic.objects import fields
|
from ironic.objects import fields
|
||||||
@ -100,6 +101,12 @@ class ConductorManager(base_manager.BaseConductorManager):
|
|||||||
super(ConductorManager, self).__init__(host, topic)
|
super(ConductorManager, self).__init__(host, topic)
|
||||||
self.power_state_sync_count = collections.defaultdict(int)
|
self.power_state_sync_count = collections.defaultdict(int)
|
||||||
|
|
||||||
|
@METRICS.timer('ConductorManager._clean_up_caches')
|
||||||
|
@periodics.periodic(spacing=CONF.conductor.cache_clean_up_interval,
|
||||||
|
enabled=CONF.conductor.cache_clean_up_interval > 0)
|
||||||
|
def _clean_up_caches(self, context):
|
||||||
|
image_cache.clean_up_all()
|
||||||
|
|
||||||
@METRICS.timer('ConductorManager.create_node')
|
@METRICS.timer('ConductorManager.create_node')
|
||||||
# No need to add these since they are subclasses of InvalidParameterValue:
|
# No need to add these since they are subclasses of InvalidParameterValue:
|
||||||
# InterfaceNotFoundInEntrypoint
|
# InterfaceNotFoundInEntrypoint
|
||||||
|
@ -59,6 +59,10 @@ opts = [
|
|||||||
min=0,
|
min=0,
|
||||||
help=_('Interval between checks of orphaned allocations, '
|
help=_('Interval between checks of orphaned allocations, '
|
||||||
'in seconds. Set to 0 to disable checks.')),
|
'in seconds. Set to 0 to disable checks.')),
|
||||||
|
cfg.IntOpt('cache_clean_up_interval',
|
||||||
|
default=3600, min=0,
|
||||||
|
help=_('Interval between cleaning up image caches, in seconds. '
|
||||||
|
'Set to 0 to disable periodic clean-up.')),
|
||||||
cfg.IntOpt('deploy_callback_timeout',
|
cfg.IntOpt('deploy_callback_timeout',
|
||||||
default=1800,
|
default=1800,
|
||||||
min=0,
|
min=0,
|
||||||
|
@ -393,6 +393,13 @@ def clean_up_caches(ctx, directory, images_info):
|
|||||||
_clean_up_caches(directory, total_size)
|
_clean_up_caches(directory, total_size)
|
||||||
|
|
||||||
|
|
||||||
|
def clean_up_all():
|
||||||
|
"""Clean up all entries from all caches."""
|
||||||
|
caches_to_clean = [x[1]() for x in _cache_cleanup_list]
|
||||||
|
for cache in caches_to_clean:
|
||||||
|
cache.clean_up()
|
||||||
|
|
||||||
|
|
||||||
def cleanup(priority):
|
def cleanup(priority):
|
||||||
"""Decorator method for adding cleanup priority to a class."""
|
"""Decorator method for adding cleanup priority to a class."""
|
||||||
def _add_property_to_class_func(cls):
|
def _add_property_to_class_func(cls):
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
All image caches are now cleaned up periodically, not only when used.
|
||||||
|
Set ``[conductor]cache_clean_up_interval`` to tune the interval or disable.
|
Loading…
x
Reference in New Issue
Block a user