Skip to content

Fix stale NodeStatus entries in StaticRoute resources when their corresponding Kubernetes nodes are removed. - #131

Open
FilatovM wants to merge 1 commit into
IBM:masterfrom
FilatovM:fix/delete-stale-node-statuses
Open

FilatovM wants to merge 1 commit into
IBM:masterfrom
FilatovM:fix/delete-stale-node-statuses

Conversation

@FilatovM

@FilatovM FilatovM commented Oct 9, 2026 •

Copy link
Copy Markdown

Fix for raised issue - #129

When a Kubernetes node disappears unexpectedly, its corresponding entry can remain in StaticRoute.Status.NodeStatus indefinitely. This can leave outdated status information and interfere with the cleanup of StaticRoute resources.

Changes:

  • Remove stale node statuses: On delete event compare StaticRoute.Status.NodeStatus entries with existing Kubernetes nodes and remove entries for nodes that no longer exist.

  • Support hostname matching: Match node statuses against both Kubernetes node names and the kubernetes.io/hostname label.

  • Improve deletion handling: Allow finalizer cleanup to proceed when a deleting StaticRoute has no remaining node statuses.

  • Handle errors: Propagate failures when listing Kubernetes nodes or updating the StaticRoute status.

  • Add test coverage: Update controller mocks and tests to cover stale status cleanup and the associated reconciliation behavior.

@Tamas-Biro1 Tamas-Biro1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution for Static Route operator!

I added some comments and suggestions, also i'm open for further discussion on this issue. Thanks!

@FilatovM
FilatovM force-pushed the fix/delete-stale-node-statuses branch 2 times, most recently from 97ac59f to c6aad97 Compare October 12, 2026 12:50
@FilatovM
FilatovM requested a review from Tamas-Biro1 October 13, 2026 07:04
@FilatovM

FilatovM commented Nov 5, 2026

Copy link
Copy Markdown
Author

Thanks for the contribution for Static Route operator!

I added some comments and suggestions, also i'm open for further discussion on this issue. Thanks!

Hi, @Tamas-Biro1. Could you review the last iteration?

My point is that node-controller can miss graceful node shutdown in this case all but one node's status can be deleted later because only staticroute-operator from current node can remove node status from list. I agreed that we shouldn't reconcile by period, but we should double-check status for node statuses from absent nodes. Also it's nice to distinguish 2 cases: we have already deleted status from our node, but other statuses exist -> "AlreadyDeleted" and case when controller tries to delete node status and there are no statuses at all, so we should allow to proceed deletion.

Could You re-check and inform if there are still some doubts? From my point of view - there are outdated StaticRoute CR-s which are left after previous operations and now have deletionTimestamp with statues from node which are no longer exist. Maybe it's some non-graceful flow of node-management, but we face side-effects of it. So probably it wouldn't be expensive to double-check status on delete event.

@Tamas-Biro1 Tamas-Biro1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update @FilatovM ! I added one major and few smaller (easy-fix) comments, otherwise your changes looks good. I do not see other concerns with your changes, so once you address these i'll approve. Thanks again for you contribution.

Comment thread controllers/staticroute/mocks_test.go Resolved
@FilatovM
FilatovM force-pushed the fix/delete-stale-node-statuses branch 2 times, most recently from 3dc25bf to b1bd7f1 Compare November 11, 2026 11:52
@FilatovM

Copy link
Copy Markdown
Author

Thanks for comments @Tamas-Biro1! I agree with all provided suggestions, already closed these conversations but if I missed something or misinterpreted something, let me know. I've checked my problematic case again, still seems good.

@FilatovM
FilatovM requested a review from Tamas-Biro1 November 11, 2026 12:04
@FilatovM

Copy link
Copy Markdown
Author

@Tamas-Biro1 , kindly asking to double-check PR after applied changes when you have an opportunity. Thanks in advance!

@Tamas-Biro1

Copy link
Copy Markdown
Member

@Tamas-Biro1 , kindly asking to double-check PR after applied changes when you have an opportunity. Thanks in advance!

Thanks @FilatovM, as i see suggestions are addressed and the PR looks good to me. I'll approve, but one small thing: could you update the PR description? It still mentions the periodic reconcile that you've already removed.
Thanks for your contribution!

@Tamas-Biro1 Tamas-Biro1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please update the PR description, otherwise it looks good to me. Thanks!

@Tamas-Biro1

Copy link
Copy Markdown
Member

Please update the PR description, otherwise it looks good to me. Thanks!

I merged a PR to update Gosec version, please rebase this branch on master and the PR tests here will succeed.

Signed-off-by: Mikhail Filatov <misha.filat@gmail.com>
@FilatovM
FilatovM force-pushed the fix/delete-stale-node-statuses branch from b1bd7f1 to 256f079 Compare November 20, 2026 08:09
@FilatovM
FilatovM requested a review from Tamas-Biro1 November 20, 2026 08:11
@FilatovM

Copy link
Copy Markdown
Author

Please update the PR description, otherwise it looks good to me. Thanks!

I merged a PR to update Gosec version, please rebase this branch on master and the PR tests here will succeed.

@Tamas-Biro1 - Done. Thanks!

@FilatovM

Copy link
Copy Markdown
Author

Hi, @Tamas-Biro1, looks we are ready to go. If you can approve workflow, let's check this out. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants