Repository navigation
fix(microsandbox): wait for name lookups, fall back to public resolvers and retry downloads - #355
Merged
Merged
Conversation
…rs and retry downloads The first build in a microsandbox stopped at uv sync with "dns error ... No address associated with hostname" when this machine's resolvers didn't answer inside the sandbox. run.sh now sources microsandbox/dns.sh: it waits for the names it downloads from, switches to public resolvers (1.1.1.1, 9.9.9.9; LENS_DNS_FALLBACK changes or turns that off) after about 15 seconds without an answer, runs apt, uv and pnpm up to three times with fewer downloads at once after a failure, and goes back to this machine's resolvers when Lens starts if they answer by then. test-dns.sh reproduces the failure with a resolver that has no address for any name and checks the fallback, the switch back and giving up with the reason; it runs in the base image (Nx project microsandbox) and inside a real microsandbox in the Install workflow. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KSHsQ2Sm6ACRZJoj8zMQ4p
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Adeel · project thread
Description
Before: the first build in a microsandbox stopped at the backend's packages with
dns error ... failed to lookup address information: No address associated with hostname(uv, downloadingopentelemetry-sdkfrom files.pythonhosted.org), and Lens never started.After: the sandbox waits for the names it downloads from. When this machine's resolvers don't answer them inside the sandbox, it looks names up with public resolvers (1.1.1.1 and 9.9.9.9) after about 15 seconds and says so in its log. Each download step (apt, uv, pnpm) runs up to three times, with fewer downloads at once after a failure. When Lens starts it goes back to this machine's resolvers if they answer by then, so names on the local network still resolve. If nothing answers, it stops with the name and the reason.
Motivation and Context
microsandbox answers the guest's lookups itself, from the host's resolvers read when the sandbox starts (its
DnsForwarder). An answer with no address for a name (what glibc reports as "No address associated with hostname") is final for the guest's resolver, so uv's five retries all failed the same way. The exact trigger on that Mac can't be reproduced here (GitHub's macOS runners can't run microVMs), so the fix doesn't depend on it: the sandbox checks lookups itself and uses another path when this machine's resolvers don't work there. Queries to a public resolver go straight to it, because microsandbox forwards a lookup aimed at a specific server to that server.How:
microsandbox/dns.sh(sourced byrun.sh):dns_readywaits for deb.debian.org, files.pythonhosted.org and registry.npmjs.org. From the 5th failed try it writes the public resolvers to/etc/resolv.conf(keeping the sandbox's own asresolv.conf.sandbox), from the 10th it tries this machine's again, and after 15 it gives up with the reason.retryreruns a step up to 3 times, rechecking lookups and settingUV_CONCURRENT_DOWNLOADS=4.dns_restoreputs this machine's resolvers back when they answer.run.sh:apt-get update --error-on=any, so a failed index download fails the step and gets retried instead of turning into "Unable to locate package". apt,uv syncandpnpm installrun throughretry.install.sh:LENS_DNS_FALLBACK(comma-separated, empty for none) on the install line is kept in.env.Steps to reproduce (if appropriate):
microsandbox/test-dns.shruns a resolver that has no address for any name and reproduces the exact error (files.pythonhosted.org: No address associated with hostname), then checks the fallback, the switch back and giving up. It passed here inpython:3.12-slim-bookworm.End to end, the whole
run.sh(lean) ran in that image against the same resolver. It loggedThis machine's DNS doesn't answer in the sandbox (deb.debian.org: No address associated with hostname); looking names up with 1.1.1.1 9.9.9.9 instead, installed the packages, built the backend and the web app, and loggedLens is starting on port 3000;/api/v1/auth/statusthen answered{"setup_required":true,...}.Types of changes
!in the title)Checklist:
run.sh,dns.sh,test-dns.sh,install.sh).test-dns.sh, run by the new Nx projectmicrosandbox(lint,testin Docker) and inside the real microsandbox in the Install workflow.docs/accordingly (docs/microsandbox.mdName lookups,docs/contributing.mdprojects table).## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
LENS_DNS_FALLBACKis an install-line setting likeLENS_PORT, kept in.env; the default works without it.msb run --dns-nameservercould pin them from install.sh if that shows up. fix(install): restart a microsandbox rerun cleanly and stop waiting with the logs and why #327 (the rerun fix) also editsrun.sharounduv syncandpnpm install, so whichever merges second takes both changes.🤖 Generated with Claude Code
https://claude.ai/code/session_01KSHsQ2Sm6ACRZJoj8zMQ4p