test(cloudflared): stop the API stub only while its pid is still the stub
Cleanup now checks /proc/<pid>/cmdline before it signals the pid, so a reused pid is never killed, and removes the pid file afterwards. Assisted-by: Claude Code:claude-opus-5-5
This commit is contained in:
1 parent
eaa5d2f4ee
commit
92534a486e
1 file changed
+18
-3
@@ -1,6 +1,7 @@
|
|||||||
---
|
---
|
||||||
# Stops the Cloudflare API stub that prepare.yml started on the controller. Also run before
|
# Stops the Cloudflare API stub that prepare.yml started on the controller. Also run before
|
||||||
# create, when there is nothing to stop yet.
|
# create, when there is nothing to stop yet. The pid is only signalled while it still belongs
|
||||||
|
# to the stub, so a reused pid is never killed.
|
||||||
- name: Cleanup
|
- name: Cleanup
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
connection: local
|
connection: local
|
||||||
@@ -14,10 +15,24 @@
|
|||||||
register: cloudflared_test_stub_pid
|
register: cloudflared_test_stub_pid
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Read the command line of that pid
|
||||||
|
ansible.builtin.slurp:
|
||||||
|
src: "/proc/{{ cloudflared_test_stub_pid.content | b64decode | trim }}/cmdline"
|
||||||
|
register: cloudflared_test_stub_cmdline
|
||||||
|
# It may have ended at its lifetime already.
|
||||||
|
failed_when: false
|
||||||
|
when: cloudflared_test_stub_pid.content is defined
|
||||||
|
|
||||||
- name: Stop the stub
|
- name: Stop the stub
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
argv: [kill, "{{ cloudflared_test_stub_pid.content | b64decode | trim }}"]
|
argv: [kill, "{{ cloudflared_test_stub_pid.content | b64decode | trim }}"]
|
||||||
# It may have ended at its lifetime already.
|
|
||||||
failed_when: false
|
failed_when: false
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: cloudflared_test_stub_pid.content is defined
|
when:
|
||||||
|
- cloudflared_test_stub_cmdline.content is defined
|
||||||
|
- "'cloudflare_api_stub.py' in (cloudflared_test_stub_cmdline.content | b64decode)"
|
||||||
|
|
||||||
|
- name: Remove the pid file
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ cloudflared_test_stub_dir }}/pid"
|
||||||
|
state: absent
|
||||||
Reference in new issue
Block a user