Skip to content

Commit 0e9bbd8

Browse files
committed
fix: Resolve APT lock conflicts and DNS issues in LXD containers
- Disable automatic package updates in cloud-init to avoid lock conflicts - Add wait loop for APT locks to be released before running updates - Configure DNS properly with fallback nameservers and /etc/hosts entry - Add 30-minute timeout to prevent CI jobs from hanging indefinitely - Move DNS configuration to cloud-init to avoid race conditions These changes should fix: - 'Could not get APT lock' errors - 'Temporary failure in name resolution' errors - Jobs hanging indefinitely
1 parent 58ce7a7 commit 0e9bbd8

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
4747
scripted-deploy:
4848
runs-on: ubuntu-24.04
49+
timeout-minutes: 30
4950
permissions:
5051
contents: read
5152
strategy:
@@ -140,6 +141,7 @@ jobs:
140141
141142
docker-deploy:
142143
runs-on: ubuntu-24.04
144+
timeout-minutes: 30
143145
permissions:
144146
contents: read
145147
strategy:

tests/cloud-init.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@ BRANCH_NAME=${BRANCH:-master}
55

66
cat << EOF
77
#cloud-config
8-
package_update: true
9-
package_upgrade: true
8+
# Disable automatic package updates to avoid APT lock conflicts
9+
package_update: false
10+
package_upgrade: false
1011
runcmd:
1112
- |
1213
#!/bin/bash
1314
set -ex
15+
16+
# Wait for any running apt processes to finish
17+
while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1 || fuser /var/lib/apt/lists/lock >/dev/null 2>&1; do
18+
echo "Waiting for apt locks to be released..."
19+
sleep 5
20+
done
21+
22+
# Fix DNS resolution
23+
echo "nameserver 8.8.8.8" > /etc/resolv.conf
24+
echo "nameserver 1.1.1.1" >> /etc/resolv.conf
25+
echo "127.0.0.1 algo" >> /etc/hosts
26+
27+
# Update packages manually after ensuring no locks
28+
apt-get update || true
29+
apt-get upgrade -y || true
30+
1431
export METHOD=local
1532
export ONDEMAND_CELLULAR=true
1633
export ONDEMAND_WIFI=true

tests/pre-deploy.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ until dig A +short algo.lxd @10.0.8.1 | grep -vE '^$' > /dev/null; do
3333
sleep 3
3434
done
3535

36-
# Ensure DNS is working in the container
37-
sleep 5
38-
lxc exec algo -- bash -c "echo 'nameserver 8.8.8.8' > /etc/resolv.conf"
39-
lxc exec algo -- bash -c "echo 'nameserver 1.1.1.1' >> /etc/resolv.conf"
36+
# DNS is now configured in cloud-init to avoid race conditions
4037

4138
case ${UBUNTU_VERSION} in
4239
20.04|22.04)

0 commit comments

Comments
 (0)