Skip to content

Conversation

@Luap99
Copy link
Member

@Luap99 Luap99 commented Jun 3, 2025

Backport of #2445

Summary by Sourcery

Backport support for preserving host DNS search domains and options via new flags, update resolv.conf generation logic and tests accordingly, and bump the build version to v0.63.1.

New Features:

  • Add KeepHostSearches and KeepHostOptions flags to preserve host resolv.conf searches and options

Enhancements:

  • Update New() logic to honor the new flags in both the fast-path build and the merging of host entries
  • Revise Params struct fields and documentation to include the new flags

Build:

  • Bump version constant to "0.63.1"

Tests:

  • Extend TestNew with scenarios for keeping host searches and options

Luap99 added 2 commits June 3, 2025 16:37
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]>
(cherry picked from commit b4bf1f2)
Signed-off-by: Paul Holzinger <[email protected]>
Signed-off-by: Paul Holzinger <[email protected]>
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

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

The pull request process is described here

Details 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

@sourcery-ai
Copy link

sourcery-ai bot commented Jun 3, 2025

Reviewer's Guide

Backports support for preserving host resolv.conf search domains and options by introducing two new flags, updates the generation logic to respect them, extends test coverage accordingly, and bumps the library version to v0.63.1.

Sequence Diagram: resolv.conf Generation with KeepHost* Flags

sequenceDiagram
    participant Caller
    participant "resolvconf.New(params)" as NewFunc
    participant "Host /etc/resolv.conf" as HostFile
    participant "build()" as BuildFunc

    Caller->>NewFunc: Invoke New(params)

    alt User provides all DNS settings (Nameservers, Searches, Options) AND<br/>KeepHostServers, KeepHostSearches, KeepHostOptions are all false
        NewFunc->>NewFunc: Prepare DNS settings from params only
        NewFunc->>BuildFunc: build(Path, prepared_Nameservers, prepared_Searches, prepared_Options)
    else
        NewFunc->>HostFile: Read host DNS configuration
        HostFile-->>NewFunc: host_dns_config

        NewFunc->>NewFunc: Merge params settings with host_dns_config<br/>(honoring KeepHostServers, KeepHostSearches, KeepHostOptions)
        NewFunc->>BuildFunc: build(Path, merged_Nameservers, merged_Searches, merged_Options)
    end
Loading

Updated Class Diagram for Params Struct in resolvconf

classDiagram
    class Params {
      +IPv6Enabled: bool
      +KeepHostServers: bool
      +KeepHostSearches: bool
      +KeepHostOptions: bool
      +Nameservers: []string
      +Searches: []string
      +Options: []string
    }
Loading

File-Level Changes

Change Details Files
Introduce flags to preserve host searches and options
  • Add KeepHostSearches and KeepHostOptions boolean fields to Params
  • Update struct comments to explain new flags’ behavior
  • Expose new flags in Params initialization
libnetwork/resolvconf/resolv.go
Respect new keep flags in resolv.conf generation logic
  • Include KeepHostSearches and KeepHostOptions in short-circuit condition
  • Use KeepHostSearches for appending host search domains
  • Use KeepHostOptions for appending host options
libnetwork/resolvconf/resolv.go
Extend test coverage for search and option preservation
  • Expand test struct to include keepHostSearches and keepHostOptions fields
  • Add new test cases covering combinations of the two flags
  • Adjust existing test expectations to align with updated behavior
libnetwork/resolvconf/resolv_test.go
Bump library version to v0.63.1
  • Update Version constant from "0.63.0" to "0.63.1"
version/version.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

@openshift-ci openshift-ci bot added the approved label Jun 3, 2025
@Luap99
Copy link
Member Author

Luap99 commented Jun 3, 2025

@mheon @TomSweeneyRedHat PTAL

Copy link
Member

@ashley-cui ashley-cui left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 3, 2025

@ashley-cui: changing LGTM is restricted to collaborators

Details

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

The mechanism (backport, version update) LGTM.

I’m not sure where the backport decision is made, but Ashley already approved the whole PR, so…

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 3, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit bc8f52f into containers:v0.63 Jun 3, 2025
11 checks passed
@TomSweeneyRedHat
Copy link
Member

@Luap99 can you tag a Jira card here that is addressed (at least partially) by this fix please?

@Luap99
Copy link
Member Author

Luap99 commented Jun 4, 2025

@Luap99 can you tag a Jira card here that is addressed (at least partially) by this fix please?

Why? This is not a RHEL release so it should not need that? In any case eventually with podman changes from containers/podman#26221 this would fix https://issues.redhat.com/browse/RHEL-83787

@Luap99 Luap99 deleted the v0.63 branch June 4, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants