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

Fix systemd-resolved detection. #10734

Merged

Conversation

mgoltzsche
Copy link
Contributor

@mgoltzsche mgoltzsche commented Jun 19, 2021

Previously podman failed when run in an environment where 127.0.0.53 is
the only nameserver but systemd-resolved is not used directly.
In practice this happened when podman was run within an alpine container
that used the host's network and the host was running systemd-resolved.

This fix makes podman ignore a file not found error when reading /run/systemd/resolve/resolv.conf.

Closes #10733
Follow-up of #10598
Relates to mgoltzsche/podman-static#10

To verify that this change really fixes the problem I created a Dockerfile that uses this patch here.

@mgoltzsche mgoltzsche changed the title Fix invalid systemd-resolved detection. Fix systemd-resolved detection. Jun 19, 2021
@mgoltzsche mgoltzsche force-pushed the fix-dns-detection branch 2 times, most recently from 28f539e to 58d6a6d Compare June 19, 2021 22:14
@rhatdan
Copy link
Member

rhatdan commented Jun 20, 2021

You need to add a test to make this work, or add a [NO TESTS NEEDED] to your commit message.

What value gets into the conainers resolv.conf when this happens?

Previously podman failed when run in an environment where 127.0.0.53 is
the only nameserver but systemd-resolved is not used directly.
In practice this happened when podman was run within an alpine container
that used the host's network and the host was running systemd-resolved.

This fix makes podman ignore a file not found error when reading /run/systemd/resolve/resolv.conf.

Closes containers#10733

[NO TESTS NEEDED]

Signed-off-by: Max Goltzsche <[email protected]>
@mgoltzsche
Copy link
Contributor Author

mgoltzsche commented Jun 20, 2021

I've added the resolv.conf contents to the issue description as well now:

$ docker run --network=host --rm mgoltzsche/podman:3.2.1 cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search fritz.box

I am afraid the podman code responsible for the bug cannot be covered by a unit test nicely since it would need to be able to write /run/systemd/resolve/resolv.conf. Instead it should be covered by an e2e test ideally. However I don't think it is worth setting this up in this PR. Actually for my alpine-based podman image there are a couple of scripted tests which made me discover this bug (among others that weren't discovered by tests within this repo in the past) - would you like to maintain such an image and tests with the podman project as well?

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 20, 2021
@mheon
Copy link
Member

mheon commented Jun 20, 2021 via email

Copy link
Member

@vrothberg vrothberg 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 openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 21, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 21, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99, mgoltzsche, vrothberg

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

@openshift-merge-robot openshift-merge-robot merged commit 18bf92f into containers:master Jun 21, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman wrongly detects systemd-resolved and fails
6 participants