Skip to content
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

netavark ,aardvark: accept and populate custom dns_servers for containers #452

Merged

Conversation

flouthoc
Copy link
Collaborator

@flouthoc flouthoc commented Oct 17, 2022

Netavark now accepts dns_servers as part of NetworkOptions which contains list of comma seperated custom DNS servers for containers. Aardvark-dns will use these as resolver for a specific container instead of host's default resolver.

Implements feature here and needs: containers/aardvark-dns#240

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 17, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc

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

@flouthoc flouthoc marked this pull request as draft October 17, 2022 08:40
flouthoc added a commit to flouthoc/common that referenced this pull request Oct 17, 2022
Netavark now accets `dns_servers` for each container which allows
containers to use custom DNS servers as resolvers instead of falling
back to host's resolver.

Following field allows callers to libnetwork to pass newly added field
to `netavark` and `aarvark-dns`

Actual feature implemented
* containers/aardvark-dns#240
* containers/netavark#452

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/common that referenced this pull request Oct 17, 2022
Netavark now accets `dns_servers` for each container which allows
containers to use custom DNS servers as resolvers instead of falling
back to host's resolver.

Following field allows callers to libnetwork to pass newly added field
to `netavark` and `aarvark-dns`

Actual feature implemented
* containers/aardvark-dns#240
* containers/netavark#452

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/podman that referenced this pull request Oct 17, 2022
Aardvark-dns and netavark now accepts custom DNS servers for containers
via new config field `dns_servers`. New field allows containers to use
custom resolvers instead of host's default resolvers.

Following commit instruments libpod to pass these custom DNS servers set
via `--dns` or central config to the network stack.

Depends-on:
* Common: containers/common#1189
* Netavark: containers/netavark#452
* Aardvark-dns: containers/aardvark-dns#240

[NO NEW TESTS ADDED]
[NO TESTS ADDED]

Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/common that referenced this pull request Oct 17, 2022
Netavark now accets `dns_servers` for each container which allows
containers to use custom DNS servers as resolvers instead of falling
back to host's resolver.

Following field allows callers to libnetwork to pass newly added field
to `netavark` and `aarvark-dns`

Actual feature implemented
* containers/aardvark-dns#240
* containers/netavark#452

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <[email protected]>
src/dns/aardvark.rs Outdated Show resolved Hide resolved
src/commands/teardown.rs Outdated Show resolved Hide resolved
test/100-bridge-iptables.bats Show resolved Hide resolved
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Also this should return the passed in the servers in the response when dns is disabled so podman does not need to check for anything and can just write the result to resolv.conf.

@flouthoc flouthoc force-pushed the container-dns-servers branch from 5b4a3b4 to a590eb8 Compare October 17, 2022 10:49
@flouthoc
Copy link
Collaborator Author

Also this should return the passed in the servers in the response when dns is disabled so podman does not need to check for anything and can just write the result to resolv.conf.

I think what you want is already handled here, podman is already aware before spawning netavark if network has dns_enabled or not ( containers/podman#16175 )

src/dns/aardvark.rs Outdated Show resolved Hide resolved
src/network/bridge.rs Outdated Show resolved Hide resolved
@Luap99
Copy link
Member

Luap99 commented Oct 17, 2022

Also this should return the passed in the servers in the response when dns is disabled so podman does not need to check for anything and can just write the result to resolv.conf.

I think what you want is already handled here, podman is already aware before spawning netavark if network has dns_enabled or not ( containers/podman#16175 )

Exactly podman should never check for dns enabled, netavark should provide the exact servers that end up in resolv.conf. The podman check is much more costly since it requires a network inspect each time with locking,etc...

@flouthoc
Copy link
Collaborator Author

Also this should return the passed in the servers in the response when dns is disabled so podman does not need to check for anything and can just write the result to resolv.conf.

I think what you want is already handled here, podman is already aware before spawning netavark if network has dns_enabled or not ( containers/podman#16175 )

Exactly podman should never check for dns enabled, netavark should provide the exact servers that end up in resolv.conf. The podman check is much more costly since it requires a network inspect each time with locking,etc...

This is added to status_block in latest commit.

@flouthoc flouthoc marked this pull request as ready for review October 17, 2022 15:00
@flouthoc flouthoc force-pushed the container-dns-servers branch from 89ecfe3 to 6ec2f48 Compare October 17, 2022 16:27
…ners

Netavark now accepts `dns_servers` as part of `NetworkOptions` which
contains list of comma seperated custom DNS servers for containers.
Aardvark-dns will use these as resolver for a specific container instead
of host's default resolver.

Implements feature here: containers/aardvark-dns#240

Signed-off-by: Aditya R <[email protected]>
@flouthoc flouthoc force-pushed the container-dns-servers branch from 6ec2f48 to f6e0258 Compare October 17, 2022 16:33
@flouthoc flouthoc requested review from Luap99, mheon and baude October 17, 2022 16:35
@flouthoc
Copy link
Collaborator Author

@Luap99 @baude @mheon Could you PTAL.

let data = format!(
"{} {} {} {}\n",
entry.container_id, ipv4s, ipv6s, container_names
"{} {} {} {}{}\n",
Copy link
Member

Choose a reason for hiding this comment

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

Where are we prepending a space so that this is separated from the previous field?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@flouthoc flouthoc requested a review from mheon October 18, 2022 14:06
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

# check aardvark config and running
run_helper cat "$NETAVARK_TMPDIR/config/aardvark-dns/podman1"
assert "${lines[0]}" =~ "10.89.3.1,fd10:88:a::1" "aardvark set to listen to all IPs"
assert "${lines[1]}" =~ "^[0-9a-f]{64} 10.89.3.2 fd10:88:a::2 somename 8.8.8.8$" "aardvark config's container"
Copy link
Member

Choose a reason for hiding this comment

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

We should also test at least two custom servers but since we cannot test it right now I fine with keeping like this and add a second test for this once aardvark is ready

@mheon
Copy link
Member

mheon commented Oct 18, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Oct 18, 2022
@openshift-merge-robot openshift-merge-robot merged commit 706601a into containers:main Oct 18, 2022
flouthoc added a commit to flouthoc/podman that referenced this pull request Jan 22, 2023
Aardvark-dns and netavark now accepts custom DNS servers for containers
via new config field `dns_servers`. New field allows containers to use
custom resolvers instead of host's default resolvers.

Following commit instruments libpod to pass these custom DNS servers set
via `--dns` or central config to the network stack.

Depends-on:
* Common: containers/common#1189
* Netavark: containers/netavark#452
* Aardvark-dns: containers/aardvark-dns#240

Signed-off-by: Aditya R <[email protected]>
flouthoc added a commit to flouthoc/podman that referenced this pull request Jan 22, 2023
…server

After containers/netavark#452 `netavark` is
incharge of deciding `custom_dns_servers` if any so lets honor that and
libpod should not set these manually.

This also ensures docker parity
Podman populates container's `/etc/resolv.conf` with custom DNS servers ( specified via `--dns` or `dns_server` in containers.conf )
even when container is connected to a network where `dns_enabled` is `true`.

Current behavior does not matches with docker, hence following commit ensures that podman only populates custom DNS server when container is not connected to any network where DNS is enabled and for the cases where `dns_enabled` is `true`
the resolution for custom DNS server will happen via ( `aardvark-dns` or `dnsname` ).

Reference: https://docs.docker.com/config/containers/container-networking/#dns-services
Closes: containers#16172

Signed-off-by: Aditya R <[email protected]>
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