refactor (ci/tests): Stop any ongoing processes before retrying to install bbb (#21515)

* Stop any ongoing processes before retrying to install bbb

* add rm -f param

* Update .github/workflows/automated-tests.yml

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* make cleanup more verbose

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Gustavo Trott 2024-10-24 10:47:02 -03:00 committed by GitHub
parent d11ab481f9
commit 67dac35176
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -292,9 +292,25 @@ jobs:
echo "Installation failed with exit code $COMMAND_EXIT_CODE" echo "Installation failed with exit code $COMMAND_EXIT_CODE"
echo "Retrying installation within $RETRY_INTERVAL seconds..." echo "Retrying installation within $RETRY_INTERVAL seconds..."
sleep $RETRY_INTERVAL sleep $RETRY_INTERVAL
# Remove lock in case the timeout was during an apt install
rm -f /var/lib/dpkg/lock
fi fi
echo "Stop any ongoing processes related to apt-get or dpkg that might be stuck"
# Use -q to suppress "no process found" messages
killall -q apt-get || true
killall -q dpkg || true
echo "Remove the lock files that may have been left behind"
# Group lock file removal for better readability
rm -f /var/lib/dpkg/lock-frontend
rm -f /var/lib/dpkg/lock
rm -f /var/cache/apt/archives/lock
echo "Reconfigure the package manager"
dpkg --configure -a
echo "Clean up any partially installed packages"
apt-get clean
apt-get autoremove
RETRY_COUNT=$((RETRY_COUNT + 1)) RETRY_COUNT=$((RETRY_COUNT + 1))
done done