[TRAIN-ONLY] Ensure we clean old ansible logs in mistral

While we do rotate the ansible.log file, it's never cleaned. This can
lead to some issues, depending on the amount of day-2 operations
(scaling, update, etc) - increasing size without control is usually a
bad thing.

Notes:
- we're using `find' instead of tmpwatch, because we want to target
  precise file pattern to remove. tmpwatch does the exact contrary.
- we're pushing the `find' in the existing container log cleaning, so
  that we don't have to edit newer releases to remove any new script we
  may want to add
- mistral being removed in newer releases (stable/wallaby), we can
  safely make this "train-only", and let newer releases override that
  script so that we don't have dangling things

Resolves: rhbz#2144483
Change-Id: Ifbd990f15b9d85260ab20a2004fe79bafda929d9
This commit is contained in:
Cédric Jeanneret 2022-11-21 17:04:04 +01:00 committed by Cedric Jeanneret
parent 073030b338
commit 64dd13b7b1
1 changed files with 7 additions and 3 deletions

View File

@ -109,6 +109,8 @@ outputs:
when: step|int == 2
block:
- name: Push script
vars:
LogrotatePurgeAfterDays: {get_param: LogrotatePurgeAfterDays}
copy:
dest: /usr/local/sbin/containers-tmpwatch
owner: root
@ -122,9 +124,11 @@ outputs:
-X "/var/log/containers/*/*err" \
{{ LogrotatePurgeAfterDays|int +1 }}d \
/var/log/containers/ 2>&1 | logger -t container-tmpwatch
vars:
LogrotatePurgeAfterDays: {get_param: LogrotatePurgeAfterDays}
- name: Insert cronjob in root crontab
find /var/lib/mistral -type f \
-iname '*.log-*' \
-atime +{{ LogrotatePurgeAfterDays|int +1 }} \
-print -delete >&1 | logger -t mistral-log-clean
- name: Insert cronjob in root crontab for containers logs
cron:
name: "Remove old logs"
special_time: "daily"