fix(gitea_runner): address review of the prune count and threshold

Give each new input its own assert message so every refused-input case
matches only its own input, and cover a negative count and a bad disk
check schedule. Fire the pressure prune only above the threshold, as
the inputs describe it. Name the disk check script apart from the
pressure service, prefix the new registers as internal, and keep the
new comments short.

Refs #319

Assisted-by: Claude Code
This commit is contained in:
Defame1297 committed 2026-11-23 18:20:32 +00:00
1 parent f50ecc2945
commit e91c074373
10 files changed
+86 -63

No files matched your search

@@ -5,5 +5,5 @@ minor_changes:
``gitea_runner_docker_prune_keep_per_repository`` above 0 the weekly prune keeps the newest N image IDs of each ``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`` 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 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 prune capped at ``gitea_runner_docker_prune_builder_keep_storage`` when the filesystem holding the Docker root is
least that full, behind the same job gate as the weekly prune. Both are off by default. fuller than that, behind the same job gate as the weekly prune. Both are off by default.
+2 -2
View File
@@ -54,7 +54,7 @@ Ubuntu 24.04 (noble), the image the molecule scenario runs on. The role uses `an
| `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_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_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_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_threshold_percent` | `0` (off) | Use % of the Docker root's filesystem above 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_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_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_enabled` | `false` | Install molecule tooling and add the host label. |
@@ -100,6 +100,6 @@ The `default` molecule scenario runs without a Gitea server and without Docker:
- The runner binary is verified against `gitea_runner_checksum_url` on install and update; a mismatch fails the download task, and on an update leaves the running binary in place. - The runner binary is verified against `gitea_runner_checksum_url` on install and update; a mismatch fails the download task, and on an update leaves the running binary in place.
- Handlers: `Restart Gitea Runner` runs when the config template changes or a registration happens. - Handlers: `Restart Gitea Runner` runs when the config template changes or a registration happens.
- The Docker prune units (`gitea-runner-docker-prune.{service,timer}`) are written only while `gitea_runner_docker_prune_enabled` is true. Setting it back to false leaves them in place: run `systemctl disable --now gitea-runner-docker-prune.timer` by hand. `gitea_runner_remove` deletes them, the pressure units and the prune scripts. A run skipped because a job was running is not retried until the next timer elapse: shorten `gitea_runner_docker_prune_schedule` (e.g. `*-*-* 04:30:00`) if that happens. - The Docker prune units (`gitea-runner-docker-prune.{service,timer}`) are written only while `gitea_runner_docker_prune_enabled` is true. Setting it back to false leaves them in place: run `systemctl disable --now gitea-runner-docker-prune.timer` by hand. `gitea_runner_remove` deletes them, the pressure units and the prune scripts. A run skipped because a job was running is not retried until the next timer elapse: shorten `gitea_runner_docker_prune_schedule` (e.g. `*-*-* 04:30:00`) if that happens.
- The pressure prune (`gitea-runner-docker-prune-pressure.{service,timer}`) runs once per check while usage is at or above the threshold; it has no low watermark, so usage that stays high needs a smaller count or a larger disk. A threshold set back to `0` stops its timer and removes its units and disk check script. The age prunes and the count prune both apply: an image either one removes is gone. - The pressure prune (`gitea-runner-docker-prune-pressure.{service,timer}`) runs once per check while usage is above the threshold; it has no low watermark, so usage that stays high needs a smaller count or a larger disk. A threshold set back to `0` stops its timer and removes its units and the disk check script. The age prunes and the count prune both apply: an image either one removes is gone.
- The play fails when `gitea-runner` is not `active` after start. - The play fails when `gitea-runner` is not `active` after start.
- `no_log` covers the token mint, the token fact and the registration command. - `no_log` covers the token mint, the token fact and the registration command.
+1 -1
View File
@@ -37,7 +37,7 @@ gitea_runner_docker_prune_image_age: 168h
gitea_runner_docker_prune_job_max_age: 21600 gitea_runner_docker_prune_job_max_age: 21600
# Newest image IDs kept per repository by the weekly and pressure prunes; 0 = off. # Newest image IDs kept per repository by the weekly and pressure prunes; 0 = off.
gitea_runner_docker_prune_keep_per_repository: 0 gitea_runner_docker_prune_keep_per_repository: 0
# Use % of the Docker root's filesystem at which the pressure prune runs; 0 = off. Needs the count. # Use % of the Docker root's filesystem above which the pressure prune runs; 0 = off. Needs the count.
gitea_runner_docker_prune_disk_threshold_percent: 0 gitea_runner_docker_prune_disk_threshold_percent: 0
gitea_runner_docker_prune_disk_check_schedule: hourly gitea_runner_docker_prune_disk_check_schedule: hourly
gitea_runner_docker_prune_builder_keep_storage: 10GB gitea_runner_docker_prune_builder_keep_storage: 10GB
@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# Exit 0 when the filesystem holding the Docker root is at least $1 percent full (the pressure # Exit 0 when the filesystem holding the Docker root is more than $1 percent full (the pressure
# prune may run), 1 to skip. Every failure skips: the prune must not run when the state is unknown. # prune may run), 1 to skip. Every failure skips: the prune must not run when the state is unknown.
threshold="$1" threshold="$1"
case "$threshold" in case "$threshold" in
@@ -10,9 +10,9 @@ use=$(df -P "$root" | awk 'NR == 2 { sub(/%$/, "", $5); print $5 }')
case "$use" in case "$use" in
'' | *[!0-9]*) echo "cannot read the use of '$root'"; exit 1 ;; '' | *[!0-9]*) echo "cannot read the use of '$root'"; exit 1 ;;
esac esac
if [ "$use" -ge "$threshold" ]; then if [ "$use" -gt "$threshold" ]; then
echo "$root is $use% full, threshold $threshold%: pruning" echo "$root is $use% full, above $threshold%: pruning"
exit 0 exit 0
fi fi
echo "$root is $use% full, below $threshold%: skipping the prune" echo "$root is $use% full, not above $threshold%: skipping the prune"
exit 1 exit 1
+1 -1
View File
@@ -245,7 +245,7 @@ argument_specs:
default: 0 default: 0
description: description:
- >- - >-
Use, in percent, of the filesystem holding the Docker root at which Use, in percent, of the filesystem holding the Docker root above which
C(gitea-runner-docker-prune-pressure.service) runs the count prune and a builder prune capped at C(gitea-runner-docker-prune-pressure.service) runs the count prune and a builder prune capped at
C(gitea_runner_docker_prune_builder_keep_storage), behind the same job gate as the weekly prune. C(0) turns it C(gitea_runner_docker_prune_builder_keep_storage), behind the same job gate as the weekly prune. C(0) turns it
off, and setting it back to C(0) stops the timer and removes its units. C(1) to C(99), and above C(0) only with off, and setting it back to C(0) stops the timer and removes its units. C(1) to C(99), and above C(0) only with
@@ -15,6 +15,7 @@
gitea_runner_docker_prune_image_age: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_image_age | default('168h') }}" gitea_runner_docker_prune_image_age: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_image_age | default('168h') }}"
gitea_runner_docker_prune_keep_per_repository: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_keep_per_repository | default(2) }}" gitea_runner_docker_prune_keep_per_repository: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_keep_per_repository | default(2) }}"
gitea_runner_docker_prune_disk_threshold_percent: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_disk_threshold_percent | default(90) }}" gitea_runner_docker_prune_disk_threshold_percent: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_disk_threshold_percent | default(90) }}"
gitea_runner_docker_prune_disk_check_schedule: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_disk_check_schedule | default('hourly') }}"
gitea_runner_docker_prune_builder_keep_storage: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_builder_keep_storage | default('10GB') }}" gitea_runner_docker_prune_builder_keep_storage: "{{ gitea_runner_test_refused.vars.gitea_runner_docker_prune_builder_keep_storage | default('10GB') }}"
gitea_runner_molecule_enabled: "{{ gitea_runner_test_refused.vars.gitea_runner_molecule_enabled | default(false) }}" gitea_runner_molecule_enabled: "{{ gitea_runner_test_refused.vars.gitea_runner_molecule_enabled | default(false) }}"
+24 -18
View File
@@ -116,7 +116,7 @@
- gitea_runner_test_pressure_timer.status.ActiveState == 'active' - gitea_runner_test_pressure_timer.status.ActiveState == 'active'
- gitea_runner_test_pressure_timer.status.UnitFileState == 'enabled' - gitea_runner_test_pressure_timer.status.UnitFileState == 'enabled'
- "'ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-gate 3600' in gitea_runner_test_pressure_text" - "'ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-gate 3600' in gitea_runner_test_pressure_text"
- "'ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-pressure 90' in gitea_runner_test_pressure_text" - "'ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-disk-check 90' in gitea_runner_test_pressure_text"
- "'ExecStart=-/usr/local/sbin/gitea-runner-docker-prune-keep 2' in gitea_runner_test_pressure_text" - "'ExecStart=-/usr/local/sbin/gitea-runner-docker-prune-keep 2' in gitea_runner_test_pressure_text"
- "'ExecStart=-/usr/bin/docker builder prune --force --keep-storage 10GB' in gitea_runner_test_pressure_text" - "'ExecStart=-/usr/bin/docker builder prune --force --keep-storage 10GB' in gitea_runner_test_pressure_text"
quiet: true quiet: true
@@ -195,14 +195,10 @@
loop_control: loop_control:
loop_var: gitea_runner_test_path loop_var: gitea_runner_test_path
# The count prune and the disk check against a stub docker CLI. The stub answers `image ls`, # The count prune and the disk check against a stub docker CLI: it answers from the files below,
# `ps` and `container inspect` from the files below, `info` with the root named in a file, and # records `rmi` calls, and a fail-<command> file makes that command fail. With N = 2, app keeps
# records every `rmi` call; a fail-<command> file makes that command fail. With N = 2: # a1 (two tags: counted twice it would push a2 out), a2 and a4 (used by c1); lib keeps m1 though
# - app: a1 (two tags, newest) and a2 stay, a3 and a5 go, a4 stays because container c1 uses it; # it is third in old; s3 (two tags) goes with --force; d1 goes, d2 (used by c2) stays.
# a1 counted twice would push a2 out;
# - lib keeps m1, so it stays although it is the third newest of old, which keeps o1 and o2;
# - stale: s3 goes with --force (two tags);
# - dangling: d1 goes, d2 stays because container c2 uses it.
- name: Verify the count prune and the disk check - name: Verify the count prune and the disk check
hosts: all hosts: all
gather_facts: false gather_facts: false
@@ -315,19 +311,23 @@
loop_control: loop_control:
label: "{{ item.gitea_runner_test_case.name }}" label: "{{ item.gitea_runner_test_case.name }}"
# Any used root filesystem is at least 1% full (df rounds up), and a tmpfs holding a few lock # The above case sets the threshold one below the root's use, read just before (df rounds up,
# files is far from 50%, so both cases hold on any host. # so a used root is at least 1%); a tmpfs holding a few lock files is never above 50%.
- name: Run each disk check case - name: Run each disk check case
ansible.builtin.shell: ansible.builtin.shell:
cmd: | cmd: |
cd {{ gitea_runner_test_dir }} && rm -f fail-* cd {{ gitea_runner_test_dir }} && rm -f fail-*
{{ ('touch fail-' ~ gitea_runner_test_case.fail) if gitea_runner_test_case.fail else ':' }} {{ ('touch fail-' ~ gitea_runner_test_case.fail) if gitea_runner_test_case.fail else ':' }}
echo '{{ gitea_runner_test_case.root }}' > root echo '{{ gitea_runner_test_case.root }}' > root
/usr/local/sbin/gitea-runner-docker-prune-pressure {{ gitea_runner_test_case.threshold }} threshold={{ gitea_runner_test_case.threshold }}
if [ "$threshold" = below-use ]; then
df -P / > df-root && threshold=$(($(awk 'NR == 2 { sub(/%$/, "", $5); print $5 }' df-root) - 1))
fi
/usr/local/sbin/gitea-runner-docker-prune-disk-check "$threshold"
loop: loop:
- {name: above, root: /, threshold: 1, fail: "", rc: 0} - {name: above, root: /, threshold: below-use, fail: "", rc: 0}
- {name: below, root: /run/lock, threshold: 50, fail: "", rc: 1} - {name: below, root: /run/lock, threshold: 50, fail: "", rc: 1}
- {name: info-fails, root: /, threshold: 1, fail: info, rc: 1} - {name: info-fails, root: /, threshold: below-use, fail: info, rc: 1}
- {name: root-missing, root: /nonexistent, threshold: 1, fail: "", rc: 1} - {name: root-missing, root: /nonexistent, threshold: 1, fail: "", rc: 1}
loop_control: loop_control:
loop_var: gitea_runner_test_case loop_var: gitea_runner_test_case
@@ -424,12 +424,18 @@
- name: prune age without a unit - name: prune age without a unit
vars: {gitea_runner_docker_prune_image_age: "168"} vars: {gitea_runner_docker_prune_image_age: "168"}
expect: plain OnCalendar value expect: plain OnCalendar value
- name: negative prune count
vars: {gitea_runner_docker_prune_keep_per_repository: -1}
expect: gitea_runner_docker_prune_keep_per_repository must be 0 (off) or more
- name: disk threshold of 100 - name: disk threshold of 100
vars: {gitea_runner_docker_prune_disk_threshold_percent: 100} vars: {gitea_runner_docker_prune_disk_threshold_percent: 100}
expect: 0 (off) or 1 to 99 expect: gitea_runner_docker_prune_disk_threshold_percent must be 0 (off) or 1 to 99
- name: disk check schedule with a newline
vars: {gitea_runner_docker_prune_disk_check_schedule: "hourly\nExecStartPre=/bin/false"}
expect: gitea_runner_docker_prune_disk_check_schedule must be a plain OnCalendar value
- name: builder keep-storage with an extra argument - name: builder keep-storage with an extra argument
vars: {gitea_runner_docker_prune_builder_keep_storage: "10GB --all"} vars: {gitea_runner_docker_prune_builder_keep_storage: "10GB --all"}
expect: 0 (off) or 1 to 99 expect: gitea_runner_docker_prune_builder_keep_storage must be a number
- name: disk threshold without a count - name: disk threshold without a count
vars: {gitea_runner_docker_prune_keep_per_repository: 0} vars: {gitea_runner_docker_prune_keep_per_repository: 0}
expect: needs gitea_runner_docker_prune_keep_per_repository above 0 expect: needs gitea_runner_docker_prune_keep_per_repository above 0
@@ -561,7 +567,7 @@
loop: loop:
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service - /etc/systemd/system/gitea-runner-docker-prune-pressure.service
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer - /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
- /usr/local/sbin/gitea-runner-docker-prune-pressure - /usr/local/sbin/gitea-runner-docker-prune-disk-check
loop_control: loop_control:
loop_var: gitea_runner_test_path loop_var: gitea_runner_test_path
register: gitea_runner_test_pressure_off register: gitea_runner_test_pressure_off
@@ -622,7 +628,7 @@
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service - /etc/systemd/system/gitea-runner-docker-prune-pressure.service
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer - /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
- /usr/local/sbin/gitea-runner-docker-prune-keep - /usr/local/sbin/gitea-runner-docker-prune-keep
- /usr/local/sbin/gitea-runner-docker-prune-pressure - /usr/local/sbin/gitea-runner-docker-prune-disk-check
- /etc/systemd/system/multi-user.target.wants/gitea-runner.service - /etc/systemd/system/multi-user.target.wants/gitea-runner.service
loop_control: loop_control:
loop_var: gitea_runner_test_path loop_var: gitea_runner_test_path
+25 -26
View File
@@ -11,19 +11,6 @@
# week set a shorter gitea_runner_docker_prune_schedule (e.g. daily). # week set a shorter gitea_runner_docker_prune_schedule (e.g. daily).
# The ExecStart= lines start with '-' so a failing step does not skip the later ones. # The ExecStart= lines start with '-' so a failing step does not skip the later ones.
# Named volumes are never pruned (docker volume prune without -a removes anonymous ones only). # Named volumes are never pruned (docker volume prune without -a removes anonymous ones only).
# The count prune of the weekly and pressure services: the newest N image IDs per repository
# stay, and images in use by a container always stay.
- name: Install Docker prune count script
become: true
ansible.builtin.copy:
src: gitea-runner-docker-prune-keep
dest: /usr/local/sbin/gitea-runner-docker-prune-keep
owner: root
group: root
mode: "0755"
when: gitea_runner_docker_prune_enabled | bool
tags: [gitea_runner, prune]
- name: Install Docker prune gate script - name: Install Docker prune gate script
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
@@ -58,6 +45,18 @@
when: gitea_runner_docker_prune_enabled | bool when: gitea_runner_docker_prune_enabled | bool
tags: [gitea_runner, prune] tags: [gitea_runner, prune]
# Used by the weekly and pressure services when gitea_runner_docker_prune_keep_per_repository > 0.
- name: Install Docker prune count script
become: true
ansible.builtin.copy:
src: gitea-runner-docker-prune-keep
dest: /usr/local/sbin/gitea-runner-docker-prune-keep
owner: root
group: root
mode: "0755"
when: gitea_runner_docker_prune_enabled | bool
tags: [gitea_runner, prune]
- name: Install Docker prune service - name: Install Docker prune service
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
@@ -119,8 +118,8 @@
- name: Install Docker disk check script - name: Install Docker disk check script
become: true become: true
ansible.builtin.copy: ansible.builtin.copy:
src: gitea-runner-docker-prune-pressure src: gitea-runner-docker-prune-disk-check
dest: /usr/local/sbin/gitea-runner-docker-prune-pressure dest: /usr/local/sbin/gitea-runner-docker-prune-disk-check
owner: root owner: root
group: root group: root
mode: "0755" mode: "0755"
@@ -141,10 +140,10 @@
[Service] [Service]
Type=oneshot Type=oneshot
ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-gate {{ gitea_runner_docker_prune_job_max_age }} ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-gate {{ gitea_runner_docker_prune_job_max_age }}
ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-pressure {{ gitea_runner_docker_prune_disk_threshold_percent }} ExecCondition=/usr/local/sbin/gitea-runner-docker-prune-disk-check {{ gitea_runner_docker_prune_disk_threshold_percent }}
ExecStart=-/usr/local/sbin/gitea-runner-docker-prune-keep {{ gitea_runner_docker_prune_keep_per_repository }} ExecStart=-/usr/local/sbin/gitea-runner-docker-prune-keep {{ gitea_runner_docker_prune_keep_per_repository }}
ExecStart=-/usr/bin/docker builder prune --force --keep-storage {{ gitea_runner_docker_prune_builder_keep_storage }} ExecStart=-/usr/bin/docker builder prune --force --keep-storage {{ gitea_runner_docker_prune_builder_keep_storage }}
register: gitea_runner_prune_pressure_service register: __gitea_runner_prune_pressure_service
- name: Install Docker pressure prune timer - name: Install Docker pressure prune timer
become: true become: true
@@ -164,7 +163,7 @@
[Install] [Install]
WantedBy=timers.target WantedBy=timers.target
register: gitea_runner_prune_pressure_timer register: __gitea_runner_prune_pressure_timer
# A threshold set back to 0 turns the pressure path off: the units go, so nothing is left armed. # A threshold set back to 0 turns the pressure path off: the units go, so nothing is left armed.
- name: Stop the Docker pressure prune timer when the disk threshold is 0 - name: Stop the Docker pressure prune timer when the disk threshold is 0
@@ -173,10 +172,10 @@
name: gitea-runner-docker-prune-pressure.timer name: gitea-runner-docker-prune-pressure.timer
state: stopped state: stopped
enabled: false enabled: false
register: gitea_runner_prune_pressure_stop register: __gitea_runner_prune_pressure_stop
failed_when: failed_when:
- gitea_runner_prune_pressure_stop.failed | default(false) - __gitea_runner_prune_pressure_stop.failed | default(false)
- "'Could not find the requested service' not in (gitea_runner_prune_pressure_stop.msg | default(''))" - "'Could not find the requested service' not in (__gitea_runner_prune_pressure_stop.msg | default(''))"
when: when:
- gitea_runner_docker_prune_enabled | bool - gitea_runner_docker_prune_enabled | bool
- gitea_runner_docker_prune_disk_threshold_percent | int == 0 - gitea_runner_docker_prune_disk_threshold_percent | int == 0
@@ -190,10 +189,10 @@
loop: loop:
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer - /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
- /etc/systemd/system/gitea-runner-docker-prune-pressure.service - /etc/systemd/system/gitea-runner-docker-prune-pressure.service
- /usr/local/sbin/gitea-runner-docker-prune-pressure - /usr/local/sbin/gitea-runner-docker-prune-disk-check
loop_control: loop_control:
loop_var: gitea_runner_prune_pressure_file loop_var: gitea_runner_prune_pressure_file
register: gitea_runner_prune_pressure_removed register: __gitea_runner_prune_pressure_removed
when: when:
- gitea_runner_docker_prune_enabled | bool - gitea_runner_docker_prune_enabled | bool
- gitea_runner_docker_prune_disk_threshold_percent | int == 0 - gitea_runner_docker_prune_disk_threshold_percent | int == 0
@@ -207,8 +206,8 @@
- gitea_runner_docker_prune_enabled | bool - gitea_runner_docker_prune_enabled | bool
- >- - >-
gitea_runner_prune_service is changed or gitea_runner_prune_timer is changed gitea_runner_prune_service is changed or gitea_runner_prune_timer is changed
or gitea_runner_prune_pressure_service is changed or gitea_runner_prune_pressure_timer is changed or __gitea_runner_prune_pressure_service is changed or __gitea_runner_prune_pressure_timer is changed
or gitea_runner_prune_pressure_removed is changed or __gitea_runner_prune_pressure_removed is changed
tags: [gitea_runner, prune] tags: [gitea_runner, prune]
# Not in check mode: on the first run the unit files above are only simulated, so systemd # Not in check mode: on the first run the unit files above are only simulated, so systemd
@@ -229,7 +228,7 @@
ansible.builtin.systemd: ansible.builtin.systemd:
name: gitea-runner-docker-prune-pressure.timer name: gitea-runner-docker-prune-pressure.timer
enabled: true enabled: true
state: "{{ 'restarted' if gitea_runner_prune_pressure_timer is changed else 'started' }}" state: "{{ 'restarted' if __gitea_runner_prune_pressure_timer is changed else 'started' }}"
when: when:
- gitea_runner_docker_prune_enabled | bool - gitea_runner_docker_prune_enabled | bool
- gitea_runner_docker_prune_disk_threshold_percent | int > 0 - gitea_runner_docker_prune_disk_threshold_percent | int > 0
+1 -1
View File
@@ -54,7 +54,7 @@
loop: loop:
- gitea-runner-docker-prune-gate - gitea-runner-docker-prune-gate
- gitea-runner-docker-prune-keep - gitea-runner-docker-prune-keep
- gitea-runner-docker-prune-pressure - gitea-runner-docker-prune-disk-check
loop_control: loop_control:
loop_var: gitea_runner_prune_script loop_var: gitea_runner_prune_script
tags: [gitea_runner, remove] tags: [gitea_runner, remove]
+25 -8
View File
@@ -36,19 +36,36 @@
quiet: true quiet: true
when: gitea_runner_docker_prune_enabled | bool when: gitea_runner_docker_prune_enabled | bool
# The same character set as the weekly schedule; the size takes Docker's own units. - name: Validate the Docker prune count
- name: Validate the Docker prune count and pressure settings ansible.builtin.assert:
that: gitea_runner_docker_prune_keep_per_repository | int >= 0
fail_msg: gitea_runner_docker_prune_keep_per_repository must be 0 (off) or more.
quiet: true
when: gitea_runner_docker_prune_enabled | bool
- name: Validate the Docker prune disk threshold
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- gitea_runner_docker_prune_keep_per_repository | int >= 0
- gitea_runner_docker_prune_disk_threshold_percent | int >= 0 - gitea_runner_docker_prune_disk_threshold_percent | int >= 0
- gitea_runner_docker_prune_disk_threshold_percent | int <= 99 - gitea_runner_docker_prune_disk_threshold_percent | int <= 99
- gitea_runner_docker_prune_disk_check_schedule is match('^[A-Za-z0-9 :*,./~-]+$') fail_msg: gitea_runner_docker_prune_disk_threshold_percent must be 0 (off) or 1 to 99.
- gitea_runner_docker_prune_builder_keep_storage is match('^[0-9]+(B|KB|MB|GB|TB)?$') quiet: true
when: gitea_runner_docker_prune_enabled | bool
# Same character set as the weekly schedule.
- name: Validate the Docker prune disk check schedule
ansible.builtin.assert:
that: gitea_runner_docker_prune_disk_check_schedule is match('^[A-Za-z0-9 :*,./~-]+$')
fail_msg: gitea_runner_docker_prune_disk_check_schedule must be a plain OnCalendar value (no newline or %).
quiet: true
when: gitea_runner_docker_prune_enabled | bool
# A subset of the units Docker accepts for --keep-storage.
- name: Validate the Docker builder keep-storage size
ansible.builtin.assert:
that: gitea_runner_docker_prune_builder_keep_storage is match('^[0-9]+(B|KB|MB|GB|TB)?$')
fail_msg: >- fail_msg: >-
gitea_runner_docker_prune_keep_per_repository must be 0 or more, gitea_runner_docker_prune_disk_threshold_percent gitea_runner_docker_prune_builder_keep_storage must be a number with an optional B, KB, MB, GB or TB (e.g. 10GB).
0 (off) or 1 to 99, gitea_runner_docker_prune_disk_check_schedule a plain OnCalendar value (no newline or %)
and gitea_runner_docker_prune_builder_keep_storage a number with an optional B, KB, MB, GB or TB (e.g. 10GB).
quiet: true quiet: true
when: gitea_runner_docker_prune_enabled | bool when: gitea_runner_docker_prune_enabled | bool