Skip to content

Commit cc3f54a

Browse files
committed
CI: run timeout inside sudo, per apt command, so the kill reaches apt-get
Addresses Copilot review on QuantEcon/lecture-intro.zh-cn#301: with timeout wrapping sudo, a timed-out attempt terminated sudo and the bash -c shell but could orphan apt-get holding the dpkg lock, making the retry block instead of retry. timeout is now the direct parent of each apt-get (inside sudo, -k 30s escalation): update 1m/2m, install 3m/12m for graphviz/texlive. Step budgets unchanged.
1 parent 541e2bb commit cc3f54a

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

.github/workflows/cache.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,24 @@ jobs:
2424
- name: graphviz Support # TODO: required?
2525
timeout-minutes: 10
2626
run: |
27-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
27+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
28+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
2829
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
2930
pkgs="graphviz"
3031
for attempt in 1 2; do
31-
timeout 4m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
32+
sudo timeout -k 30s 1m apt-get -qq update && sudo timeout -k 30s 3m apt-get install -y $pkgs && break
3233
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
3334
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
3435
done
3536
- name: Install latex dependencies
3637
timeout-minutes: 30
3738
run: |
38-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
39+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
40+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
3941
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
4042
pkgs="texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra texlive-xetex latexmk xindy dvipng cm-super"
4143
for attempt in 1 2; do
42-
timeout 14m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
44+
sudo timeout -k 30s 2m apt-get -qq update && sudo timeout -k 30s 12m apt-get install -y $pkgs && break
4345
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
4446
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
4547
done

.github/workflows/ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@ jobs:
2020
- name: Graphics Support #TODO: Review if graphviz is needed
2121
timeout-minutes: 10
2222
run: |
23-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
23+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
24+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
2425
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
2526
pkgs="graphviz"
2627
for attempt in 1 2; do
27-
timeout 4m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
28+
sudo timeout -k 30s 1m apt-get -qq update && sudo timeout -k 30s 3m apt-get install -y $pkgs && break
2829
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
2930
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
3031
done
3132
- name: Install latex dependencies
3233
timeout-minutes: 30
3334
run: |
34-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
35+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
36+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
3537
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
3638
pkgs="texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra texlive-xetex latexmk xindy dvipng cm-super"
3739
for attempt in 1 2; do
38-
timeout 14m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
40+
sudo timeout -k 30s 2m apt-get -qq update && sudo timeout -k 30s 12m apt-get install -y $pkgs && break
3941
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
4042
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
4143
done

.github/workflows/publish.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ jobs:
3939
- name: Install latex dependencies
4040
timeout-minutes: 30
4141
run: |
42-
# Retried with a per-attempt timeout: a stalled Ubuntu mirror otherwise
42+
# Retried with per-command timeouts (timeout inside sudo, so the kill reaches
43+
# apt-get and the dpkg lock is released): a stalled Ubuntu mirror otherwise
4344
# hangs this step for hours (two 358-minute hangs on 2026-08-18).
4445
pkgs="texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended texlive-fonts-extra texlive-xetex latexmk xindy dvipng cm-super"
4546
for attempt in 1 2; do
46-
timeout 14m sudo bash -c "apt-get -qq update && apt-get install -y $pkgs" && break
47+
sudo timeout -k 30s 2m apt-get -qq update && sudo timeout -k 30s 12m apt-get install -y $pkgs && break
4748
if [ "$attempt" = 2 ]; then echo "apt-get failed after 2 attempts"; exit 1; fi
4849
echo "apt-get attempt $attempt failed; retrying in 30s"; sleep 30
4950
done

0 commit comments

Comments
 (0)