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

kubelet: parseResolvConf: Handle "search ." #109441

Conversation

Miciah
Copy link
Contributor

@Miciah Miciah commented Apr 12, 2022

What type of PR is this?

/kind bug
/sig network

What this PR does / why we need it:

When parsing a resolv.conf file that has search ., parseResolvConf should accept the "." entry verbatim. Before this change, parseResolvConf unconditionally trimmed the "." suffix, which in the case of "." resulted in a "" entry (that is, the empty string). This empty entry could lead parseResolvConf to produce a resolv.conf file with search . Resolvers could fail to parse such a resolv.conf file from parseResolvConf, thus breaking DNS resolution in pods. After this change, parseResolvConf accepts a resolv.conf file with search . and passes the "." entry through verbatim to produce a valid resolv.conf file. The "." suffix is still trimmed for any entry that does not solely comprise ".".

Follow-up to a215a88.

  • pkg/kubelet/network/dns/dns.go (parseResolvConf): Handle a "." entry in the search path by copying it verbatim.
  • pkg/kubelet/network/dns/dns_test.go (TestParseResolvConf): Add a test case for search ..

Which issue(s) this PR fixes:

Failures related to search . in resolv.conf were reported for OKD running on Fedora in https://bugzilla.redhat.com/show_bug.cgi?id=2063414. The issue can be caused by this systemd change: systemd/systemd#17201

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Kubernetes now correctly handles "search ." in the host's resolv.conf file by preserving the "." entry in the "resolv.conf" that the kubelet writes to pods.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


When parsing a resolv.conf file that has "search .", parseResolvConf should
accept the "." entry verbatim.  Before this commit, parseResolvConf
unconditionally trimmed the "." suffix, which in the case of "." resulted
in a "" entry (that is, the empty string).  This empty entry could lead
parseResolvConf to produce a resolv.conf file with "search ".  Resolvers
could fail to parse such a resolv.conf file from parseResolvConf, thus
breaking DNS resolution in pods.  After this commit, parseResolvConf
accepts a resolv.conf file with "search ." and passes the "." entry through
verbatim to produce a valid resolv.conf file.  The "." suffix is still
trimmed for any entry that does not solely comprise ".".

Follow-up to commit a215a88.

* pkg/kubelet/network/dns/dns.go (parseResolvConf): Handle a "." entry in
the search path by copying it verbatim.
* pkg/kubelet/network/dns/dns_test.go (TestParseResolvConf): Add a test
case for "search .".
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. sig/network Categorizes an issue or PR as relevant to SIG Network. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 12, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @Miciah. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 12, 2022
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. labels Apr 12, 2022
@aojea
Copy link
Member

aojea commented Apr 12, 2022

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 12, 2022
@ehashman ehashman added this to Triage in SIG Node PR Triage Apr 12, 2022
@aojea
Copy link
Member

aojea commented Apr 12, 2022

/lgtm
/approve

/assign @thockin
I didn't new you could use search . 😄

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 12, 2022
@dcbw
Copy link
Member

dcbw commented Apr 12, 2022

/lgtm
/approve

@khenidak
Copy link
Contributor

/retest
/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, dcbw, khenidak, Miciah

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

@endocrimes
Copy link
Member

