Skip to content

[fix] remove node IP annotations the linode no longer has - #660

Open
lbarrosby wants to merge 1 commit into
linode:mainfrom
lbarrosby:fix-node-stale-ip-annotations
Open

lbarrosby wants to merge 1 commit into
linode:mainfrom
lbarrosby:fix-node-stale-ip-annotations

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

Description

The node controller writes node.k8s.linode.com/private-ip and node.k8s.linode.com/public-ipv6, but updateNodeMetadata only sets them when the linode has a value (... && privateIP != ""). When the private IPv4 is removed from the linode (or the IPv6 range goes away), the old annotation stays on the node:

  • getNodePrivateIP prefers the annotation over Status.Addresses, so the NodeBalancer config keeps that node's backend on the removed private IP instead of falling back to its InternalIP.
  • handleNode compares the annotation with the linode on every metadata refresh, sees a mismatch, and sends a Nodes().Update that changes nothing, once per TTL for each such node.

Change: setOrDeleteAnnotation sets the annotation to the expected value, or deletes it when the value is empty. Other annotations are untouched, and the label/ProviderID handling is the same as before.

Test: TestNodeController_handleNodeRemovesStaleIPAnnotations starts from a node that has both annotations and a linode that only has its public IPv4. It checks that both annotations are removed and an unrelated one is kept, that getNodePrivateIP now returns the node's InternalIP, and that the next refresh leaves the node unchanged (same resourceVersion). On main it fails:

Error: map[string]string{"node.k8s.linode.com/private-ip":"192.168.159.135", "node.k8s.linode.com/public-ipv6":"2001:db8::f03c:91ff:fe2b:1a2b/128", "other":"kept"} should not contain "node.k8s.linode.com/private-ip"
$ go test ./cloud/... -count=1
ok  	github.com/linode/linode-cloud-controller-manager/cloud/linode	10.905s
ok  	github.com/linode/linode-cloud-controller-manager/cloud/linode/services	0.766s
ok  	github.com/linode/linode-cloud-controller-manager/cloud/linode/utils	0.348s
ok  	github.com/linode/linode-cloud-controller-manager/cloud/nodeipam/ipam	4.475s
$ golangci-lint run -c .golangci.yml ./cloud/linode/...
No issues found

General:

  • Have you removed all sensitive information, including but not limited to access keys and passwords?
  • Have you checked to ensure there aren't other open or closed Pull Requests for the same bug/feature/question?

Pull Request Guidelines:

  1. Does your submission pass tests?
  2. Have you added tests?
  3. Are you addressing a single feature in this PR?
  4. Are your commits atomic, addressing one change per commit?
  5. Are you following the conventions of the language?
  6. Have you saved your large formatting changes for a different PR, so we can focus on your work?
  7. Have you explained your rationale for why this feature is needed?
  8. Have you linked your PR to an open issue

updateNodeMetadata only set node.k8s.linode.com/private-ip and
node.k8s.linode.com/public-ipv6 when the linode had a value, so an
address removed from the linode stayed on the node forever.
getNodePrivateIP prefers the annotation, so NodeBalancer backends kept
pointing at the removed private IP instead of falling back to the
node's InternalIP. handleNode also saw the mismatch on every refresh and
sent a Node update that changed nothing.

Remove the annotation when the expected value is empty.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
@lbarrosby
lbarrosby requested review from a team as code owners November 10, 2026 07:25
@github-actions github-actions Bot added the bugfix for any bug fixes in the changelog. label Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix for any bug fixes in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant