Skip to content

Backfill interface DNS fields from host resolv.conf#4994

Open
willmyrs wants to merge 1 commit into
aws:devfrom
willmyrs:backfill-dns
Open

Backfill interface DNS fields from host resolv.conf#4994
willmyrs wants to merge 1 commit into
aws:devfrom
willmyrs:backfill-dns

Conversation

@willmyrs

@willmyrs willmyrs commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Summary

When the ACS payload omits DomainNameServers, netlib copies the host's resolv.conf into the task volume but leaves the interface struct fields empty. This PR populates them from the copied content so the model reflects the DNS config that containers actually use.

Implementation details

In createResolvConf (common_linux.go), after copying the host's resolv.conf to the netns directory, parse the content and backfill iface.DomainNameServers and iface.DomainNameSearchList.

The parser (parseResolvConf) follows resolv.conf(5) using the same rules as Go's net.dnsReadConfig:

  • Lines starting with ; or # are comments
  • Fields split on any whitespace
  • nameserver contributes one IP per line
  • Last search directive wins

Testing

Unit tests for parseResolvConf covering:

  • Go stdlib test fixture (IPv4, IPv6, zone-scoped nameservers, mixed directives)
  • Semicolon and hash comments
  • Tabs and multiple spaces as separators
  • Last-search-wins semantics
  • Empty input and unknown directives

New tests cover the changes: yes

Description for the changelog

Enhancement - Populate interface DNS fields when resolv.conf is copied from host

Additional Information

Does this PR include breaking model changes? If so, Have you added transformation functions?

No. Existing fields are populated where they were previously nil.

Does this PR include the addition of new environment variables in the README?

No.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

When the ACS payload omits DomainNameServers, netlib copies the host's
resolv.conf but left the interface struct fields empty.

Parse the copied content back into the interface fields. The parser
follows resolv.conf(5) using the same rules as Go's net.dnsReadConfig
(comment handling, whitespace splitting, last-search-wins).
@willmyrs willmyrs marked this pull request as ready for review June 8, 2026 16:01
@willmyrs willmyrs requested a review from a team as a code owner June 8, 2026 16:01
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.

4 participants