From 67dac35176097e6840de93f8142b52e2794908b7 Mon Sep 17 00:00:00 2001 From: Gustavo Trott Date: Thu, 24 Oct 2024 10:47:02 -0300 Subject: [PATCH] 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> --- .github/workflows/automated-tests.yml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automated-tests.yml b/.github/workflows/automated-tests.yml index 61ceac66f9..396258f6bf 100644 --- a/.github/workflows/automated-tests.yml +++ b/.github/workflows/automated-tests.yml @@ -292,9 +292,25 @@ jobs: echo "Installation failed with exit code $COMMAND_EXIT_CODE" echo "Retrying installation within $RETRY_INTERVAL seconds..." sleep $RETRY_INTERVAL - # Remove lock in case the timeout was during an apt install - rm -f /var/lib/dpkg/lock 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)) done