From caf16c8aa5c42dec6f908ac36d9545672d136875 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Tue, 24 Nov 2026 10:15:38 -0500 Subject: [PATCH] fix(steam): a failed package claim fails the install (#3149) run_parallel is called in an || list, which switches set -e off inside it and inside its workers, so a failed claim left the worker's index empty and the worker exited successfully with packages unclaimed. The worker now checks the claim itself and marks the run failed, and claim_next uses the same flock command as the unpack lock. --- .../overlay/usr/local/bin/droiddeck-steam-install | 5 +++-- tools/tests/test_steam_install.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install index 8990abf3dc..1578b24042 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install @@ -184,7 +184,7 @@ claim_next() { local n while :; do # A counter that cannot be read or written must fail the worker: a stale or empty number would give a package to two workers or to none. - n=$( { flock 8 || exit 1 + n=$( { "$flock_command" 8 || exit 1 n=$(cat "$state/next") || exit 1 case $n in ''|*[!0-9]*) exit 1 ;; esac echo $((n + 1)) > "$state/next" || exit 1 @@ -223,7 +223,8 @@ run_parallel() { ( trap ': > "$state/exit.$slot"' EXIT while [ ! -e "$state/failed" ]; do - index=$(claim_next) + # run_parallel is called in an || list, which switches set -e off in here: a failed claim has to be checked by hand. + index=$(claim_next) || { : > "$state/failed"; exit 1; } [ "$index" -gt 0 ] || exit 0 file=${files[index]} fetched="" diff --git a/tools/tests/test_steam_install.py b/tools/tests/test_steam_install.py index 3364729efb..836372c29c 100644 --- a/tools/tests/test_steam_install.py +++ b/tools/tests/test_steam_install.py @@ -627,7 +627,7 @@ with open(log, 'a') as out: state = self.root / 'claims' state.mkdir() (state / 'next').write_text('1\n') - script = 'state=$1\ncount=$2\n' + function + 'while :; do n=$(claim_next); [ "$n" -gt 0 ] || exit 0; echo "$n"; done\n' + script = 'state=$1\ncount=$2\nflock_command=flock\n' + function + 'while :; do n=$(claim_next); [ "$n" -gt 0 ] || exit 0; echo "$n"; done\n' workers = [subprocess.Popen(['bash', '-c', script, 'bash', str(state), '300'], stdout=subprocess.PIPE, text=True) for _ in range(8)] claimed = [] @@ -649,10 +649,17 @@ with open(log, 'a') as out: (state / 'next').mkdir() else: (state / 'next').write_text('' if broken == 'empty' else 'abc\n') - script = 'state=$1\ncount=5\n' + function + 'n=$(claim_next) && echo "claimed $n" || echo failed\n' + script = 'state=$1\ncount=5\nflock_command=flock\n' + function + 'n=$(claim_next) && echo "claimed $n" || echo failed\n' result = subprocess.run(['bash', '-c', script, 'bash', str(state)], text=True, capture_output=True, timeout=30) self.assertEqual('failed', result.stdout.strip(), f'{broken}: {result.stdout!r} {result.stderr!r}') + def test_a_claim_that_fails_fails_the_install_instead_of_leaving_packages_unclaimed(self): + self.many_parts() + # false is found like a flock would be, but it never takes the lock, so every claim fails. + result = self.install(DD_STEAM_FLOCK='false', timeout=60) + self.assertNotEqual(0, result.returncode, result.stdout) + self.assertFalse((self.steam / 'package/droiddeck-installed').exists()) + def test_the_parallel_workers_use_no_process_substitution(self): source = SCRIPT.read_text() region = source[source.index('fetch_one() {'):source.index('fetch_manifest() {')]