Skip to content

Add apt retries, optional mirror for debootstrap#587

Merged
selzoc merged 1 commit into
ubuntu-jammyfrom
add-ubuntu-server-resilience
Apr 30, 2026
Merged

Add apt retries, optional mirror for debootstrap#587
selzoc merged 1 commit into
ubuntu-jammyfrom
add-ubuntu-server-resilience

Conversation

@selzoc

@selzoc selzoc commented Apr 30, 2026

Copy link
Copy Markdown
Member

We've observed many issues over the years with ubuntu's apt servers, including lots of temporary 503's.
This commit will

  1. Use an in-gcp mirror for debootstrap, which should be fast (it
    doesn't run on ubuntu's infrastructure at all)
  2. Add retries for all apt-get invocations during the build of both the
    os-image, and the iaas-specific builds - details below

Acquire::Retries=10 If a download fails (including transient HTTP errors like 503), apt retries that fetch up to 10 times before giving up on that URL. Without this, one bad response often aborts the whole apt-get run.

Acquire::Retries::Delay=true Between retries, apt waits with increasing delay (backoff) instead of hammering the server immediately. On Jammy this is the “delay between retries” behavior (apt ≥ 2.0). Cumulatively with Retries=10, you get many attempts spread over time, which helps when snapshot.ubuntu.com is briefly overloaded rather than hard-down.

Acquire::http::Timeout=120 and Acquire::https::Timeout=120 Each individual HTTP/HTTPS connection apt opens to a mirror can block for at most 120 seconds before apt treats it as stuck and fails that attempt (which can then trigger a retry if retries remain).

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@selzoc has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 27 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 677f0aa3-3348-43af-9970-dd0a90f12188

📥 Commits

Reviewing files that changed from the base of the PR and between 4d8c0c7 and 2b41de6.

📒 Files selected for processing (8)
  • bosh-stemcell/lib/bosh/stemcell/builder_options.rb
  • bosh-stemcell/spec/bosh/stemcell/builder_options_spec.rb
  • ci/pipelines/builder.yml
  • ci/tasks/os-images/build.yml
  • stemcell_builder/lib/prelude_apply.bash
  • stemcell_builder/lib/prelude_fips.bash
  • stemcell_builder/stages/base_debootstrap/apply.sh
  • stemcell_builder/stages/base_debootstrap/config.sh

Walkthrough

This change updates the Ubuntu mirror configuration mechanism across the stemcell build system. It replaces the UBUNTU_MIRROR environment variable with UBUNTU_DEBOOTSTRAP_MIRROR in builder options, CI pipeline configuration, and debootstrap stage scripts. Additionally, it introduces APT_RETRY_OPTS for apt operations to handle transient network issues with retry logic and timeouts. The debootstrap mirror parameter is now dynamically set from the environment variable instead of using a hardcoded empty string.

Suggested reviewers

  • mkocher
  • aramprice
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The PR description explains the motivation, implementation details (apt retry settings with specific values), and rationale, but does not follow the merge-forward branching strategy template. Clarify which branch this PR targets and confirm it follows the merge-forward strategy documented in the template (create PR into oldest branch first, then merge forward).
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding apt retries and an optional mirror for debootstrap configuration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-ubuntu-server-resilience

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 56 minutes and 27 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

We've observed many issues over the years with ubuntu's apt servers,
including lots of temporary 503's.
This commit will
1) Use an in-gcp mirror for debootstrap, which should be fast (it
   doesn't run on ubuntu's infrastructure at all)
2) Add retries for all apt-get invocations during the build of both the
   os-image, and the iaas-specific builds - details below

Acquire::Retries=10 If a download fails (including transient HTTP errors
like 503), apt retries that fetch up to 10 times before giving up on
that URL. Without this, one bad response often aborts the whole apt-get
run.

Acquire::Retries::Delay=true Between retries, apt waits with increasing
delay (backoff) instead of hammering the server immediately. On Jammy
this is the “delay between retries” behavior (apt ≥ 2.0). Cumulatively
with Retries=10, you get many attempts spread over time, which helps
when snapshot.ubuntu.com is briefly overloaded rather than hard-down.

Acquire::http::Timeout=120 and Acquire::https::Timeout=120 Each
individual HTTP/HTTPS connection apt opens to a mirror can block for at
most 120 seconds before apt treats it as stuck and fails that attempt
(which can then trigger a retry if retries remain).

ai-assisted=yes
[TNZ-88995]
@selzoc selzoc force-pushed the add-ubuntu-server-resilience branch from 4d8c0c7 to 2b41de6 Compare April 30, 2026 20:57
@selzoc selzoc merged commit 1dbe63b into ubuntu-jammy Apr 30, 2026
12 checks passed
@aramprice aramprice deleted the add-ubuntu-server-resilience branch April 30, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants