Skip to content

Commit 54c89e1

Browse files
committed
azure-pipelines: wait for the dpkg lock when installing Linux deps
The 1ES Ubuntu agents come up with the `unattended-upgrades` service already running, which holds `/var/lib/dpkg/lock-frontend` for the first few minutes after boot. The Linux build's 'Install build dependencies' and the Linux validate job's 'Install Git' steps both ran `sudo apt-get update` immediately and intermittently failed with E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process <pid> (unattended-upgr) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? (see e.g. pipeline run #96 of debug-azp), aborting the entire job on what is genuinely just a timing race. Pass `-o DPkg::Lock::Timeout=600` to the affected `apt-get update` and `apt-get install` invocations on both the build and validate jobs. apt 2.1+ (Ubuntu 22.04 ships 2.4) honours this option by internally polling for the lock rather than failing immediately, which both turns the race into a backoff and lets us keep the existing one-line apt invocations rather than wrapping them in an ad-hoc retry loop. 600 seconds is enough headroom for the longest boot-time unattended-upgrades run we have observed in CI without giving up so late that a genuinely stuck lock would still block the agent forever. A short comment on the build-job step captures the rationale; the validate-job comment cross-references it instead of duplicating the explanation. Assisted-by: Claude Opus 4.7 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent bb77905 commit 54c89e1

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

.azure-pipelines/release.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,8 +918,16 @@ extends:
918918
targetType: inline
919919
script: |
920920
set -euo pipefail
921-
sudo apt-get update -q
922-
sudo apt-get install -y -q --no-install-recommends \
921+
# The 1ES Ubuntu agents come up with `unattended-
922+
# upgrades` running, which holds the dpkg
923+
# frontend lock for the first few minutes after
924+
# boot. `apt-get` releases earlier than 2.1
925+
# would have failed immediately with
926+
# E: Could not get lock /var/lib/dpkg/lock-frontend
927+
# Pass `DPkg::Lock::Timeout=600` so apt waits up
928+
# to 10 minutes for the lock instead.
929+
sudo apt-get -o DPkg::Lock::Timeout=600 update -q
930+
sudo apt-get -o DPkg::Lock::Timeout=600 install -y -q --no-install-recommends \
923931
build-essential \
924932
tcl tk gettext asciidoc xmlto \
925933
libcurl4-gnutls-dev libpcre2-dev zlib1g-dev libexpat-dev \
@@ -1151,8 +1159,11 @@ extends:
11511159
exit 1
11521160
fi
11531161
echo "Installing $deb"
1154-
sudo apt-get update
1155-
sudo apt-get install -y "$deb"
1162+
# Wait up to 10 minutes for unattended-upgrades to
1163+
# release the dpkg lock; see comment on the build
1164+
# job's 'Install build dependencies' step.
1165+
sudo apt-get -o DPkg::Lock::Timeout=600 update
1166+
sudo apt-get -o DPkg::Lock::Timeout=600 install -y "$deb"
11561167
displayName: 'Install Git'
11571168
- bash: |
11581169
set -e

0 commit comments

Comments
 (0)