Repository navigation
fix: apply [container.dns] config defaults when Berthly starts the builder - #239
Merged
Merged
Conversation
…ilder Berthly's builder replica hard-coded DNSConfiguration(), whose default nameserver is 1.1.1.1, so builds never used the network gateway's resolver like CLI-made builders do, and ignored the [container.dns] defaults container 1.7.1 added (apple/container#1614). The builder now resolves DNS the way upstream's Builder.start does, and DNS joins the reuse/recreate check using upstream's comparison so CLI and Berthly builds don't recreate each other's builder. The first build after updating recreates an existing 1.1.1.1 builder once, which drops its build cache.
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.
Closes #233.
Problem
LiveContainerService.startBuilderContaineris Berthly's copy of upstream'sBuilder.start, kept separate on purpose (#210). Two things diverged from the CLI:1.1.1.1since the initial commit. It setconfig.dns = DNSConfiguration(), and that init's default nameserver is1.1.1.1. Upstream has always passed empty nameservers, which the runtime replaces with the network gateway's resolver (RuntimeService: "Dynamically configure the DNS nameserver from a network if no explicit configuration"). SoRUNsteps in Berthly builds skipped the gateway resolver, which the CLI's builds use.[container.dns]defaults were ignored. container 1.7.1 (Add TOML configuration for default DNS nameservers, search, options apple/container#1614) applies theseconfig.tomldefaults to the builder. Berthly's Run/Create picked them up with chore(deps): bump apple/container to 1.7.1 / containerization to 0.54.0 #238, but its builder didn't.Changes
builderDNS(defaults:)resolves DNS exactly as upstream's builder does:[container.dns]defaults, else empty nameservers, with no host-domain fallback.Flags.DNSinit. The empty init leaves the@Options in ArgumentParser's unset.definitionstate, the same trap asFlags.MachineUser. This differs from the task text in fix: apply [container.dns] config defaults when Berthly starts the builder (container 1.7.1) #233.builderNeedsRecreate..init()(1.1.1.1), copying upstream'sdnsConfigurationChanged, so a CLI build and a Berthly build don't recreate each other's builder. fix: apply [container.dns] config defaults when Berthly starts the builder (container 1.7.1) #233's task text expected "no change" there; this matches upstream instead.BuilderDNSTestsfor nil, full and partial defaults.Behavior change
192.168.64.1) by default instead of1.1.1.1, matchingcontainer build. Builds behind a VPN or split DNS may resolve differently.1.1.1.1. That drops the build cache.Testing
Local, container 1.7.1 daemon:
swiftlint lint --strict: cleanscripts/e2e.sh:ResourceJourneyTests/testBuildImageFromDockerfileThenRun(×5)testBuildWithSSHForwardingMountsAgentSocketMachineJourneyTests/testBuildMachineImageThenBootMachinebuildkitcontainer'sstartedDateand storeddnsacross runs:['1.1.1.1']) was recreated once on the first build, now with[]. The second build reused it.container build, then a Berthly build: no recreate either way. The CLI build'sRUN cat /etc/resolv.confprintednameserver 192.168.64.1.[container.dns](nameservers = ["9.9.9.9"],searchDomains = [...]) set and the daemon restarted, the builder was recreated with those values, and its/etc/resolv.confmatched. After restoring the config, the builder went back to[].nameservers: []and only fills in the gateway inside the guest, so the comparison doesn't recreate the builder on every build. I confirmed this with a plaincontainer runplusinspect.🤖 Generated with Claude Code