Skip to content

fix(microsandbox): wait for name lookups, fall back to public resolvers and retry downloads - #355

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-ruvgn2
Oct 11, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-ruvgn2

Conversation

@adeelahmad

@adeelahmad adeelahmad commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

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, downloading opentelemetry-sdk from 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 by run.sh): dns_ready waits 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 as resolv.conf.sandbox), from the 10th it tries this machine's again, and after 15 it gives up with the reason. retry reruns a step up to 3 times, rechecking lookups and setting UV_CONCURRENT_DOWNLOADS=4. dns_restore puts 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 sync and pnpm install run through retry.
  • 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.sh runs 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 in python:3.12-slim-bookworm.

End to end, the whole run.sh (lean) ran in that image against the same resolver. It logged This 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 logged Lens is starting on port 3000; /api/v1/auth/status then answered {"setup_required":true,...}.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (shellcheck clean on run.sh, dns.sh, test-dns.sh, install.sh).
  • I added or updated tests: test-dns.sh, run by the new Nx project microsandbox (lint, test in Docker) and inside the real microsandbox in the Install workflow.
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/microsandbox.md Name lookups, docs/contributing.md projects table).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: the build gets past lookups that fail in the sandbox; merged on green CI.
  • Agents: n/a, this runs inside the sandbox at install and start, before Lens is up.
  • Zero setup: nothing to do; the fallback is automatic.
  • Fewest clicks: same one line.
  • Configurable: LENS_DNS_FALLBACK is an install-line setting like LENS_PORT, kept in .env; the default works without it.
  • Light: no new packages (python3 is in the base image).
  • Private and secure: the public resolvers are used only when this machine's don't answer in the sandbox, it says so in the log, and they can be turned off. Downloads stay verified (uv.lock hashes, the pnpm lockfile, apt signatures), so a spoofed answer can't change what installs. No new surface a user can reach, so no threat-model change.
  • Cost: n/a, no model calls.
  • User decides: defaults unchanged where this machine's DNS works; the fallback only replaces a failed install.
  • Upgrades: no stored-data change; existing sandboxes get it on the next start.
  • Honest: docs describe exactly when it switches and back.
  • Tests, docs and generated files updated.
  • Open standards; no new dependencies.
  • Reported with evidence. Refine later: microsandbox reads the host's resolvers once at sandbox start, so a Mac that changes networks mid-install can still hit this until the next start; msb run --dns-nameserver could 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 edits run.sh around uv sync and pnpm install, so whichever merges second takes both changes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KSHsQ2Sm6ACRZJoj8zMQ4p

…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
@adeelahmad adeelahmad self-assigned this Oct 11, 2026
@adeelahmad
adeelahmad merged commit b8b4cde into main Oct 11, 2026
17 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-ruvgn2 branch October 11, 2026 07:54
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