Skip to content

Conversation

@jessebye
Copy link

We use self-hosted runners and have found that sometimes another process (probably apt-daily) has a lock and causes the apt update in this action to fail. Adding an exponential backoff provides more resilience for the action. Adding the -o DPkg::Lock::Timeout=60 provides additional resilience so it won't fail immediately if another dpkg process is running.

@lrozniewicz
Copy link

I just wanted to +1 this PR — we’re encountering the same intermittent issue on our self-hosted runners.

@github-actions
Copy link

github-actions bot commented Nov 8, 2025

This pull request is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the wontfix This will not be worked on label Nov 8, 2025
@bertekintw bertekintw requested a review from Copilot December 2, 2025 19:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +43
for i in $(seq 1 $max_retries); do
if sudo apt-get update; then
echo "apt-get update succeeded"
break
else
echo "apt-get update failed, retrying ($i/$max_retries) in $delay seconds..."
sleep $delay
delay=$((delay * 2)) # exponential backoff
fi
done
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry loop doesn't check if apt-get update ultimately succeeded after all retries are exhausted. If all 5 attempts fail, the script continues to the install step which may fail or produce unexpected results. Consider adding a check after the loop:

if [ $i -eq $max_retries ] && ! sudo apt-get update; then
  echo "apt-get update failed after $max_retries attempts"
  exit 1
fi

Alternatively, track success in a variable inside the loop and check it afterward.

Copilot uses AI. Check for mistakes.
max_retries=5
delay=5
for i in $(seq 1 $max_retries); do
if sudo apt-get update; then
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry logic updates all apt repositories, but the original code specifically updated only the Twingate repository using -o Dir::Etc::sourcelist="sources.list.d/twingate.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0". This change could unnecessarily update all system repositories on each retry, potentially increasing execution time and exposing the action to unrelated apt repository issues.

Consider restoring the targeted update to maintain the original focused approach:

if sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/twingate.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"; then
Suggested change
if sudo apt-get update; then
if sudo apt-get update -o Dir::Etc::sourcelist="sources.list.d/twingate.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"; then

Copilot uses AI. Check for mistakes.
else
echo "apt-get update failed, retrying ($i/$max_retries) in $delay seconds..."
sleep $delay
delay=$((delay * 2)) # exponential backoff
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The delay is doubled on each retry but only after sleeping, which means on the final (5th) retry attempt, the delay is calculated to 80 seconds but never used. Consider moving the delay calculation before the sleep, or better yet, only increment it after the sleep when there will be a next iteration:

if [ $i -lt $max_retries ]; then
  sleep $delay
  delay=$((delay * 2))
fi

This makes the logic clearer and avoids unnecessary computation on the final iteration.

Suggested change
delay=$((delay * 2)) # exponential backoff
if [ $i -lt $max_retries ]; then
delay=$((delay * 2)) # exponential backoff
fi

Copilot uses AI. Check for mistakes.
@github-actions github-actions bot removed the wontfix This will not be worked on label Dec 3, 2025
@github-actions
Copy link

This pull request is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the wontfix This will not be worked on label Dec 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants