Skip to content

Commit 498b9f1

Browse files
committed
fix: resolve LXD provision workflow timeout by removing sudo conflicts
- Add timeout-minutes: 20 to prevent indefinite hanging - Remove sudo from OpenTofu commands to avoid permission conflicts - Remove sudo from LXD commands to use socket permissions consistently - Add LXD socket permissions verification step - Align with working e2e workflow approach that uses non-sudo execution The previous workflow was failing with 'context deadline exceeded' because using sudo with OpenTofu created conflicts with the LXD daemon socket permissions configured by install-lxd-ci.sh.
1 parent 395690d commit 498b9f1

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

.github/workflows/test-lxd-provision.yml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414
jobs:
1515
test-lxd-provision:
1616
runs-on: ubuntu-latest
17+
timeout-minutes: 20 # Set reasonable timeout for LXD provisioning
1718

1819
steps:
1920
- name: Checkout repository
@@ -30,6 +31,12 @@ jobs:
3031
sudo lxc version
3132
tofu version
3233
34+
- name: Test LXD socket permissions
35+
run: |
36+
# Test that LXD commands work without sudo due to socket permissions
37+
lxc version
38+
lxc list
39+
3340
- name: Initialize OpenTofu
3441
working-directory: config/tofu/lxd
3542
run: tofu init
@@ -45,9 +52,9 @@ jobs:
4552
- name: Apply configuration
4653
working-directory: config/tofu/lxd
4754
run: |
48-
# Run with sudo to ensure LXD access in CI environment
55+
# Use tofu without sudo since socket permissions are set up
4956
# NOTE: For local development, use "sg lxd -c 'tofu apply'" instead
50-
sudo -E tofu apply -auto-approve
57+
tofu apply -auto-approve
5158
5259
- name: Wait for container to be ready
5360
run: |
@@ -58,7 +65,7 @@ jobs:
5865
timeout=300
5966
elapsed=0
6067
while [ $elapsed -lt $timeout ]; do
61-
if sudo lxc exec torrust-vm -- test -f /tmp/provision_complete 2>/dev/null; then
68+
if lxc exec torrust-vm -- test -f /tmp/provision_complete 2>/dev/null; then
6269
echo "Container provisioning completed successfully!"
6370
break
6471
fi
@@ -75,53 +82,53 @@ jobs:
7582
- name: Test container functionality
7683
run: |
7784
# Test basic connectivity
78-
sudo lxc list
79-
sudo lxc info torrust-vm
85+
lxc list
86+
lxc info torrust-vm
8087
8188
# Test command execution
82-
sudo lxc exec torrust-vm -- whoami
89+
lxc exec torrust-vm -- whoami
8390
8491
# Test system information with error handling
8592
echo "Getting system information..."
86-
sudo lxc exec torrust-vm -- cat /etc/os-release || echo "os-release failed"
93+
lxc exec torrust-vm -- cat /etc/os-release || echo "os-release failed"
8794
sleep 1
8895
89-
sudo lxc exec torrust-vm -- df -h || echo "df failed"
96+
lxc exec torrust-vm -- df -h || echo "df failed"
9097
sleep 1
9198
92-
sudo lxc exec torrust-vm -- free -h || echo "free failed"
99+
lxc exec torrust-vm -- free -h || echo "free failed"
93100
sleep 1
94101
95102
# Test cloud-init functionality
96103
echo "Testing cloud-init..."
97-
sudo lxc exec torrust-vm -- cloud-init status || echo "cloud-init status failed"
104+
lxc exec torrust-vm -- cloud-init status || echo "cloud-init status failed"
98105
sleep 1
99106
100107
# Test user creation
101108
echo "Testing user creation..."
102-
sudo lxc exec torrust-vm -- id torrust || echo "torrust user not found"
109+
lxc exec torrust-vm -- id torrust || echo "torrust user not found"
103110
sleep 1
104111
105112
# Test systemd services
106113
echo "Testing systemd..."
107-
sudo lxc exec torrust-vm -- systemctl status ssh || echo "ssh service check failed"
114+
lxc exec torrust-vm -- systemctl status ssh || echo "ssh service check failed"
108115
109116
- name: Get container outputs
110117
working-directory: config/tofu/lxd
111-
run: sudo -E tofu output
118+
run: tofu output
112119

113120
- name: Cleanup
114121
if: always()
115122
working-directory: config/tofu/lxd
116123
run: |
117124
echo "Cleaning up container..."
118-
# Use sudo for CI environment cleanup
125+
# Use tofu without sudo since socket permissions are set up
119126
# NOTE: For local development, use "sg lxd -c 'tofu destroy'" instead
120-
sudo -E tofu destroy -auto-approve || true
121-
sudo lxc delete torrust-vm --force || true
127+
tofu destroy -auto-approve || true
128+
lxc delete torrust-vm --force || true
122129
123130
- name: Final verification
124131
if: always()
125132
run: |
126133
echo "Verifying cleanup..."
127-
sudo lxc list
134+
lxc list

0 commit comments

Comments
 (0)