Skip to content

libnetwork/resolvconf: add new KeepHostSearches/Options #2445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented May 27, 2025

Using one KeepHostServers that controls the override of nameservers, search domains and options is not good enough.

With netavark 1.15 we dropped the dns.podman search domain[1] as this always overwrote the host search domains which was not correct. However that in turn caused a new issue[2] that a container name might now get resolved to a search domain from the host first.
To fix that we either need to revert the dns.podman change or add the ndots:0 option in resolv.conf. Whatever we end up doing we will need one of KeepHostSearches or KeepHostOptions in podman to populate resolv.conf correctly so that we don't overwrite the host domains/options but still can overwrite the nameservers as we want to force aardvark-dns only as nameserver so resolvers cannot bypass it.

[1] containers/netavark#1214
[2] containers/podman#26198

Summary by Sourcery

Add dedicated flags to preserve host search domains and DNS options when generating resolv.conf and update the generation logic and tests accordingly.

New Features:

  • Introduce KeepHostSearches flag to retain host search domains.
  • Introduce KeepHostOptions flag to retain host DNS options.

Enhancements:

  • Update New() logic to respect the new flags and only append host content when requested.

Tests:

  • Extend unit tests to cover all combinations of KeepHostServers, KeepHostSearches, and KeepHostOptions.

Using one KeepHostServers that controls the override of nameservers,
search domains and options is not good enough.

With netavark 1.15 we dropped the dns.podman search domain[1] as this
always overwrote the host search domains which was not correct. However
that in turn caused a new issue[2] that a container name might now get
resolved to a search domain from the host first.
To fix that we either need to revert the dns.podman change or add the
ndots:0 option in resolv.conf. Whatever we end up doing we will need one
of KeepHostSearches or KeepHostOptions in podman to populate resolv.conf
correctly so that we don't overwrite the host domains/options but still
can overwrite the nameservers as we want to force aardvark-dns only as
nameserver so resolvers cannot bypass it.

[1] containers/netavark#1214
[2] containers/podman#26198

Signed-off-by: Paul Holzinger <[email protected]>
Copy link

sourcery-ai bot commented May 27, 2025

Reviewer's Guide

Introduces two new parameters to control preserving host DNS search domains and options when generating resolv.conf, updates the builder logic to respect these flags, and extends unit tests to validate the new behavior.

File-Level Changes

Change Details Files
Enhance Params with new KeepHostSearches and KeepHostOptions flags and update resolv.conf generation logic
  • Add KeepHostSearches and KeepHostOptions fields to Params struct with documentation
  • Modify short-circuit condition in New() to include the new flags
  • Adjust search and options append logic to use KeepHostSearches and KeepHostOptions instead of only KeepHostServers
libnetwork/resolvconf/resolv.go
Extend TestNew unit tests to cover the new flags
  • Add keepHostSearches and keepHostOptions fields to the test struct
  • Insert test cases for scenarios with each flag and both flags set
  • Update expected outputs to reflect preserved host searches and options
libnetwork/resolvconf/resolv_test.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@Luap99 Luap99 marked this pull request as ready for review May 28, 2025 14:59
@Luap99
Copy link
Member Author

Luap99 commented May 28, 2025

@mheon @baude PTAL

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Luap99 - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

openshift-ci bot commented May 28, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, sourcery-ai[bot]

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mheon
Copy link
Member

mheon commented May 28, 2025

LGTM

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