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

podIPs order match node IP family preference (Downward API) #103307

Merged
merged 1 commit into from Jul 7, 2021

Conversation

aojea
Copy link
Member

@aojea aojea commented Jun 29, 2021

Following up on #97979,
we should implement the same logic for the exposed PodIPs in the downward API, so
both values are identical.

In addition, it also fixes a bug that causes panic in the kubelet, because the podIPs object was mutated meanwhile the code was parsing the IP addresses.

xref: #102817

Additional information

I've tried different approaches, also to filter directly the podIPs in

func (m *kubeGenericRuntimeManager) determinePodSandboxIPs(podNamespace, podName string, podSandbox *runtimeapi.PodSandboxStatus) []string {

but I've discarded that approach because it has to add a dependeny to the runtimeManager on the kubelet nodeIPs.

Another alternative that I started and stopped because it is toooo disruptive, is to refactor all code to stop plumbing podIP and podIPs

What type of PR is this?

/kind bug
Fixes #103263, #102806

kubelet: the returned value for PodIPs is the same in the Downward API and in the pod.status.PodIPs field

@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 29, 2021
@k8s-ci-robot
Copy link
Contributor

@aojea: 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 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. labels Jun 29, 2021
@aojea aojea changed the title podIPs order match node IP family preference podIPs order match node IP family preference (Downward API) Jun 29, 2021
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 29, 2021
@aojea
Copy link
Member Author

aojea commented Jun 29, 2021

/sig network
/sig node
/assign @danwinship @thockin
/cc @ehashman

@k8s-ci-robot k8s-ci-robot added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Jun 29, 2021
@aojea
Copy link
Member Author

aojea commented Jun 29, 2021

/retest

Kubernetes e2e suite: [sig-node] RuntimeClass should reject a Pod requesting a deleted RuntimeClass [NodeFeature:RuntimeHandler] 

@aojea
Copy link
Member Author

aojea commented Jun 30, 2021

/priority important-soon

/test pull-kubernetes-integration
TestCertRotationContinuousRequests

@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-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jun 30, 2021
@aojea
Copy link
Member Author

aojea commented Jun 30, 2021

/test pull-kubernetes-e2e-gce-ubuntu-containerd

Kubernetes e2e suite: [sig-storage] CSI Volumes [Driver: csi-hostpath] [Testpattern: Dynamic PV (filesystem volmode)] volumeLimits should verify that all csinodes have volume limits expand_less

@ehashman ehashman added this to Triage in SIG Node PR Triage Jul 1, 2021
pkg/kubelet/kubelet_pods.go Outdated Show resolved Hide resolved
runtimes may return an arbitrary number of Pod IPs, however, kubernetes
only takes into consideration the first one of each IP family.

The order of the IPs are the one defined by the Kubelet:
- default prefer IPv4
- if NodeIPs are defined, matching the first nodeIP family

PodIP is always the first IP of PodIPs.

The downward API must expose the same IPs and in the same order than
the pod.Status API object.
}

// make podIPs order match node IP family preference #97979
podIPs = kl.sortPodIPs(podIPs)
Copy link
Member Author

@aojea aojea Jul 6, 2021

Choose a reason for hiding this comment

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

is there some subtle golang thing that disallow this?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know - is something not working?

Copy link
Member Author

Choose a reason for hiding this comment

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

it does work, I just pass the slice as argument and override the same variable with the output, I think is fine, but I just wanted to double check

@thockin
Copy link
Member

thockin commented Jul 6, 2021 via email

@thockin
Copy link
Member

thockin commented Jul 6, 2021

This whole sorting things makes me a little uneasy, not going to lie. But it's already being done elsewhere, so ....

/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 Jul 6, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Jul 6, 2021
@k8s-ci-robot k8s-ci-robot merged commit 2547c5b into kubernetes:master Jul 7, 2021
SIG Node PR Triage automation moved this from Triage to Done Jul 7, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.22 milestone Jul 7, 2021
@aojea
Copy link
Member Author

aojea commented Jul 7, 2021

This whole sorting things makes me a little uneasy, not going to lie. But it's already being done elsewhere, so ....

/lgtm
/approve

I think that this is one of the things that goes to the bucket of "needs a refactor", the podIP and podIPs combo are plumbed in a lot of functions, we no longer need podIP IIUIC .... as I wrote in the description I think that this should be done in the runtime

func (m *kubeGenericRuntimeManager) determinePodSandboxIPs(podNamespace, podName string, podSandbox *runtimeapi.PodSandboxStatus) []string {
but that is a big change , adds a new dependency on the kubelet, and there is a big PR to refactor these code #102344 in flight, 🤷

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-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.

"fieldPath: status.podIP" may use wrong IP family in dual stack cluster.
4 participants