/triage accepted
/priority important-soon

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Apr 20, 2022
@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 20, 2022
@endocrimes endocrimes moved this from Triage to Done in SIG Node PR Triage Apr 20, 2022
@ehashman ehashman moved this from Done to Needs Approver in SIG Node PR Triage Apr 22, 2022
@k8s-ci-robot k8s-ci-robot merged commit d9fa563 into kubernetes:master May 4, 2022
SIG Node PR Triage automation moved this from Needs Approver to Done May 4, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.25 milestone May 4, 2022
dghubble added a commit to poseidon/typhoon that referenced this pull request Aug 31, 2022
* systemd adds "search ." to hosts /run/systemd/resolve/resolv.conf
on hosts with a fqdn hostname
* Kubelet v1.25 began propagating "search ." from the host node
into containers' `/etc/resolv.conf`
* musl-based DNS resolvers don't behave correctly when `search .`
is used in their `/etc/resolv.conf`. This breaks Alpine images
* Adapt the same workaround used by Openshift to strip the "search ."
* This only applies to bare-metal Typhoon nodes (where hostnames are
set to fqdn's), nodes on cloud platforms aren't affected in the
Typhoon configuration

Kubernetes tracking issue: kubernetes/kubernetes#112135

Rel:

* systemd/systemd#17201
* kubernetes/kubernetes#109441
* coreos/fedora-coreos-tracker#1287
* openshift/okd-machine-os#159
dghubble added a commit to poseidon/typhoon that referenced this pull request Aug 31, 2022
* systemd adds "search ." to hosts /run/systemd/resolve/resolv.conf
on hosts with a fqdn hostname
* Kubelet v1.25 began propagating "search ." from the host node
into containers' `/etc/resolv.conf`
* musl-based DNS resolvers don't behave correctly when `search .`
is used in their `/etc/resolv.conf`. This breaks Alpine images
* Adapt the same workaround used by Openshift to strip the "search ."
* This only applies to bare-metal Typhoon nodes (where hostnames are
set to fqdn's), nodes on cloud platforms aren't affected in the
Typhoon configuration

Kubernetes tracking issue: kubernetes/kubernetes#112135

Rel:

* systemd/systemd#17201
* kubernetes/kubernetes#109441
* coreos/fedora-coreos-tracker#1287
* openshift/okd-machine-os#159
dghubble added a commit to dghubble/kubernetes that referenced this pull request Sep 1, 2022
* Adapt kubernetes#109441 but
ensures that `search .` does not get propagated into containers'
/etc/resolv.conf. There is no reason to put `.` in a container's
search field and it causes issues for musl
lucab pushed a commit to lucab/kubernetes that referenced this pull request Sep 2, 2022
* Adapt kubernetes#109441 but
ensures that `search .` does not get propagated into containers'
/etc/resolv.conf. There is no reason to put `.` in a container's
search field and it causes issues for musl
elemental-lf pushed a commit to elemental-lf/typhoon that referenced this pull request Sep 2, 2022
* systemd adds "search ." to hosts /run/systemd/resolve/resolv.conf
on hosts with a fqdn hostname
* Kubelet v1.25 began propagating "search ." from the host node
into containers' `/etc/resolv.conf`
* musl-based DNS resolvers don't behave correctly when `search .`
is used in their `/etc/resolv.conf`. This breaks Alpine images
* Adapt the same workaround used by Openshift to strip the "search ."
* This only applies to bare-metal Typhoon nodes (where hostnames are
set to fqdn's), nodes on cloud platforms aren't affected in the
Typhoon configuration

Kubernetes tracking issue: kubernetes/kubernetes#112135

Rel:

* systemd/systemd#17201
* kubernetes/kubernetes#109441
* coreos/fedora-coreos-tracker#1287
* openshift/okd-machine-os#159
danielye11 pushed a commit to danielye11/kubernetes that referenced this pull request Sep 21, 2022
* Adapt kubernetes#109441 but
ensures that `search .` does not get propagated into containers'
/etc/resolv.conf. There is no reason to put `.` in a container's
search field and it causes issues for musl
Snaipe pushed a commit to aristanetworks/monsoon that referenced this pull request Apr 13, 2023
* systemd adds "search ." to hosts /run/systemd/resolve/resolv.conf
on hosts with a fqdn hostname
* Kubelet v1.25 began propagating "search ." from the host node
into containers' `/etc/resolv.conf`
* musl-based DNS resolvers don't behave correctly when `search .`
is used in their `/etc/resolv.conf`. This breaks Alpine images
* Adapt the same workaround used by Openshift to strip the "search ."
* This only applies to bare-metal Typhoon nodes (where hostnames are
set to fqdn's), nodes on cloud platforms aren't affected in the
Typhoon configuration

Kubernetes tracking issue: kubernetes/kubernetes#112135

Rel:

* systemd/systemd#17201
* kubernetes/kubernetes#109441
* coreos/fedora-coreos-tracker#1287
* openshift/okd-machine-os#159
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging this pull request may close these issues.

None yet

7 participants