Skip to content

feat: collector-based rule_matched_nodes and typed failure reasons - #286

Open
rawadhossain wants to merge 2 commits into
kubernetes-sigs:mainfrom
rawadhossain:feat/add-observability-metrics
Open

feat: collector-based rule_matched_nodes and typed failure reasons#286
rawadhossain wants to merge 2 commits into
kubernetes-sigs:mainfrom
rawadhossain:feat/add-observability-metrics

Conversation

@rawadhossain

@rawadhossain rawadhossain commented Jul 2, 2026

Copy link
Copy Markdown
Member

Description

Adds node_readiness_rule_matched_nodes metric to the scrape-time collector pattern introduced in #398.

The metric is computed on each scrape from the cached Node list, sharing the same snapshot as node_readiness_rule_nodes. Dry-run and deleting rules are also included.

(exisitng) node_readiness_failures_total (new reason: AnnotationPatchFailed)

Also adds AnnotationPatchFailed as a new reason for the existing node_readiness_failures_total metric. Tracks failures when writing the bootstrap-completion annotation, keeping all failure reporting under the existing failures_total counter.

Changes

  • Moved node_readiness_rule_matched_nodes to the scrape-time ReadinessCollector.
  • Shares the Node list with node_readiness_rule_nodes.
  • Includes dry-run and deleting rules.
  • Added AnnotationPatchFailed to node_readiness_failures_total.
  • Failure reasons (EvaluationError, AddTaintError, RemoveTaintError, AnnotationPatchFailed) are now defined as a type with named constants.

Related to #397

Type of Change

/kind feature

Testing

  • make test, make lint, go test ./... -race all pass
  • Verified the metric against a live cluster and confirmed the counts match the current Node selectors.

Checklist

  • make test passes
  • make lint passes

@kubernetes-prow kubernetes-prow Bot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 2, 2026
@netlify

netlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller ready!

Name Link
🔨 Latest commit 5278d1d
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a98f2fd76f4f200089e568c
😎 Deploy Preview https://deploy-preview-286--node-readiness-controller.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@kubernetes-prow

Copy link
Copy Markdown

Hi @rawadhossain. 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.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 2, 2026
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 406dde6 to 11900ae Compare July 3, 2026 15:07
@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 3, 2026
@ajaysundark
ajaysundark self-requested a review July 3, 2026 21:22

@AvineshTripathi AvineshTripathi left a comment

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 the PR! Left a few comments.

Comment thread internal/controller/nodereadinessrule_controller.go Outdated
Comment thread internal/metrics/metrics.go Outdated
Comment thread internal/metrics/metrics.go Outdated
Comment thread internal/controller/nodereadinessrule_controller.go Outdated
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 11900ae to 12ab0d9 Compare July 5, 2026 07:32
@rawadhossain

Copy link
Copy Markdown
Member Author

@AvineshTripathi PTAL. I'll commit the changes once you approve.
Thanks.

@AvineshTripathi

Copy link
Copy Markdown
Contributor

@rawadhossain I left one comment PHAL and maybe remove the Bootstrap duration metrics till we merge #224

@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 7, 2026
@ajaysundark
ajaysundark requested review from AvineshTripathi and removed request for dchen1107 and haircommander July 7, 2026 21:33
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 12ab0d9 to 8fcbeca Compare July 8, 2026 10:01
@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 8, 2026
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 8fcbeca to 3051634 Compare July 8, 2026 10:20
@rawadhossain

Copy link
Copy Markdown
Member Author

@AvineshTripathi I have made the changes. PTAL.
Thanks.

@AvineshTripathi

Copy link
Copy Markdown
Contributor

/ok-to-test

@kubernetes-prow kubernetes-prow Bot 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 Jul 20, 2026
@AvineshTripathi

Copy link
Copy Markdown
Contributor

/lgtm

cc @ajaysundark for final look

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 23, 2026
@rawadhossain

Copy link
Copy Markdown
Member Author

updated the description. Thanks.

@AvineshTripathi

Copy link
Copy Markdown
Contributor

/lgtm

/assign @ajaysundark
for review and approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 9, 2026
Comment thread internal/metrics/metrics.go Outdated
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from db7d7e2 to 4bc164e Compare August 15, 2026 10:39
@kubernetes-prow kubernetes-prow Bot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 15, 2026
@kubernetes-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rawadhossain
Once this PR has been reviewed and has the lgtm label, please ask for approval from ajaysundark. 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

@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 4bc164e to 0034c33 Compare August 15, 2026 10:50
@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 17, 2026
@AvineshTripathi

Copy link
Copy Markdown
Contributor

@rawadhossain can you please resolve the conflicts?

@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 0034c33 to aa9c0a4 Compare August 17, 2026 18:25
@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 17, 2026
@rawadhossain

Copy link
Copy Markdown
Member Author

@AvineshTripathi resolved the conflicts. GitHub was down for quite a while 😥
PTAL.

@rawadhossain

Copy link
Copy Markdown
Member Author

@ajaysundark if everything looks right here, can we get it merged?
Will do the collector migration for rule_matched_nodes as a follow-up PR once this land.

@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from aa9c0a4 to 4ea706d Compare August 19, 2026 20:12
@rawadhossain

Copy link
Copy Markdown
Member Author

@ajaysundark made the changes based on scrape time collector and updated the description.

Could we get #431 (blocked_nodes) reviewed and merged first? This PR has a small adjustment that depends on the changes in #431. Once it's merged, I'll make that change here and push the final commit.

@rawadhossain rawadhossain changed the title feat: Add selector and bootstrap observability metrics feat: collector-based rule_matched_nodes and typed failure reasons Aug 31, 2026
@rawadhossain

Copy link
Copy Markdown
Member Author

@ajaysundark made the adjustments here after 431 landed. I think this should be good to merge.
PTAL. Thanks!

@AvineshTripathi

Copy link
Copy Markdown
Contributor

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 2, 2026
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 4ab42a3 to 5278d1d Compare September 3, 2026 04:09
@kubernetes-prow kubernetes-prow Bot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 3, 2026
@kubernetes-prow

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

}
}

matched, err := c.lister.ListRuleMatchedNodes(ctx, nodes, rules)

@ajaysundark ajaysundark Sep 3, 2026

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.

@rawadhossain Could you check if we are scraping these metrics as a single-pass instead of scraping the cache individually for each of these scrape time metrics?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, checked it. All three scrape time metrics scrape the node and rule cache only once, not three individual cache reads. Also tested it on a live cluster to double check, and everything matched up correctly.

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/feature Categorizes issue or PR as related to a new feature. 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.

3 participants