From 847a835d3a8a5a50049f6661016aa36788613424 Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Fri, 12 Jul 2024 11:26:35 -0700
Subject: [PATCH] Limit linaro mirror Apache cache size

The linaro mirror node only has a 100GB cache volume to be shared
between OpenAFS and Apache. Each cache gets a ~50GB filesystem dedicated
to it. Unfortunately we were telling Apache's cache pruning system to
limit to 60000M which is large than 50GB. THis resulted in the cache
filling up and I think it may also be the source of errors.

Address this my reconfiguring htcacheclean to limit to ~40GB. This limit
is set with some buffer space as htcacheclean runs periodically and has
to keep things low enough to avoid filling up.

Change-Id: I7af3daa396b1631feefed5952460b8a9710b25b5
---
 .../host_vars/mirror01.regionone.linaro.opendev.org.yaml       | 3 +++
 playbooks/roles/mirror/defaults/main.yaml                      | 3 ++-
 playbooks/roles/mirror/tasks/main.yaml                         | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/inventory/service/host_vars/mirror01.regionone.linaro.opendev.org.yaml b/inventory/service/host_vars/mirror01.regionone.linaro.opendev.org.yaml
index 04d8bf5c79..3177eb2ec3 100644
--- a/inventory/service/host_vars/mirror01.regionone.linaro.opendev.org.yaml
+++ b/inventory/service/host_vars/mirror01.regionone.linaro.opendev.org.yaml
@@ -6,3 +6,6 @@ letsencrypt_certs:
 # Allocated 100GB volume for this mirror, so openafs cache has to be <
 # 95%; we go for 45gb
 afs_client_cache_size: '45000000'
+# Simiarly we need to limit the size of the apache mirror to < 50GB
+# and the default is 60000M.
+mirror_apache_cache_limit: '40000M'
diff --git a/playbooks/roles/mirror/defaults/main.yaml b/playbooks/roles/mirror/defaults/main.yaml
index 8268337479..2bd73e067f 100644
--- a/playbooks/roles/mirror/defaults/main.yaml
+++ b/playbooks/roles/mirror/defaults/main.yaml
@@ -1,3 +1,4 @@
 mirror_root: '/afs/openstack.org/mirror'
 www_base: '/var/www'
-www_root: '{{ www_base }}/mirror'
\ No newline at end of file
+www_root: '{{ www_base }}/mirror'
+mirror_apache_cache_limit: '60000M'
diff --git a/playbooks/roles/mirror/tasks/main.yaml b/playbooks/roles/mirror/tasks/main.yaml
index f548a05f08..f18d4575d1 100644
--- a/playbooks/roles/mirror/tasks/main.yaml
+++ b/playbooks/roles/mirror/tasks/main.yaml
@@ -168,6 +168,6 @@
   cron:
     name: Apache cache cleanup
     state: present
-    job: /usr/bin/flock -n /var/run/htcacheclean.lock /usr/bin/htcacheclean -n -p /var/cache/apache2/proxy -t -l 60000M > /dev/null
+    job: /usr/bin/flock -n /var/run/htcacheclean.lock /usr/bin/htcacheclean -n -p /var/cache/apache2/proxy -t -l {{ mirror_apache_cache_limit }} > /dev/null
     minute: '0'
     hour: '*'