Skip to content

Fix/remove dead nil selector check#231

Open
dorodb-web22 wants to merge 1 commit intokubernetes-sigs:mainfrom
dorodb-web22:fix/remove-dead-nil-selector-check
Open

Fix/remove dead nil selector check#231
dorodb-web22 wants to merge 1 commit intokubernetes-sigs:mainfrom
dorodb-web22:fix/remove-dead-nil-selector-check

Conversation

@dorodb-web22
Copy link
Copy Markdown

Description

metav1.LabelSelectorAsSelector is called with &oldRule.Spec.NodeSelector, where NodeSelector is a struct value, not a pointer. It never returns nil, nil ; an empty struct yields labels.Everything(), which correctly matches all nodes. The subsequent if oldSelector == nil branch was therefore dead code and could never be reached.

Remove the nil check and call oldSelector.Matches(...) directly.

Related Issue

Fixes #230

Type of Change

/kind cleanup

Testing

make test
make lint

Checklist

  • make test passes
  • make lint passes

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label May 9, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 9, 2026

Deploy Preview for node-readiness-controller canceled.

Name Link
🔨 Latest commit fc5b44b
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a003e340fc1290008a2f395

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found here.

Details 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 9, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @dorodb-web22. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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.

Details

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 9, 2026
Comment thread internal/controller/node_controller.go Outdated

// Process node against all applicable rules
r.Controller.processNodeAgainstAllRules(ctx, node)
if err := r.Controller.processNodeAgainstAllRules(ctx, node); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for your PR. Please note this is also addressed here: #229. Can you coordinate with the other author?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah I see your original PR: #222. This possibly is carrying your earlier changes as well. Can you scope the changes in this PR to only nil check?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@ajaysundark Good catch, I had accidentally branched from another PR instead of main. i have now force-pushed a cleaned-up version scoped only to the nil check in nodereadinessrule_controller.go. Thanks....

@ajaysundark
Copy link
Copy Markdown
Contributor

/ok-to-test

@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 May 9, 2026
@dorodb-web22 dorodb-web22 force-pushed the fix/remove-dead-nil-selector-check branch from 43fbf88 to fc5b44b Compare May 10, 2026 08:13
@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 10, 2026
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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cleanup: Remove dead code nil selector check in cleanupNodesAfterSelectorChange

3 participants