Skip to content

fix(agents-login): pin OpenAI auth host to IPv4 so codex sign-in works (musl + broken IPv6)#745

Merged
ExtraToast merged 1 commit into
mainfrom
fix/agents-login-codex-ipv4-hosts
Jun 27, 2026
Merged

fix(agents-login): pin OpenAI auth host to IPv4 so codex sign-in works (musl + broken IPv6)#745
ExtraToast merged 1 commit into
mainfrom
fix/agents-login-codex-ipv4-hosts

Conversation

@ExtraToast

Copy link
Copy Markdown
Owner

Problem

codex login --device-auth fails ("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.com AAAA answers make codex try IPv6 and fail with no IPv4 fallback.

Fix

Remove the inert gai.conf. Add a codex-auth-hosts init 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/hosts before DNS, so codex connects over IPv4. Dynamic resolution avoids static hostAliases going stale on Cloudflare IP rotation; CODEX_IPV4_HOSTS is configurable.

Validation

Sandbox can't reach the cluster, so this needs a real deploy. After Flux reconciles I'll verify the worker's /etc/hosts has the IPv4 pin and that codex login --device-auth reaches the user-code step. (The agent-runner runtime codex needs the same treatment — separate follow-up.)

🤖 Generated with Claude Code

…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>
@ExtraToast ExtraToast merged commit 812fffd into main Jun 27, 2026
22 checks passed
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.

1 participant