Skip to content

Commit 61884b1

Browse files
committed
run.yaml: add diagnostic context when dockerd fails to start
Replace the silent retry loop with tasks that dump: - docker info output from last attempt - dockerd process list (ps aux | grep dockerd) - last 100 lines of /var/log/dockerd.log - last 100 lines of /var/log/containerd.log Then fail with all that context so we can see what went wrong.
1 parent d540d2d commit 61884b1

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

‎playbooks_k8s/run.yaml‎

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,44 @@
121121
path: /var/run/docker.sock
122122
timeout: 60
123123

124-
- name: Wait for Docker daemon to be ready (docker info, retries)
124+
# After 75s of retries the daemon still hasn't started. Capture
125+
# stderr/stdout from the last attempt, show the process list, and
126+
# dump the daemon log so we can diagnose why it fails.
127+
- name: Show docker info output from last attempt
128+
ansible.builtin.debug:
129+
var: docker_info
130+
when: docker_info is defined
131+
132+
- name: Check if dockerd process exists
125133
ansible.builtin.command:
126-
cmd: docker info
127-
register: docker_info
134+
cmd: ps aux | grep -v grep | grep dockerd
135+
register: dockerd_ps
128136
changed_when: false
129-
retries: 15
130-
delay: 5
131-
until: docker_info.rc == 0
137+
failed_when: false
132138

133-
- name: Show Docker version
139+
- name: Show dockerd log (last 100 lines)
134140
ansible.builtin.command:
135-
cmd: docker --version
136-
register: docker_ver
141+
cmd: tail -n 100 /var/log/dockerd.log
142+
register: dockerd_tail
137143
changed_when: false
138144
failed_when: false
139145

146+
- name: Show containerd log (last 100 lines)
147+
ansible.builtin.command:
148+
cmd: tail -n 100 /var/log/containerd.log
149+
register: containerd_tail
150+
changed_when: false
151+
failed_when: false
152+
153+
- name: Fail with diagnostic context
154+
ansible.builtin.fail:
155+
msg: >-
156+
Docker daemon failed to start after 75s.
157+
dockerd process: {{ dockerd_ps.stdout_lines | default(['no process found']) }}
158+
Last docker info: {{ docker_info.msg | default('N/A') }}
159+
dockerd log:\n{{ dockerd_tail.stdout | default('no log file') }}
160+
containerd log:\n{{ containerd_tail.stdout | default('no log file') }}
161+
140162
- hosts: all
141163
become: true
142164
roles:

0 commit comments

Comments
 (0)