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

When resolvConf is "" in kubelet configuration, pod will be created with wrong dns policy #104624

Merged

Conversation

Haleygo
Copy link
Contributor

@Haleygo Haleygo commented Aug 27, 2021

What type of PR is this?

/kind bug

What this PR does / why we need it:

Now we can launch kubelet with "--resolv-conf= " and use the default DNS Policy like this.
But if set resolvConf in a config file to "", resolv.conf path was set to "/etc/resolv.conf" and it's not what we wanted.

Which issue(s) this PR fixes:

Fixes ##103110

Special notes for your reviewer:

Does this PR introduce a user-facing change?

ACTION REQUIRED: kubelet: turn the KubeletConfiguration v1beta1 `ResolverConfig` field from a `string` to `*string`.

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


@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/bug Categorizes issue or PR as related to a bug. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/kubeadm kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 27, 2021
@aojea
Copy link
Member

aojea commented Aug 27, 2021

This fixes the mismatch on the behavior between flags and config file.
Please check with sig-node how they use to handle the changes on the config fields, since you are moving one field form string to pointer, I don't know if you need an api bump or since this is a bug it can be done directly

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

this is a breaking change to KubeletConfiguration users that import the Go struct to set the ResolverConfig field - e.g. the kubeadm change is an example of how they need to adapt.
normally things like this should be done in a version increment.

deferring to SIG Node if they are OK with this.

the change also needs a release note; proposing:

kubelet: turn the KubeletConfiguration v1beta1 `ResolverConfig` field from a `string` to `*string`.

perhaps prefixed with ACTION REQUIRED too.

@pacoxu
Copy link
Member

pacoxu commented Aug 30, 2021

/sig node
/cc gjkim42 ehashman
since you have reviewed #103183

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 30, 2021
@Haleygo Haleygo marked this pull request as ready for review August 30, 2021 06:08
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 30, 2021
@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

Copy link
Member

@gjkim42 gjkim42 left a comment

Choose a reason for hiding this comment

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

Agree that setting with config file and setting with command argument should be more consistent.

@neolit123
Copy link
Member

/area kubelet

@Haleygo
Copy link
Contributor Author

Haleygo commented Aug 30, 2021

/retest

@pacoxu
Copy link
Member

pacoxu commented Sep 4, 2021

/priority important-longterm
/triage accepted

@k8s-ci-robot k8s-ci-robot added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed 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. labels Sep 4, 2021
@pacoxu pacoxu moved this from Triage to Needs Reviewer in SIG Node PR Triage Sep 4, 2021
@pacoxu
Copy link
Member

pacoxu commented Sep 10, 2021

/lgtm

@kubernetes/sig-node-api-reviews
as it is a small api-change(no behavior change IMO).

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 10, 2021
@liggitt
Copy link
Member

liggitt commented Sep 11, 2021

/label api-review
/assign
/assign @ehashman

@k8s-ci-robot k8s-ci-robot added the api-review Categorizes an issue or PR as actively needing an API review. label Sep 11, 2021
@liggitt liggitt added this to Assigned in API Reviews Sep 11, 2021
@@ -601,7 +601,7 @@ type KubeletConfiguration struct {
// the node is recommended before changing this field.
// Default: "/etc/resolv.conf"
Copy link
Member

Choose a reason for hiding this comment

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

the behavior of providing an explicit empty string needs to be described in the field doc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure!
Added description according to this

case podDNSHost:
// When the kubelet --resolv-conf flag is set to the empty string, use
// DNS settings that override the docker default (which is to use
// /etc/resolv.conf) and effectively disable DNS lookups. According to
// the bind documentation, the behavior of the DNS client library when
// "nameservers" are not specified is to "use the nameserver on the
// local machine". A nameserver setting of localhost is equivalent to
// this documented behavior.
if c.ResolverConfig == "" {
for _, nodeIP := range c.nodeIPs {
if utilnet.IsIPv6(nodeIP) {
dnsConfig.Servers = append(dnsConfig.Servers, "::1")
} else {
dnsConfig.Servers = append(dnsConfig.Servers, "127.0.0.1")
}
}
if len(dnsConfig.Servers) == 0 {
dnsConfig.Servers = append(dnsConfig.Servers, "127.0.0.1")
}
dnsConfig.Searches = []string{"."}
}
}

Copy link
Member

@ehashman ehashman left a comment

Choose a reason for hiding this comment

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

Is there anything that should be added to the kubelet config validation tests for this change? (note that there doesn't appear to be a defaults_test.go defined and validation in https://github.com/kubernetes/kubernetes/blob/release-1.22/pkg/kubelet/apis/config/validation/validation_test.go is not very targeted)

Generally LGTM, fixes a drift in behaviour between CLI flag and the kubeletConfig.

if obj.ResolverConfig == "" {
obj.ResolverConfig = kubetypes.ResolvConfDefault
if obj.ResolverConfig == nil {
obj.ResolverConfig = utilpointer.String(kubetypes.ResolvConfDefault)
Copy link
Member

Choose a reason for hiding this comment

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

Note internal type is remaining string and we will always default here if unset so the addition of a pointer should not cause NPEs.

@@ -601,7 +601,7 @@ type KubeletConfiguration struct {
// the node is recommended before changing this field.
// Default: "/etc/resolv.conf"
// +optional
ResolverConfig string `json:"resolvConf,omitempty"`
ResolverConfig *string `json:"resolvConf,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

This was omitempty before so old clients should behave the right way.

@Haleygo Haleygo force-pushed the support-null-resolvConf-in-configFile branch from aef8b8b to 46454ea Compare September 14, 2021 08:13
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 14, 2021
@liggitt liggitt moved this from Assigned to API review completed, 1.23 in API Reviews Sep 14, 2021
@liggitt
Copy link
Member

liggitt commented Sep 14, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 14, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Haleygo, liggitt

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 14, 2021
@k8s-ci-robot k8s-ci-robot merged commit fa2657b into kubernetes:master Sep 14, 2021
SIG Node PR Triage automation moved this from Needs Reviewer to Done Sep 14, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. area/kubeadm area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. 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. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: API review completed, 1.23
Development

Successfully merging this pull request may close these issues.

None yet

9 participants