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

Internal Load Balancer Controller do NOT remove nodes with empty string in the zone field #757

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

08volt
Copy link

@08volt 08volt commented Aug 30, 2024

Fix(ILB): Prevent deletion of nodes with empty zone label

Previously, new nodes were created with all topology labels present, including the zone label. However, recently, labels are being patched/updated on the node resource after the resource is created. This can result in nodes having an empty zone field when initially added to an instance group.

The Internal Load Balancer controller was incorrectly removing these nodes with empty zone labels from their assigned instance groups. This occurred because the controller interpreted nodes with empty zones as not belonging to any zone.

This commit fixes the issue by:

  • Storing nodes with empty zones during node processing.
  • Preventing the controller from removing these nodes during zone processing.

This ensures that new nodes with initially empty zone labels, due to the asynchronous label patching, are not prematurely deleted from their instance groups.

The fix has been verified with a new test which add a node with an empty zone label to an instance group and confirming that it is not deleted after a controller sync.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 30, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If the repository mantainers determine 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-sigs/prow 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 Aug 30, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @08volt!

It looks like this is your first PR to kubernetes/cloud-provider-gcp 🎉. 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/cloud-provider-gcp 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 30, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @08volt. 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 30, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 08volt
Once this PR has been reviewed and has the lgtm label, please assign jingxu97 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

@k8s-ci-robot k8s-ci-robot requested review from cici37 and jiahuif August 30, 2024 15:06
@aojea
Copy link
Member

aojea commented Aug 30, 2024

/ok-to-test
/assign @cezarygerard

@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 Aug 30, 2024
@08volt 08volt force-pushed the do-not-remove-nodes branch from 37b5fb0 to d8fd8fe Compare September 2, 2024 13:44
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 2, 2024
@08volt 08volt force-pushed the do-not-remove-nodes branch 7 times, most recently from 6563a59 to a428be3 Compare September 3, 2024 16:14
@cezarygerard
Copy link
Contributor

/retest

@08volt 08volt force-pushed the do-not-remove-nodes branch 4 times, most recently from eca15c8 to 49ed0a4 Compare September 6, 2024 14:38
@08volt 08volt force-pushed the do-not-remove-nodes branch 3 times, most recently from b8fe50c to 152e629 Compare September 7, 2024 12:13
@08volt
Copy link
Author

08volt commented Sep 9, 2024

/retest

@08volt 08volt force-pushed the do-not-remove-nodes branch from 152e629 to 86ee4d6 Compare September 9, 2024 09:31
@08volt
Copy link
Author

08volt commented Sep 16, 2024

/retest

4 similar comments
@08volt
Copy link
Author

08volt commented Sep 17, 2024

/retest

@08volt
Copy link
Author

08volt commented Sep 18, 2024

/retest

@08volt
Copy link
Author

08volt commented Sep 27, 2024

/retest

@08volt
Copy link
Author

08volt commented Oct 8, 2024

/retest

@08volt
Copy link
Author

08volt commented Oct 28, 2024

@cezarygerard @aojea
can we merge this?

@mmamczur
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 28, 2024
@bowei
Copy link
Member

bowei commented Oct 28, 2024

Can we add more information in the Git commit message (not just the Github PR). Use git commit --amend to edit the commit message.

  • When does this condition come up -- basically why would you get an empty Zone in the Node resource -- seems impossible?
  • Why not ignoring the missing zone field is safe. Is the information coming from a different place?
  • How this change was tested. I assume there is some situation where this behavior was causing a problem -- how did we test that we have fixed the problem.

@08volt 08volt force-pushed the do-not-remove-nodes branch from 86ee4d6 to e40c2fc Compare October 29, 2024 09:45
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2024
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@08volt
Copy link
Author

08volt commented Oct 29, 2024

Can we add more information in the Git commit message (not just the Github PR). Use git commit --amend to edit the commit message.

  • When does this condition come up -- basically why would you get an empty Zone in the Node resource -- seems impossible?
  • Why not ignoring the missing zone field is safe. Is the information coming from a different place?
  • How this change was tested. I assume there is some situation where this behavior was causing a problem -- how did we test that we have fixed the problem.

Thanks for the input @bowei , I updated the commit message with new information. Please let me know if you think it is enough.

@08volt 08volt force-pushed the do-not-remove-nodes branch from e40c2fc to 67dd896 Compare October 29, 2024 09:54
Previously, new nodes were created with all topology labels present, including the zone label. However, recently, labels are being patched/updated on the node resource after the resource is created. This can result in nodes having an empty zone field when initially added to an instance group.

The Internal Load Balancer controller was incorrectly removing these nodes with empty zone labels from their assigned instance groups. This occurred because the controller interpreted nodes with empty zones as not belonging to any zone.

This commit fixes the issue by:

Storing nodes with empty zones during node processing.
Preventing the controller from removing these nodes during zone processing.
This ensures that new nodes with initially empty zone labels, due to the asynchronous label patching, are not prematurely deleted from their instance groups.

The fix has been verified with a new test which add a node with an empty zone label to an instance group and confirming that it is not deleted after a controller sync.
@08volt 08volt force-pushed the do-not-remove-nodes branch from 67dd896 to 2361da9 Compare October 29, 2024 10:02
@@ -700,7 +719,7 @@ func (g *Cloud) ensureInternalInstanceGroups(name string, nodes []*v1.Node) ([]s
igLinks = append(igLinks, ig.SelfLink)
}
} else {
igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes)
igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes, zonedNodes[""])
Copy link
Member

@bowei bowei Nov 15, 2024

Choose a reason for hiding this comment

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

How do we know that all Nodes with an empty zone belong to the zone being ensured here?

Specifically:

igLink, err := g.ensureInternalInstanceGroup(name, zone, nodes, zonedNodes[""])
                                                   ^^^^         ^^^^^^^^^^^^^^
                                                    A            B

That B all belong in zone A.

e.g. can B have a node in zone z1 and zone z2 but A == z1? Will this work correctly?

Copy link
Contributor

Choose a reason for hiding this comment

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

so the logic here is that zonedNodes contain nodes that 'should not be removed from Instance Groups'.

What this means is that if, a node is attached to an IG, but for some reason it's zone assignment disappears, don't remove it from the group.
nodes in emptyZoneNodes will not be added, it's just to keep them from being removed.

inside ensureInternalInstanceGroup there is this part removeNodes := gceNodes.Difference(kubeNodes).Difference(emptyZoneNodesNames).List() - when determining which nodes to remove, skip the empty zones one.

In general we have many issues that start with nodes becoming 'temporarily' unready, or missing some data like zone info. Then LB controllers start removing them and we get outages.

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-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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants