Merge "Glance cache pruner/cleaner operations via salt"
diff --git a/README.rst b/README.rst
index 0d49ea7..e9c2d30 100644
--- a/README.rst
+++ b/README.rst
@@ -341,6 +341,34 @@
barbican:
enabled: true
+Adding cron-job
+---------------
+
+.. code-block:: yaml
+
+ glance:
+ server:
+ cron:
+ cache_pruner:
+ special_period: '@daily'
+ cache_cleaner:
+ hour: '5'
+ minute: '30'
+ daymonth: '*/2'
+
+
+Image cache settings
+--------------------
+
+.. code-block:: yaml
+
+ glance:
+ server:
+ image_cache:
+ max_size: 10737418240
+ stall_time: 86400
+ directory: '/var/lib/glance/image-cache/'
+
Client role
-----------
diff --git a/glance/files/pike/glance-cache.conf.Debian b/glance/files/pike/glance-cache.conf.Debian
index 7d2432b..8aa0445 100644
--- a/glance/files/pike/glance-cache.conf.Debian
+++ b/glance/files/pike/glance-cache.conf.Debian
@@ -554,12 +554,10 @@
# (integer value)
# Minimum value: 0
#image_cache_max_size = 10737418240
-{% if server.get('image_cache', {}).get('enabled', False) %}
-image_cache_max_size = {{ server.image_cache.get('max_size', '10737418240') }}
-image_cache_stall_time = {{ server.image_cache.get('stall_time', '86400') }}
-image_cache_dir = {{ server.image_cache.get('directory', '/var/lib/glance/image-cache/') }}
-{% endif %}
+image_cache_max_size = {{ server.image_cache.max_size }}
+image_cache_stall_time = {{ server.image_cache.stall_time }}
+image_cache_dir = {{ server.image_cache.directory }}
{% if server.identity.region is defined %}
os_region_name = {{ server.identity.region }}
diff --git a/glance/files/queens/glance-cache.conf.Debian b/glance/files/queens/glance-cache.conf.Debian
index ab18a63..29f79f9 100644
--- a/glance/files/queens/glance-cache.conf.Debian
+++ b/glance/files/queens/glance-cache.conf.Debian
@@ -669,12 +669,10 @@
# (integer value)
# Minimum value: 0
#image_cache_max_size = 10737418240
-{% if server.get('image_cache', {}).get('enabled', False) %}
-image_cache_max_size = {{ server.image_cache.get('max_size', '10737418240') }}
-image_cache_stall_time = {{ server.image_cache.get('stall_time', '86400') }}
-image_cache_dir = {{ server.image_cache.get('directory', '/var/lib/glance/image-cache/') }}
-{% endif %}
+image_cache_max_size = {{ server.image_cache.max_size }}
+image_cache_stall_time = {{ server.image_cache.stall_time }}
+image_cache_dir = {{ server.image_cache.directory }}
{% if server.identity.region is defined %}
os_region_name = {{ server.identity.region }}
diff --git a/glance/map.jinja b/glance/map.jinja
index 9d2a690..2d82750 100644
--- a/glance/map.jinja
+++ b/glance/map.jinja
@@ -32,6 +32,21 @@
}
},
},
+ 'image_cache': {
+ 'max_size': '10737418240',
+ 'stall_time': '86400',
+ 'directory': '/var/lib/glance/image-cache/',
+ },
+ 'cron': {
+ 'cache_pruner': {
+ 'special_period': '@daily'
+ },
+ 'cache_cleaner': {
+ 'hour': '5',
+ 'minute': '30',
+ 'daymonth': '*/2',
+ },
+ },
},
'RedHat': {
'pkgs': ['openstack-glance', 'python-glanceclient','python-pycadf'],
@@ -58,6 +73,21 @@
}
},
},
+ 'image_cache': {
+ 'max_size': '10737418240',
+ 'stall_time': '86400',
+ 'directory': '/var/lib/glance/image-cache/',
+ },
+ 'cron': {
+ 'cache_pruner': {
+ 'special_period': '@daily'
+ },
+ 'cache_cleaner': {
+ 'hour': '5',
+ 'minute': '30',
+ 'daymonth': '*/2',
+ },
+ },
},
}, merge=pillar.glance.get('server', {}), base='BaseDefaults') %}
diff --git a/glance/server.sls b/glance/server.sls
index e94dd0f..64254dd 100644
--- a/glance/server.sls
+++ b/glance/server.sls
@@ -258,13 +258,11 @@
- file: mysql_ca_glance_server
{% endif %}
-
-{%- if server.get('image_cache', {}).get('enabled', False) %}
glance_cron_glance-cache-pruner:
cron.present:
- name: glance-cache-pruner
- user: glance
- - special: '@daily'
+ - special: '{{ server.cron.cache_pruner.special_period }}'
- require:
- service: glance_services
@@ -272,16 +270,14 @@
cron.present:
- name: glance-cache-cleaner
- user: glance
- - minute: 30
- - hour: 5
- - daymonth: '*/2'
+ - minute: '{{ server.cron.cache_cleaner.minute }}'
+ - hour: '{{ server.cron.cache_cleaner.hour }}'
+ - daymonth: '{{ server.cron.cache_cleaner.daymonth }}'
- require:
- service: glance_services
{%- endif %}
-{%- endif %}
-
{%- if grains.get('virtual_subtype', None) == "Docker" %}
glance_entrypoint: