core: APT/APK Mirror Fallback for CDN Failures#13316
Merged
Conversation
Improve robustness of package updates and installs by adding CDN/mirror fallback logic for Alpine and Debian/Ubuntu workflows. - misc/alpine-install.func: update_os() now attempts apk -U upgrade and, on failure, iterates a shuffled list of alternate Alpine mirrors, writes /etc/apk/repositories, tests the mirror and falls back with clear warnings/errors if none succeed. - misc/build.func: when apk add inside an Alpine container fails, run an in-container mirror scan that rewrites /etc/apk/repositories and retries apk update/add against multiple mirrors. Added a check to inject public DNS (8.8.8.8/1.1.1.1) into containers when APT repo DNS resolution fails. - misc/build.func (Debian/Ubuntu path): expanded apt-get failure handling to detect the failing mirror, then run a multi-phase mirror scanner (global → primary → regional), detect hash/SSL errors, and prompt the user for a custom mirror if automatic attempts fail. - misc/install.func: added apt_update_safe() implementing the apt-get update fallback logic (mirror lists, regional selection by timezone, reachable scanning, hash/SSL detection, and user prompt), returning failure if all mirrors fail. These changes aim to mitigate CDN outages, broken CDNs/mirrors, or DNS issues during container builds and OS updates, improving reliability and providing clear messages and fallbacks when automatic fixes are exhausted.
michelroegl-brunner
approved these changes
Mar 26, 2026
tremor021
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✍️ Description
Container creation fails when Debian/Ubuntu/Alpine CDN mirrors are unreachable, serve corrupted data (hash mismatch), or lack valid SSL certificates — especially in Asia/India.
Solution
Three-phase mirror fallback: Global → Primary → Regional → Manual prompt. Scans TCP reachability first, picks 3 random working mirrors per phase. Detects Debian vs Ubuntu automatically and uses the correct mirror pool. Alpine gets its own 8-mirror fallback.
Key decisions:
Example:
💡 apt-get update failed (deb.debian.org), trying alternate mirrors... 💡 Attempting mirror: ftp.jp.debian.org ⚠️ Mirror ftp.jp.debian.org failed (SSL/certificate error) 💡 Attempting mirror: ftp.it.debian.org ✔️ CDN set to ftp.it.debian.org: tests passed ✔️ Customized LXC Container🔗 Related Issue
https://discord.com/channels/1302816934508630047/1486700783343894619
✅ Prerequisites (X in brackets)
🛠️ Type of Change (X in brackets)
README,AppName.md,CONTRIBUTING.md, or other docs.