From f50ecc29453cd5724b7c83c61791367d7cfa7dcc Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Mon, 23 Nov 2026 18:04:50 +0000 Subject: [PATCH 1/4] feat(gitea_runner): bound the Docker image cache by count and disk usage An age-based prune does not cap disk use: the cache grows with how often new image versions are published, and builds on the runner then fail for lack of space. Keep the newest N image IDs per repository in the weekly prune, and add an hourly pressure prune that runs the count prune and a capped builder prune when the Docker root's filesystem passes a threshold, behind the same job gate. Both are off by default. Refs #319 Assisted-by: Claude Code --- ...ea-runner-docker-prune-count-threshold.yml | 9 + roles/gitea_runner/README.md | 9 +- roles/gitea_runner/defaults/main.yml | 6 + .../files/gitea-runner-docker-prune-keep | 58 ++++ .../files/gitea-runner-docker-prune-pressure | 18 ++ roles/gitea_runner/meta/argument_specs.yml | 32 +++ .../molecule/default/molecule.yml | 2 + .../molecule/default/tasks/refused_input.yml | 3 + .../gitea_runner/molecule/default/verify.yml | 251 +++++++++++++++++- roles/gitea_runner/tasks/prune.yml | 125 ++++++++- roles/gitea_runner/tasks/remove.yml | 21 +- roles/gitea_runner/tasks/validate.yml | 27 ++ 12 files changed, 552 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/gitea-runner-docker-prune-count-threshold.yml create mode 100755 roles/gitea_runner/files/gitea-runner-docker-prune-keep create mode 100755 roles/gitea_runner/files/gitea-runner-docker-prune-pressure diff --git a/changelogs/fragments/gitea-runner-docker-prune-count-threshold.yml b/changelogs/fragments/gitea-runner-docker-prune-count-threshold.yml new file mode 100644 index 0000000..002088b --- /dev/null +++ b/changelogs/fragments/gitea-runner-docker-prune-count-threshold.yml @@ -0,0 +1,9 @@ +--- +minor_changes: + - >- + gitea_runner - The Docker prune can bound the image cache by count and by disk use. With + ``gitea_runner_docker_prune_keep_per_repository`` above 0 the weekly prune keeps the newest N image IDs of each + repository and removes every other image no container uses. With ``gitea_runner_docker_prune_disk_threshold_percent`` + set, a timer (``gitea_runner_docker_prune_disk_check_schedule``, hourly by default) runs the count prune and a builder + prune capped at ``gitea_runner_docker_prune_builder_keep_storage`` when the filesystem holding the Docker root is at + least that full, behind the same job gate as the weekly prune. Both are off by default. diff --git a/roles/gitea_runner/README.md b/roles/gitea_runner/README.md index 6f7b766..d28e2a9 100644 --- a/roles/gitea_runner/README.md +++ b/roles/gitea_runner/README.md @@ -53,6 +53,10 @@ Ubuntu 24.04 (noble), the image the molecule scenario runs on. The role uses `an | `gitea_runner_docker_prune_schedule` | `Sun *-*-* 04:30:00` | `OnCalendar` of the prune timer. | | `gitea_runner_docker_prune_container_age`, `_image_age` | `24h`, `168h` | `until` filters (creation time) for containers, and for images and build cache. | | `gitea_runner_docker_prune_job_max_age` | `21600` | Seconds; the prune skips while a younger container runs and ignores older ones as leaked job containers. | +| `gitea_runner_docker_prune_keep_per_repository` | `0` (off) | Newest image IDs kept per repository by the weekly and pressure prunes; every other image no container uses is removed. A multi-tag image counts once. | +| `gitea_runner_docker_prune_disk_threshold_percent` | `0` (off) | Use % of the Docker root's filesystem at which the pressure prune runs the count prune and a capped builder prune, behind the job gate. 1 to 99; needs the count above 0. | +| `gitea_runner_docker_prune_disk_check_schedule` | `hourly` | `OnCalendar` of the pressure prune timer. | +| `gitea_runner_docker_prune_builder_keep_storage` | `10GB` | `--keep-storage` of the builder prune under pressure. | | `gitea_runner_molecule_enabled` | `false` | Install molecule tooling and add the host label. | | `gitea_runner_molecule_label` | `molecule` | Host-executor label name, registered as `