fix(agents-login): pin OpenAI auth host to IPv4 so codex sign-in works (musl + broken IPv6)#745
Merged
Merged
Conversation
…s (musl + broken IPv6)
codex 0.141 ships a musl static binary; in this cluster IPv6 egress is
unreachable and musl ignores /etc/gai.conf, so auth.openai.com AAAA answers make
`codex login --device-auth` fail before it tries IPv4 ("error sending request
... deviceauth/usercode", CLI exits 1). The earlier gai.conf approach was inert
for musl — remove it.
Add a `codex-auth-hosts` init container (runner image) that resolves the OpenAI
auth host A-records at pod startup and writes a complete pod-local /etc/hosts
(localhost + ipv6 loopback + pod IP/hostname + IPv4 pins), shared via an emptyDir
mounted read-only at the worker's /etc/hosts. musl reads /etc/hosts before DNS,
so codex connects over IPv4 (working egress). Dynamic resolution avoids the
staleness of static hostAliases when Cloudflare rotates IPs; CODEX_IPV4_HOSTS is
configurable if more hosts need pinning.
Scoped to agents-login sign-in; the agent-runner runtime codex needs the same
treatment separately.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 27, 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 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.
Problem
codex login --device-authfails ("CLI exited with code 1 before login completed";error sending request … auth.openai.com/api/accounts/deviceauth/usercode). codex 0.141 ships a musl static binary; this cluster has no IPv6 egress, and musl ignores/etc/gai.conf(so the earlier gai.conf fix was inert) —auth.openai.comAAAA answers make codex try IPv6 and fail with no IPv4 fallback.Fix
Remove the inert
gai.conf. Add acodex-auth-hostsinit container that resolves the OpenAI auth host A-records at pod startup and writes a complete pod-local/etc/hosts(localhost + ipv6 loopback + pod IP/hostname + IPv4 pins), shared via an emptyDir mounted read-only at the worker's/etc/hosts. musl reads/etc/hostsbefore DNS, so codex connects over IPv4. Dynamic resolution avoids statichostAliasesgoing stale on Cloudflare IP rotation;CODEX_IPV4_HOSTSis configurable.Validation
Sandbox can't reach the cluster, so this needs a real deploy. After Flux reconciles I'll verify the worker's
/etc/hostshas the IPv4 pin and thatcodex login --device-authreaches the user-code step. (The agent-runner runtime codex needs the same treatment — separate follow-up.)🤖 Generated with Claude Code