about summary refs log tree commit diff
path: root/ops/modules
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2024-03-31T21·36+0300
committerclbot <clbot@tvl.fyi>2024-03-31T21·44+0000
commit9204b58f158cedb1cff7746c7d465573952e1c4f (patch)
treed391f522bacd774185454ab34e2022e7dccc817e /ops/modules
parent1d1984e85f29e5af686241208a458b5531750169 (diff)
feat(automatic-gc): robust way to disable automatic-gc r/7835
We just had a minor incident where apparently our build cache for the
critical security fix was deleted by automatic-gc (which I had stopped
manually) being reenabled by an unrelated whitby deploy.

This adds a new mechanism where by touching a file called
`/run/stop-automatic-gc` the GC can be prevented from running.

We might want to configure an occasional alert or something if this
file exists, so we don't forget about it when we are using it.

Change-Id: I041e57e24b2b684696164a2d516581d7f5696ef0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11326
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: flokli <flokli@flokli.de>
Diffstat (limited to 'ops/modules')
-rw-r--r--ops/modules/automatic-gc.nix5
1 files changed, 5 insertions, 0 deletions
diff --git a/ops/modules/automatic-gc.nix b/ops/modules/automatic-gc.nix
index ad53a63f7f..003f160919 100644
--- a/ops/modules/automatic-gc.nix
+++ b/ops/modules/automatic-gc.nix
@@ -13,6 +13,11 @@ let
   gcScript = pkgs.writeShellScript "automatic-nix-gc" ''
     set -ueo pipefail
 
+    if [ -e /run/stop-automatic-gc ]; then
+      echo "GC is disabled through /run/stop-automatic-gc"
+      exit 0
+    fi
+
     readonly MIN_THRESHOLD_KIB="${toString (GiBtoKiB cfg.diskThreshold)}"
     readonly MAX_FREED_BYTES="${toString (GiBtoBytes cfg.maxFreed)}"
     readonly GEN_THRESHOLD="${cfg.preserveGenerations}"