Skip to content

Commit 064fe9f

Browse files
committed
fix: improve E2E test reliability in GitHub Actions
- Add network diagnostics to Docker installation playbook - Implement retry logic for apt operations (3 retries, 10s delay) - Force apt-get usage for better CI compatibility - Add fallback apt update mechanism - Increase workflow timeout from 20 to 30 minutes - Enhance error handling for network connectivity issues Fixes intermittent apt cache update failures in CI environment.
1 parent 44b21d8 commit 064fe9f

File tree

3 files changed

+61
-6
lines changed

3 files changed

+61
-6
lines changed

.github/workflows/test-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ on:
1414
jobs:
1515
e2e-tests:
1616
runs-on: ubuntu-latest
17-
timeout-minutes: 20 # Set reasonable timeout for E2E tests
17+
timeout-minutes: 30 # Increased timeout for better network reliability in CI
1818

1919
steps:
2020
- name: Checkout repository

project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ nullglob
2121
oneline
2222
pacman
2323
pipefail
24+
prereq
2425
publickey
2526
pytest
2627
resolv

templates/ansible/install-docker.yml

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,53 @@
2222

2323
# List of tasks to execute in order
2424
tasks:
25-
# Task 1: Update package cache
25+
# Task 0: Network diagnostics for CI troubleshooting
26+
- name: Check network connectivity and DNS resolution
27+
ansible.builtin.shell: |
28+
echo "=== Network Diagnostics ==="
29+
echo "Testing DNS resolution..."
30+
nslookup archive.ubuntu.com || echo "DNS resolution failed"
31+
echo "Testing connectivity to Ubuntu repositories..."
32+
curl -I https://archive.ubuntu.com/ubuntu/ --connect-timeout 10 || echo "Ubuntu repo unreachable"
33+
echo "Testing connectivity to Docker repositories..."
34+
curl -I https://download.docker.com --connect-timeout 10 || echo "Docker repo unreachable"
35+
echo "Current apt sources:"
36+
cat /etc/apt/sources.list
37+
register: network_diagnostics
38+
changed_when: false
39+
ignore_errors: true
40+
41+
- name: Display network diagnostics
42+
ansible.builtin.debug:
43+
var: network_diagnostics.stdout_lines
44+
when: network_diagnostics is defined
45+
46+
# Task 1: Update package cache with retries and better error handling
2647
- name: Update apt package cache
2748
ansible.builtin.apt:
2849
update_cache: true
2950
cache_valid_time: 3600 # Cache valid for 1 hour
51+
force_apt_get: true # Force using apt-get instead of aptitude for better CI compatibility
52+
register: apt_update_result
53+
retries: 3
54+
delay: 10
55+
until: apt_update_result is succeeded
3056
when: ansible_os_family == "Debian"
31-
32-
# Task 2: Install required packages for Docker repository
57+
ignore_errors: false # Fail if apt update ultimately fails
58+
59+
# Task 1.1: Fallback apt update with different approach if needed
60+
- name: Fallback apt update with apt-get directly
61+
ansible.builtin.command: apt-get update
62+
register: apt_get_update
63+
retries: 2
64+
delay: 15
65+
until: apt_get_update.rc == 0
66+
when:
67+
- ansible_os_family == "Debian"
68+
- apt_update_result is failed
69+
ignore_errors: false
70+
71+
# Task 2: Install required packages for Docker repository with retries
3372
- name: Install required packages for Docker repository
3473
ansible.builtin.apt:
3574
name:
@@ -39,6 +78,11 @@
3978
- gnupg
4079
- lsb-release
4180
state: present
81+
force_apt_get: true
82+
register: prereq_packages
83+
retries: 3
84+
delay: 10
85+
until: prereq_packages is succeeded
4286
when: ansible_os_family == "Debian"
4387

4488
# Task 3: Add Docker's official GPG key
@@ -57,13 +101,18 @@
57101
filename: docker
58102
when: ansible_os_family == "Debian"
59103

60-
# Task 5: Update package cache after adding repository
104+
# Task 5: Update package cache after adding repository with retries
61105
- name: Update apt package cache after adding Docker repository
62106
ansible.builtin.apt:
63107
update_cache: true
108+
force_apt_get: true # Force using apt-get for better CI compatibility
109+
register: apt_update_docker_repo
110+
retries: 3
111+
delay: 10
112+
until: apt_update_docker_repo is succeeded
64113
when: ansible_os_family == "Debian"
65114

66-
# Task 6: Install Docker packages
115+
# Task 6: Install Docker packages with retries
67116
- name: Install Docker packages
68117
ansible.builtin.apt:
69118
name:
@@ -72,6 +121,11 @@
72121
- containerd.io
73122
- docker-buildx-plugin
74123
state: present
124+
force_apt_get: true
125+
register: docker_install
126+
retries: 3
127+
delay: 10
128+
until: docker_install is succeeded
75129
when: ansible_os_family == "Debian"
76130

77131
# Task 7: Start and enable Docker service

0 commit comments

Comments
 (0)