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.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-24 10:15:38 -05:00
1 parent c1dd542f97
commit caf16c8aa5
2 files changed
+12 -4

No files matched your search

@@ -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=""
+9 -2
View File
@@ -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() {')]