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

return multiple IPs for nodes when reporting ingress status #10757

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

akdor1154
Copy link

@akdor1154 akdor1154 commented Dec 13, 2023

What this PR does / why we need it:

When reporting a node's IP into an Ingress' status, currently ingress-nginx only reports the first IP. In particular, this makes it impossible to report dual IPv4/IPv6 addresses.

This PR updates behaviour to report all matching (internal vs external) addresses instead of just the first.

First two commits are small refactors to make the actual change commit easier to read.
Third commit is the meat.
Final commit is probably needed in some form but I need to look into it more: when shutting down syncStatus, looks like len(addrs) == 1 is considered a special case, this is no longer an appropriate assumption to make but I need to look more deeply into what's going on here.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • CVE Report (Scanner found CVE and adding report)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation only

Which issue/s this PR fixes

fixes #10756 .

How Has This Been Tested?

unit tests updated as per commits.. I will do integration testing tomorrow.

Checklist:

  • [?] My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added unit and/or e2e tests to cover my changes.
  • All new and existing tests passed.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 13, 2023
Copy link

linux-foundation-easycla bot commented Dec 13, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Dec 13, 2023

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
🔨 Latest commit 89b8125
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/657a4aa2ccf99400081efc7d

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Dec 13, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors 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-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Dec 13, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @akdor1154!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Dec 13, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @akdor1154. 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 13, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: akdor1154
Once this PR has been reviewed and has the lgtm label, please assign rikatz for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

this is done to make the intention of current behaviour clearer
before I go changing it.
this should have no effect on current behaviour.
again, no actual behaviour change here, just augmenting tests to show
current behaviour before i go changing it.

I changed the node IPv4 IP because other bits of the tests used the same
IP for a mock load balancer.
the main consideration I had for doing this was to make sure both IPv4
and IPv6 addresses are attached to my ingress, however the approach here
has nothing to do with IP Families: the change is to return all matching
addresses instead of just the first, regardless of family.
this logic is no longer valid but I don't understand what's going on
well enough to justify its removal yet - input welcome if you can tell
me if this is/isn't reasonable.
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 14, 2023
@akdor1154
Copy link
Author

reading into the final shutdown len(addrs)>1 change a bit more - my interpretation is (could be way off)


len(addrs) > 1

  • is intended to mean "given I'm leader, are there any other candidates around which will gain leader status once I'm gone?"
  • in which case skipping cleanup makes sense.

If this interpretation is right, then I think just removing that block is justified, as the next check seems to be checking the same thing ("are their other candidates around who will update for me after I'm gone"?).

I'll play around and test a bit, but as said, I'm now a bit more confident that my approach to shutdown behaviour is justified.

@akdor1154
Copy link
Author

akdor1154 commented Dec 14, 2023

initial testing looks OK. I've published a public image:

# values.yaml
controller:
  image:
    registry: ghcr.io
    image: akdor1154/ingress-nginx/controller
    tag: "v1.9.4"
    digest: "sha256:3b15d2cb572389e9ac131ac3218a11b54b3c1a68ba95e39a085957ef64a7420b"

With that image, my ingresses get marked with all relevant node IPs, both internal and external.

I don't think I'm able to test this with the e2e tests in a sensible way sorry - the e2e kind config is set to ipv4 only (by default). Setting it to dual stack seems to work here, but I suspect it will break things for mac/windows devs. As such I'm marking this ready for review.

@akdor1154 akdor1154 marked this pull request as ready for review December 14, 2023 02:37
@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 Dec 14, 2023
@strongjz
Copy link
Member

@akdor1154 it looks good, can you double check the e2e test and add one with node with both ipv4 and 6 address.

@strongjz
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Dec 20, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Dec 20, 2023
@strongjz
Copy link
Member

https://github.com/kubernetes/ingress-nginx/blob/main/test/e2e/framework/deployment.go

I dont know if we have ipv6 tests, looking at the deployment and others, I don't really see it. That might make this a little harder to get in.

@strongjz
Copy link
Member

looks like it can be added here in status https://github.com/kubernetes/ingress-nginx/blob/main/test/e2e/status/update.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Report dual stack Node IPs instead of just the first
3 participants