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: append options to pod if there are multi options in /etc/resolv.conf #112414

Merged
merged 2 commits into from Sep 30, 2022

Conversation

pacoxu
Copy link
Member

@pacoxu pacoxu commented Sep 13, 2022

What type of PR is this?

/kind bug

What this PR does / why we need it:

options timeout:1 
options attempts:3

kubelet will be loading above reslov.conf as below.

options timeout:1 attempts:3

Which issue(s) this PR fixes:

Fixes #112323

Special notes for your reviewer:

The feature was added by #54773 long time ago by @phsiao following the design kubernetes/community#1276.

However, per #91052 (comment) as Tim pointed out that

If you want to specify multiple options, combine them on a single line in resolv.conf

we may keep it as.

I tried centos/ubuntu, both will append extra options to the options list and overwrite them if it already exists by the later settings.

If we want to keep the same behavior, we can accept this pr as a bug fix.

Does this PR introduce a user-facing change?

kubelet: when there are multi option lines in /etc/resolv.conf, merge all options into one line in a pod with the `Default` DNS policy.

Design details

- [KEP]: https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/504-configurable-pod-dns#proposal

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 13, 2022
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/network Categorizes an issue or PR as relevant to SIG Network. sig/node Categorizes an issue or PR as relevant to SIG Node. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Sep 13, 2022
@k8s-ci-robot
Copy link
Contributor

@pacoxu: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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 the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Sep 13, 2022
@pacoxu pacoxu added this to Triage in SIG Node PR Triage Sep 13, 2022
@pacoxu
Copy link
Member Author

pacoxu commented Sep 13, 2022

The KEP about it is https://github.com/kubernetes/enhancements/tree/master/keps/sig-network/504-configurable-pod-dns#proposal
/cc @MrHohn @thockin @bowei
for the author and approvers of the KEP kubernetes/enhancements#504.

  • options that are an OS-dependent list of (name, value) options. These values
    are NOT expected to be generally portable across platforms. For containers that
    use /etc/resolv.conf style configuration, these correspond to the parameters
    passed to the option lines. Options will override if their names coincide,
    i.e, if the DnsPolicy sets ndots:5 and ndots:1 appears in the Spec,
    then the final value will be ndots:1.

@haosdent
Copy link
Member

Thanks @pacoxu . Let's paste how golang parse the config for your references. https://github.com/golang/go/blob/master/src/net/dnsconfig_unix.go#L39-L140

@pacoxu
Copy link
Member Author

pacoxu commented Sep 13, 2022

Thanks @pacoxu . Let's paste how golang parse the config for your references. https://github.com/golang/go/blob/master/src/net/dnsconfig_unix.go#L39-L140

I think we don't need to validate the option or do some aliases merging or further meaning parsing.
As the test case shows, in kubelet, we just parse

options ndots:1 attempts:3
options single-request rotate use-vc"

to an array like {"ndots:1", "attempts:3", "single-request", "rotate", "use-vc"}.

This is enough in this case.

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 20, 2022
@aojea
Copy link
Member

aojea commented Sep 20, 2022

  • Options will override if their names coincide,
    i.e, if the DnsPolicy sets ndots:5 and ndots:1 appears in the Spec,
    then the final value will be ndots:1.

/lgtm

It can be argued that is not a bug, just a known limitation of current implementation, since it seems that is working as documented.
This change seems to be backwards compatible
/assign @thockin

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Sep 20, 2022
{"options ndots:1\noptions ndots:5 attempts:3", []string{}, []string{}, []string{"ndots:5", "attempts:3"}, false},
{"options ndots:1 timeout:3 timeout:1 attempts:3\noptions ndots:5", []string{}, []string{}, []string{"ndots:5", "timeout:1", "attempts:3"}, false},
{"options ndots:1 attempts:3\noptions ndots:1 attempts:3 ndots:5", []string{}, []string{}, []string{"ndots:5", "attempts:3"}, false},
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a test for badly formatted resolv.conf?

Copy link
Member Author

@pacoxu pacoxu Sep 21, 2022

Choose a reason for hiding this comment

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

can we add a test for badly formatted resolv.conf?

Sorry, I can not get the point. Would you provide a badly formatted options example?

@thockin
Copy link
Member

thockin commented Sep 21, 2022

I still can't find any spec that says how this is SUPPOSED to work. I commented more on the issue #112323

@thockin
Copy link
Member

thockin commented Sep 21, 2022

Absent a real user who is really impacted by this, my inclination is to (again) do nothing. The risk of breakage is non-zero. The reward is zero (nobody is complaining, IIUC).

@thockin
Copy link
Member

thockin commented Sep 29, 2022

OK, as per the issue #112323 I guess I do not see why we should BREAK it.

Who owns this approve? @khenidak? @aojea?

@thockin thockin assigned khenidak and unassigned thockin Sep 29, 2022
@aojea
Copy link
Member

aojea commented Sep 29, 2022

/approve

Since seems to be valid to have multiple lines with options in a resolv.conf but is not documented how to interpret them, we now merge those options giving preference to the latest entries, making the options field consistent inside the pods, avoiding issues if muslc/libc/... do not agree on the interpretation of the multiline configuration.

I do not know if this should be backported, the references to the kubernetes implementation mentions that only the last option line will be used, so we can argue that it was working as expected on the initial design.

@pacoxu I suggest to add a more detailed release note

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, pacoxu

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 29, 2022
@pacoxu
Copy link
Member Author

pacoxu commented Sep 30, 2022

I changed the release note like below.

kubelet: when there are multi option lines in /etc/resolv.conf, merge all options into one line in a pod with the Default DNS policy.

@haosdent
Copy link
Member

Many thanks to @pacoxu @aojea @thockin !

@haosdent
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 30, 2022
@k8s-ci-robot k8s-ci-robot merged commit 4276ed3 into kubernetes:master Sep 30, 2022
SIG Node PR Triage automation moved this from Triage to Done Sep 30, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Sep 30, 2022
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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.

kubelet doesn't merge multiple 'options' lines from node /etc/resolv.conf
6 participants