fix: import runner image archives during prepull
Deploy Cluster / Terraform (push) Successful in 32s
Deploy Cluster / Ansible (push) Failing after 46m46s

This commit is contained in:
2026-04-30 09:08:44 +00:00
parent 353a408dac
commit 6d6e3e8371
3 changed files with 89 additions and 8 deletions
@@ -1,13 +1,49 @@
---
- name: Pre-pull bootstrap images into containerd
- name: Check for runner-provided bootstrap image archives
stat:
path: "{{ playbook_dir }}/../outputs/bootstrap-image-archives/{{ item | regex_replace('[/:]', '_') }}.tar"
delegate_to: localhost
become: false
register: bootstrap_image_archive_stats
loop: "{{ bootstrap_prepull_images }}"
- name: Ensure remote bootstrap image archive directory exists
file:
path: /tmp/bootstrap-image-archives
state: directory
mode: "0755"
- name: Copy runner-provided bootstrap image archives
copy:
src: "{{ item.stat.path }}"
dest: "/tmp/bootstrap-image-archives/{{ item.item | regex_replace('[/:]', '_') }}.tar"
mode: "0644"
loop: "{{ bootstrap_image_archive_stats.results }}"
loop_control:
label: "{{ item.item }}"
when: item.stat.exists
- name: Import or pull bootstrap images into containerd
shell: |
if /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
echo "already present"
exit 0
fi
for attempt in 1 2 3; do
if timeout 120s /usr/local/bin/ctr -n k8s.io images pull "{{ item }}"; then
archive="/tmp/bootstrap-image-archives/{{ item | regex_replace('[/:]', '_') }}.tar"
if [ -s "${archive}" ]; then
for attempt in 1 2 3; do
if /usr/local/bin/ctr -n k8s.io images import "${archive}" && /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
echo "imported image"
exit 0
fi
sleep 10
done
fi
for attempt in 1 2 3 4 5; do
if timeout 180s /usr/local/bin/ctr -n k8s.io images pull "{{ item }}"; then
echo "pulled image"
exit 0
fi
@@ -20,4 +56,4 @@
executable: /bin/bash
register: bootstrap_image_pull
loop: "{{ bootstrap_prepull_images }}"
changed_when: "'pulled image' in bootstrap_image_pull.stdout"
changed_when: "'imported image' in bootstrap_image_pull.stdout or 'pulled image' in bootstrap_image_pull.stdout"
@@ -1,13 +1,49 @@
---
- name: Pre-pull Rancher images into containerd
- name: Check for runner-provided Rancher image archives
stat:
path: "{{ playbook_dir }}/../outputs/bootstrap-image-archives/{{ item | regex_replace('[/:]', '_') }}.tar"
delegate_to: localhost
become: false
register: rancher_image_archive_stats
loop: "{{ rancher_images_to_prepull }}"
- name: Ensure remote Rancher image archive directory exists
file:
path: /tmp/bootstrap-image-archives
state: directory
mode: "0755"
- name: Copy runner-provided Rancher image archives
copy:
src: "{{ item.stat.path }}"
dest: "/tmp/bootstrap-image-archives/{{ item.item | regex_replace('[/:]', '_') }}.tar"
mode: "0644"
loop: "{{ rancher_image_archive_stats.results }}"
loop_control:
label: "{{ item.item }}"
when: item.stat.exists
- name: Import or pull Rancher images into containerd
shell: |
if /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
echo "already present"
exit 0
fi
for attempt in 1 2 3; do
if timeout 120s /usr/local/bin/ctr -n k8s.io images pull "{{ item }}"; then
archive="/tmp/bootstrap-image-archives/{{ item | regex_replace('[/:]', '_') }}.tar"
if [ -s "${archive}" ]; then
for attempt in 1 2 3; do
if /usr/local/bin/ctr -n k8s.io images import "${archive}" && /usr/local/bin/ctr -n k8s.io images ls -q | grep -Fx -- "{{ item }}" >/dev/null; then
echo "imported image"
exit 0
fi
sleep 10
done
fi
for attempt in 1 2 3 4 5; do
if timeout 180s /usr/local/bin/ctr -n k8s.io images pull "{{ item }}"; then
echo "pulled image"
exit 0
fi
@@ -20,4 +56,4 @@
executable: /bin/bash
register: rancher_image_pull
loop: "{{ rancher_images_to_prepull }}"
changed_when: "'pulled image' in rancher_image_pull.stdout"
changed_when: "'imported image' in rancher_image_pull.stdout or 'pulled image' in rancher_image_pull.stdout"