From e1b9e09be3b2261a359ae98b1954866ff7e76f2b Mon Sep 17 00:00:00 2001 From: Emil Simeonov Date: Sat, 8 Aug 2026 22:43:55 +0200 Subject: [PATCH] fix(prune): add --filter until=1h to network prune docker network prune -f removes ALL unused networks, including ones that molecule tests are actively creating (e.g. 'traefik' network created during molecule create phase before containers are attached). This caused "network traefik not found" errors in CI molecule tests. Add --filter "until=1h" to only prune networks older than 1 hour, matching the container prune filter. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- ansible/roles/gitea_runner/templates/docker-prune.service.j2 | 5 ++++- .../roles/gitea_runner/templates/runner-healthcheck.sh.j2 | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ansible/roles/gitea_runner/templates/docker-prune.service.j2 b/ansible/roles/gitea_runner/templates/docker-prune.service.j2 index 208c8c0..ce23d43 100644 --- a/ansible/roles/gitea_runner/templates/docker-prune.service.j2 +++ b/ansible/roles/gitea_runner/templates/docker-prune.service.j2 @@ -13,5 +13,8 @@ Environment=XDG_RUNTIME_DIR=/run/user/{{ gitea_runner_uid }} # them kills the active CI job and causes "RWLayer is unexpectedly nil" errors. ExecStart=/bin/sh -c 'docker ps -a --format "{% raw %}{{.ID}} {{.Names}}{% endraw %}" 2>/dev/null | grep -v "GITEA-ACTIONS-TASK" | awk "{print $1}" | xargs -r docker rm -f 2>/dev/null || true' ExecStart=/usr/bin/docker system prune -af --filter "until={{ gitea_runner_prune_until }}" --volumes -ExecStart=/usr/bin/docker network prune -f +# Prune networks older than the prune-until threshold to avoid removing +# networks that molecule tests are actively creating (e.g. 'traefik' network +# created during molecule create phase before containers are attached). +ExecStart=/usr/bin/docker network prune -f --filter "until={{ gitea_runner_prune_until }}" ExecStart=/usr/bin/docker builder prune -f diff --git a/ansible/roles/gitea_runner/templates/runner-healthcheck.sh.j2 b/ansible/roles/gitea_runner/templates/runner-healthcheck.sh.j2 index 2e4ba95..88ba20b 100644 --- a/ansible/roles/gitea_runner/templates/runner-healthcheck.sh.j2 +++ b/ansible/roles/gitea_runner/templates/runner-healthcheck.sh.j2 @@ -234,7 +234,10 @@ if [[ "$disk_pct" -ge {{ gitea_runner_healthcheck_disk_threshold }} ]]; then | awk '{print $1}' \ | xargs -r docker rm -f 2>/dev/null || true docker system prune -af --filter "until=1h" --volumes || true - docker network prune -f || true + # Prune networks older than 1 hour to avoid removing networks that + # molecule tests are actively creating (e.g. 'traefik' network created + # during molecule create phase before containers are attached). + docker network prune -f --filter "until=1h" || true disk_pct=$(df -P / | awk 'NR==2 {gsub(/%/, "", $5); print $5}') echo "INFO: Disk usage after prune: ${disk_pct}%" fi