Implement alarms history cleanup via panko-expirer
Added ability to create cron for panko-expirer launch.
By default expirer will be launched on hourly basis.
Change-Id: I7b128f804d715f417950eba32a4f8be9e74afdac
Related-Prod: https://mirantis.jira.com/browse/PROD-21307
diff --git a/README.rst b/README.rst
index 2a9932b..1cceabc 100644
--- a/README.rst
+++ b/README.rst
@@ -48,6 +48,25 @@
- host: 10.20.0.104
port: 11211
+Setting event cleanup
+
+In order to allow events cleanup from one node of the cluster,
+server:role field should be set to primary and all others to
+secondary to avoid race conditions. On the example below
+expirer is set to run every day at 2:00 AM. By default
+it will be run every hour.
+
+.. code-block:: yaml
+
+ panko:
+ server:
+ role: primary
+ expirer:
+ cron:
+ minute: 0
+ hour: 2
+
+
Enhanced logging with logging.conf
----------------------------------
diff --git a/panko/map.jinja b/panko/map.jinja
index e24342e..551fb29 100644
--- a/panko/map.jinja
+++ b/panko/map.jinja
@@ -4,6 +4,9 @@
pkgs:
- panko-api
cacert_file: '/etc/ssl/certs/ca-certificates.crt'
+ expirer:
+ cron:
+ minute: 0
logging:
log_appender: false
log_handlers:
diff --git a/panko/server.sls b/panko/server.sls
index e5997ac..da24d93 100644
--- a/panko/server.sls
+++ b/panko/server.sls
@@ -47,6 +47,30 @@
- service: panko_apache_restart
{% endif %}
+{%- if server.get('role', 'secondary') == 'primary' %}
+{%- set cron = server.expirer.cron %}
+panko_expirer_cron:
+ cron.present:
+ {#- By default expirer will write logs to stderr, so redirecting them to syslog #}
+ - name: /usr/bin/panko-expirer {% if not server.logging.log_appender %}--use-syslog{% endif %}
+ - user: panko
+ - minute: '{{ cron.minute }}'
+ {%- if cron.hour is defined %}
+ - hour: '{{ cron.hour }}'
+ {%- endif %}
+ {%- if cron.daymonth is defined %}
+ - daymonth: '{{ cron.daymonth }}'
+ {%- endif %}
+ {%- if cron.month is defined %}
+ - month: '{{ cron.month }}'
+ {%- endif %}
+ {%- if cron.dayweek is defined %}
+ - dayweek: '{{ cron.dayweek }}'
+ {%- endif %}
+ - require:
+ - file: /etc/panko/panko.conf
+{%- endif %}
+
panko_syncdb:
cmd.run:
- name: panko-dbsync