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:
1 parent
f50ecc2945
commit
e91c074373
10 files changed
+86
-63
No files matched your search
@@ -11,19 +11,6 @@
|
||||
# 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.
|
||||
# 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
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
@@ -58,6 +45,18 @@
|
||||
when: gitea_runner_docker_prune_enabled | bool
|
||||
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
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
@@ -119,8 +118,8 @@
|
||||
- name: Install Docker disk check script
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
src: gitea-runner-docker-prune-pressure
|
||||
dest: /usr/local/sbin/gitea-runner-docker-prune-pressure
|
||||
src: gitea-runner-docker-prune-disk-check
|
||||
dest: /usr/local/sbin/gitea-runner-docker-prune-disk-check
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0755"
|
||||
@@ -141,10 +140,10 @@
|
||||
[Service]
|
||||
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-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/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
|
||||
become: true
|
||||
@@ -164,7 +163,7 @@
|
||||
|
||||
[Install]
|
||||
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.
|
||||
- name: Stop the Docker pressure prune timer when the disk threshold is 0
|
||||
@@ -173,10 +172,10 @@
|
||||
name: gitea-runner-docker-prune-pressure.timer
|
||||
state: stopped
|
||||
enabled: false
|
||||
register: gitea_runner_prune_pressure_stop
|
||||
register: __gitea_runner_prune_pressure_stop
|
||||
failed_when:
|
||||
- gitea_runner_prune_pressure_stop.failed | default(false)
|
||||
- "'Could not find the requested service' not in (gitea_runner_prune_pressure_stop.msg | default(''))"
|
||||
- __gitea_runner_prune_pressure_stop.failed | default(false)
|
||||
- "'Could not find the requested service' not in (__gitea_runner_prune_pressure_stop.msg | default(''))"
|
||||
when:
|
||||
- gitea_runner_docker_prune_enabled | bool
|
||||
- gitea_runner_docker_prune_disk_threshold_percent | int == 0
|
||||
@@ -190,10 +189,10 @@
|
||||
loop:
|
||||
- /etc/systemd/system/gitea-runner-docker-prune-pressure.timer
|
||||
- /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_var: gitea_runner_prune_pressure_file
|
||||
register: gitea_runner_prune_pressure_removed
|
||||
register: __gitea_runner_prune_pressure_removed
|
||||
when:
|
||||
- gitea_runner_docker_prune_enabled | bool
|
||||
- gitea_runner_docker_prune_disk_threshold_percent | int == 0
|
||||
@@ -207,8 +206,8 @@
|
||||
- gitea_runner_docker_prune_enabled | bool
|
||||
- >-
|
||||
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_removed 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
|
||||
tags: [gitea_runner, prune]
|
||||
|
||||
# Not in check mode: on the first run the unit files above are only simulated, so systemd
|
||||
@@ -229,7 +228,7 @@
|
||||
ansible.builtin.systemd:
|
||||
name: gitea-runner-docker-prune-pressure.timer
|
||||
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:
|
||||
- gitea_runner_docker_prune_enabled | bool
|
||||
- gitea_runner_docker_prune_disk_threshold_percent | int > 0
|
||||
|
||||
Reference in new issue
Block a user