fix(forgejo-runner): prevent duplicate runner registrations

- Persist runner registration state by setting container working_dir to /data\n- Add post-register assertion that /opt/forgejo-runner/data/.runner exists
This commit is contained in:
Jeremie Fraeys 2026-01-20 18:06:51 -05:00
parent adca1b0ef9
commit 92003e8f1c
No known key found for this signature in database
2 changed files with 18 additions and 0 deletions

View file

@ -88,6 +88,23 @@
when: (not forgejo_runner_registration.stat.exists) or forgejo_runner_labels_changed
no_log: true
- name: Check that runner registration state file exists after registration
stat:
path: /opt/forgejo-runner/data/.runner
register: forgejo_runner_registration_after
changed_when: false
when: (not forgejo_runner_registration.stat.exists) or forgejo_runner_labels_changed
- name: Fail if runner registration did not persist state
assert:
that:
- forgejo_runner_registration_after.stat.exists
fail_msg: >-
Forgejo runner registration did not create /opt/forgejo-runner/data/.runner.
Without this file, the runner will re-register and Forgejo will accumulate duplicate runners.
Ensure the runner container writes its .runner file under /data (the persisted volume).
when: (not forgejo_runner_registration.stat.exists) or forgejo_runner_labels_changed
- name: Persist applied Forgejo runner labels
copy:
dest: /opt/forgejo-runner/data/.labels

View file

@ -1,6 +1,7 @@
services:
runner:
image: data.forgejo.org/forgejo/runner:11
working_dir: /data
environment:
DOCKER_HOST: unix:///var/run/docker.sock
user: "0:0"