Skip to content

feat: Add selector and bootstrap observability metrics - #286

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

feat: Add selector and bootstrap observability metrics#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
Contributor

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 4ea706d
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a860e375a20db0008caf841
😎 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
Contributor 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
Contributor 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
rawadhossain force-pushed the feat/add-observability-metrics branch from 46a0b95 to 4cdb15e Compare August 4, 2026 18:48
@rawadhossain

Copy link
Copy Markdown
Contributor Author

Could node_readiness_bootstrap_completion_errors_total be folded within failures_total with a dedicated reason?

Yeah, agreed. Folded it into failures_total with a dedicated reason, so bootstrap_completion_errors_total has been removed.

@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch 3 times, most recently from 9978442 to 3209f2c Compare August 5, 2026 15:42
Comment thread internal/metrics/metrics.go Outdated
@rawadhossain
rawadhossain force-pushed the feat/add-observability-metrics branch from 3209f2c to db7d7e2 Compare August 8, 2026 20:21
@ajaysundark

Copy link
Copy Markdown
Contributor

Hi @rawadhossain can you update the description to reflect the changes?

@rawadhossain

Copy link
Copy Markdown
Contributor 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
// RuleMatchedNodes tracks how many nodes match each rule's selector.
RuleMatchedNodes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "node_readiness_rule_matched_nodes",

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.

We discussed this in design about having this behind the scrape-collector. I see you have a PR (#398) open for that. Do you want to merge this and migrate later or you want to handle this after handling #398 first?

@rawadhossain rawadhossain Aug 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was the plan to get this merged first. Since this PR was raised before we introduced the scrape-time collector, I didn’t want to discard it and block the current work.

I’ll do a follow-up migration PR once this and the collector PRs are merged.

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.

Now that scrape-time collector is already in, would it make sense to make these changes right now than to plan a followup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was thinking the same. I think it'd be better to do it now, and it'll be easier for you to review as well. I'll try to get the changes done today. Thanks.

@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

New changes are detected. LGTM label has been removed.

@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
Contributor Author

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

@rawadhossain

Copy link
Copy Markdown
Contributor 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
Contributor 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.

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