Skip to content

fix: DNS resolution for Ubuntu 24 stemcells - #9565

Merged
taylorsilva merged 1 commit into
concourse:masterfrom
Kump3r:master
May 7, 2026
Merged

taylorsilva merged 1 commit into
concourse:masterfrom
Kump3r:master

Conversation

@Kump3r

@Kump3r Kump3r commented May 7, 2026

Copy link
Copy Markdown
Contributor

Fix DNS resolution on Ubuntu 24 (Noble) stemcells

Problem

On Concourse workers with Ubuntu Noble (24.04) stemcells, container DNS resolution was failing with:

dial tcp: lookup some.address.com on [::1]:53: read udp [::1]:58930->[::1]:53: read: connection refused

Root Cause

Upstream resolv.conf behavior changed between Ubuntu Jammy and Noble:

  • Jammy (22.04LTS): /etc/resolv.conf directly contained a routable DNS IP (e.g., nameserver 172.18.96.9)
  • Noble (24.04LTS): /etc/resolv.conf is now a systemd-resolved stub resolver symlink with only loopback nameservers:
    nameserver 127.0.0.53
    nameserver ::1
    

Concourse's DNS parser issue:

The regex patterns in worker/runtime/resolvconf_parser.go only matched IPv4 loopback (127.0.0.x), not IPv6 loopback (::1). When systemd-resolved's stub was detected as loopback-only, the parser would:

  1. Fall back to localip.LocalIP() (the worker VM IP)
  2. Write that to the container's /etc/resolv.conf
  3. Containers then tried to query that VM IP, which was unreachable from the container network namespace
  4. This cascaded to DNS defaulting to [::1]:53, which didn't exist, causing connection refused

Solution

Updated worker/runtime/resolvconf_parser.go to:

  1. Add IPv6 loopback to regex patterns — both 127.0.0.x and ::1 are now recognized as loopback and handled uniformly
  2. Implement systemd-resolved upstream fallback — when host /etc/resolv.conf is loopback-only on Noble, parser now:
    • Attempts to read upstream resolvers from /run/systemd/resolve/resolv.conf
    • Uses those if available (correct for Noble)
    • Falls back to worker IP only if upstream file is unavailable (backward compatibility for older/edge cases)
  3. Preserve non-loopback passthrough — if /etc/resolv.conf contains any usable non-loopback nameserver, it passes through unchanged (Jammy behavior preserved)

Changes

Modified Files

  • worker/runtime/resolvconf_parser.go

    • Updated loopbackNameserverRegexp to match both 127.0.0.x and ::1 with multiline mode
    • Updated loopbackIPRegexp to strip both IPv4 and IPv6 loopback
    • Added systemdResolvedResolvConfPath constant pointing to systemd upstream resolv.conf
    • Refactored logic to:
      • Parse entries first, return immediately if any valid nameserver exists
      • Only attempt fallbacks when all nameservers are loopback
      • Try systemd-resolved upstream file before falling back to worker IP
    • Added testable hooks (readFileFn, localIPFn) for deterministic testing without exporting test-only APIs
  • worker/runtime/resolvconf_parser_internal_test.go (new file)

    • Tests systemd-resolved upstream fallback behavior (Noble scenario)
    • Tests local IP fallback when upstream is unavailable (backward compatibility)
    • Uses internal package scope to access unexported test helpers

Why Separate Test File?

The internal tests need access to unexported helpers (readFileFn, localIPFn, default path constants) to stub I/O deterministically. Placing them in package runtime (not runtime_test) allows this without polluting the public API. The existing resolvconf_parser_test.go remains in package runtime_test for black-box behavior validation.

Testing

  • ✅ Validated with manually built binary on Ubuntu Noble (24.04) stemcell — containers now resolve DNS correctly
  • ✅ Validated backward compatibility on Ubuntu Jammy (22.04) stemcell — existing behavior unchanged
  • ✅ All existing runtime tests pass: ginkgo -r ./worker/runtime
  • ✅ New internal tests confirm both fallback paths work correctly

Behavior Summary

Scenario Before After
Jammy with upstream DNS in /etc/resolv.conf ✓ Passes through ✓ Passes through
Noble with systemd stub only ✗ Tries [::1]:53 → connection refused ✓ Uses systemd upstream resolvers
Edge case: No upstream available Uses worker IP Uses worker IP (fallback)

Backward Compatibility

  • Jammy and older stemcells with routable DNS IPs in /etc/resolv.conf are unaffected
  • If systemd upstream file is missing (legacy/custom setups), behavior reverts to worker IP (same as before)
  • No configuration changes required; this is fully transparent

Related Issue

This fixes DNS resolution failures introduced by Ubuntu 24's systemd-resolved stub resolver changes for Concourse workers on Noble stemcells.

@Kump3r
Kump3r requested a review from a team May 7, 2026 12:13
@linux-foundation-easycla

linux-foundation-easycla Bot commented May 7, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: Kump3r / name: Kump3r (204ffe2)

@Kump3r

Kump3r commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

Well the containerd-integration is failing due to the flakey issue #9449
@taylorsilva can we prioritise this as newer ubuntu stemcells are impacted. Would it be possible to include this in v8.2.0?

@taylorsilva

Copy link
Copy Markdown
Member

Thanks Kalin! Fine with getting this into v8.2.0

Yeah that flaky test error is so weird. I re-deployed the workers last night which always causes this issue. I don't know why, but when re-deployed we'll see this error, but after a few hours it just stops, as if someone ran insmod to install the missing module(s) 😕

@taylorsilva

Copy link
Copy Markdown
Member

Yup and now it just worked! Weirdddddd

Will review and merge shortly.

@taylorsilva
taylorsilva merged commit 4d4d77e into concourse:master May 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants