mirror of
https://github.com/actions/runner-images.git
synced 2025-12-18 07:46:57 +00:00
Workaround for apt db locked by WALinuxAgent v2 (#2000)
* retry apt if lock is held by other process * Increase timeout and change grep string
This commit is contained in:
@@ -11,17 +11,22 @@ for tool in apt apt-get apt-fast;do
|
|||||||
|
|
||||||
i=1
|
i=1
|
||||||
while [ \$i -le 30 ];do
|
while [ \$i -le 30 ];do
|
||||||
fuser /var/lib/dpkg/lock >/dev/null 2>&1
|
err=\$(mktemp)
|
||||||
|
$real_tool "\$@" 2>\$err
|
||||||
result=\$?
|
result=\$?
|
||||||
if [ \$result -eq 0 ];then
|
if [ \$result -eq 0 ];then
|
||||||
sleep 1
|
|
||||||
echo "/var/lib/dpkg/locked... retry \$i"
|
|
||||||
i=\$((i + 1))
|
|
||||||
else
|
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
grep -q 'Could not get lock' \$err
|
||||||
|
held=\$?
|
||||||
|
if [ \$held -ne 0 ];then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
cat \$err >&2
|
||||||
|
sleep 5
|
||||||
|
echo "...retry \$i"
|
||||||
|
i=\$((i + 1))
|
||||||
done
|
done
|
||||||
$real_tool "\$@"
|
|
||||||
EOT
|
EOT
|
||||||
chmod +x $prefix/$tool
|
chmod +x $prefix/$tool
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user