Skip to content

apt: make the apt-cacher-ng proxy non-fatal (pipelining off + reachability fallback)#10004

Open
igorpecovnik wants to merge 2 commits into
mainfrom
fix/apt-cacher-ng-fallback
Open

apt: make the apt-cacher-ng proxy non-fatal (pipelining off + reachability fallback)#10004
igorpecovnik wants to merge 2 commits into
mainfrom
fix/apt-cacher-ng-fallback

Conversation

@igorpecovnik

@igorpecovnik igorpecovnik commented Jun 19, 2026

Copy link
Copy Markdown
Member

Robustness for builds that route apt through an apt-cacher-ng proxy. Split out of fix/docker-unique-image-tag.

  • disable HTTP pipelining through the proxy — apt-cacher-ng mishandles pipelined requests, causing intermittent hash/size mismatches.
  • probe proxy reachability, fall back to direct — if the configured proxy isn't reachable, fetch directly instead of failing the whole build.

Touches main-config.sh, runners.sh, rootfs-create.sh.

Summary by CodeRabbit

  • Bug Fixes
    • Improved APT proxy validation with automatic fallback when proxy is unreachable
    • Enhanced stability by disabling HTTP pipelining when using proxy configurations

Through a caching proxy, pipelined index requests can get mismatched
against fast-changing repo indexes (e.g. beta.armbian.com), producing
"File has unexpected size" / hash-sum mismatch failures during apt-get
update. Set Acquire::http::Pipeline-Depth=0 wherever the build routes apt
through a proxy: the in-chroot apt-get (chroot_sdcard_apt_get) and the
mmdebstrap base bootstrap. Gated on MANAGE_ACNG=yes or APT_PROXY_ADDR set,
so direct (no-proxy) builds are unaffected.
A self-hosted GitHub runner injects http_proxy/https_proxy into every job
from its environment; docker.sh forwards it into the container and
main-config derives APT_PROXY_ADDR from it. When that points at a cache the
host can't reach (e.g. a LAN apt-cacher-ng baked into a VPS image), every
apt operation hard-fails with "No route to host"/"connection timed out".

Probe host:port with a 2s TCP connect before adopting APT_PROXY_ADDR
(covers both env-derived and pre-set/NetBox values); if it doesn't connect,
warn and unset it so the build goes direct instead of failing.
@igorpecovnik igorpecovnik requested a review from a team as a code owner June 19, 2026 18:29
@igorpecovnik igorpecovnik requested review from catalinii and martinayotte and removed request for a team June 19, 2026 18:29
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e3b49ca5-39f4-49b9-8a88-a0a01226a5eb

📥 Commits

Reviewing files that changed from the base of the PR and between 74f1543 and 3d91da6.

📒 Files selected for processing (3)
  • lib/functions/configuration/main-config.sh
  • lib/functions/logging/runners.sh
  • lib/functions/rootfs/rootfs-create.sh

📝 Walkthrough

Walkthrough

Adds TCP reachability validation for APT_PROXY_ADDR in do_extra_configuration, clearing it if the proxy is unreachable. Also disables HTTP pipelining (Acquire::http::Pipeline-Depth=0) in both chroot_sdcard_apt_get and the mmdebstrap bootstrap path when a proxy is active.

Changes

APT Proxy Validation and Pipeline-Depth Hardening

Layer / File(s) Summary
APT proxy TCP reachability check and auto-clear
lib/functions/configuration/main-config.sh
Parses host and port from APT_PROXY_ADDR (defaulting port to 3142), probes TCP connectivity via /dev/tcp under a short timeout, retains the address if reachable, otherwise logs a warning and unsets APT_PROXY_ADDR.
Disable HTTP pipelining for proxy-backed apt operations
lib/functions/logging/runners.sh, lib/functions/rootfs/rootfs-create.sh
Appends -o Acquire::http::Pipeline-Depth=0 to apt_params in chroot_sdcard_apt_get when MANAGE_ACNG=yes or APT_PROXY_ADDR is non-empty; adds the equivalent --aptopt flag in the mmdebstrap proxy branch of create_new_rootfs_cache_via_debootstrap.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • armbian/build#9741: Modifies do_extra_configuration in the same file to auto-derive APT_PROXY_ADDR from proxy environment variables, directly preceding the validation logic added in this PR.
  • armbian/build#9961: Modifies create_new_rootfs_cache_via_debootstrap's APT_PROXY_ADDR routing branch for mmdebstrap, the same branch extended here with the pipeline-depth flag.

Suggested labels

size/medium

Suggested reviewers

  • corestaq
  • hzyitc
  • iav
  • schwar3kat

Poem

🐇 Hop hop, before we fetch the cache,
Let's make sure the proxy's in its place!
A quick TCP knock — are you there?
No answer? We'll go direct with flair.
Pipeline depth? We'll keep it at zero,
This little bunny is a network hero! 🌐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main changes: adding HTTP pipelining disablement and proxy reachability fallback to make apt-cacher-ng proxy non-fatal.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/apt-cacher-ng-fallback

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

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

@github-actions github-actions Bot added size/small PR with less then 50 lines 08 Milestone: Third quarter release Needs review Seeking for review Framework Framework components labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

08 Milestone: Third quarter release Framework Framework components Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

1 participant