From 608f56ab82800980ee5158c75bc9b8993f5f0c8c Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Thu, 30 Apr 2020 16:23:51 -0700
Subject: [PATCH] Configure htcacheclean for zuul-web

We are starting to use the apache2 mod_cache_disk functionality more now
and during use the cache has grown into the 1.5GB range. The
htcacheclean process is cleaning up every 2 hours which is how it is
getting behind with its limit of 300MB. Reduce the interval to 15
minutes by supplying an /etc/default/apache-htcacheclean config.

Note we cache status.json files which are only valid for a very short
period of time. This likely explains the quick growth of the cache.

Change-Id: Iff00fb1806796ef6db26e53e026c533c47a902b4
---
 .../files/apache-htcacheclean.default         | 22 +++++++++++++++++++
 playbooks/roles/zuul-web/tasks/main.yaml      |  8 +++++++
 2 files changed, 30 insertions(+)
 create mode 100644 playbooks/roles/zuul-web/files/apache-htcacheclean.default

diff --git a/playbooks/roles/zuul-web/files/apache-htcacheclean.default b/playbooks/roles/zuul-web/files/apache-htcacheclean.default
new file mode 100644
index 0000000000..2f8ceaac2b
--- /dev/null
+++ b/playbooks/roles/zuul-web/files/apache-htcacheclean.default
@@ -0,0 +1,22 @@
+# This file must only contain KEY=VALUE lines. Do not use advanced
+# shell script constructs!
+
+## run mode: cron, daemon
+## run in daemon mode or as daily cron job
+## default: daemon
+HTCACHECLEAN_MODE=daemon
+
+## cache size
+HTCACHECLEAN_SIZE=300M
+
+## interval: if in daemon mode, clean cache every x minutes
+HTCACHECLEAN_DAEMON_INTERVAL=15
+
+## path to cache
+## must be the same as in CacheRoot directive
+#HTCACHECLEAN_PATH=/var/cache/apache2/mod_cache_disk
+
+## additional options:
+## -n : be nice
+## -t : remove empty directories
+HTCACHECLEAN_OPTIONS="-n"
diff --git a/playbooks/roles/zuul-web/tasks/main.yaml b/playbooks/roles/zuul-web/tasks/main.yaml
index 67a1349cee..3d0521a7a8 100644
--- a/playbooks/roles/zuul-web/tasks/main.yaml
+++ b/playbooks/roles/zuul-web/tasks/main.yaml
@@ -47,6 +47,14 @@
     mode: 0644
   notify: zuul Reload apache2
 
+- name: Copy htcacheclean config
+  copy:
+    src: apache-htcacheclean.default
+    dest: /etc/default/apache-htcacheclean
+    owner: root
+    group: root
+    mode: '0644'
+
 - name: Install logging config
   copy:
     src: logging.conf