Skip to content

feat: Add bootstrap NRC duration metric - #294

Open
rawadhossain wants to merge 1 commit into
kubernetes-sigs:mainfrom
rawadhossain:feat/bootstrap-nrc-duration-metric
Open

feat: Add bootstrap NRC duration metric#294
rawadhossain wants to merge 1 commit into
kubernetes-sigs:mainfrom
rawadhossain:feat/bootstrap-nrc-duration-metric

Conversation

@rawadhossain

@rawadhossain rawadhossain commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds node_readiness_bootstrap_hold_duration_seconds, which measures how long a node is held by a bootstrap-only rule's taint, from when the taint is first present on the node until bootstrap completes.

The status object now tracks two anchor timestamps on NodeEvaluation:

  • taintAppliedAt — when NRC itself applies the taint
  • taintObservedAt — when NRC first observes the taint present, whether applied by NRC or already present (e.g. via kubelet -register-with-taints)

The metric carries a new controller label (applied/adopted) so the two cases are distinguishable: anchored on taintAppliedAt when NRC applied the taint, falling back to taintObservedAt for the adopted case, where taintAppliedAt is never set.

Related to Issue #182

Type of Change

/kind feature

Testing

  • Unit tests for isBootstrapCompleted, including backward compatibility and in progress states
  • Integration tests added

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 8, 2026
@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for node-readiness-controller ready!

Name Link
🔨 Latest commit f889aee
🔍 Latest deploy log https://app.netlify.com/projects/node-readiness-controller/deploys/6a86176000cd6f00083cf239
😎 Deploy Preview https://deploy-preview-294--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
kubernetes-prow Bot requested review from dchen1107 and mrunalp July 8, 2026 14:33
@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 assign tallclair 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

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 8, 2026
@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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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 the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 8, 2026
@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from 10d451f to f85970c Compare July 8, 2026 14:51
Comment thread internal/controller/helper.go Outdated
)

// bootstrapAnnotationPayload is the JSON value stored in a bootstrap-completion annotation.
type bootstrapAnnotationPayload struct {

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.

IMO, TaintAppliedAt and Completed are better suited for the dedicated NodeEvaluation 'status' api we planned. Can we discuss this during our next sync on how we could shape it in the alpha2 api?

@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 10, 2026
@AvineshTripathi

Copy link
Copy Markdown
Contributor

@rawadhossain can you resolve the conflicts please!

@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from f85970c to a9d441f Compare July 21, 2026 17:25
@kubernetes-prow kubernetes-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 21, 2026
@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from 3069c56 to 59e4f78 Compare July 21, 2026 17:43
@rawadhossain

Copy link
Copy Markdown
Contributor Author

Hi @ajaysundark @AvineshTripathi
Sorry for the late response.

Updated the PR. Moved the timestamp from node metadata to status.nodeEvaluations, following the current API shape as we discussed. Also handled the adopted taint (--register-with-taints) case by only stamping the anchor when the taint is applied by NRC.

@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 22, 2026
@kubernetes-prow kubernetes-prow Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 30, 2026
@rawadhossain

Copy link
Copy Markdown
Contributor Author

While validating this metric for Section 2 Grafana dashboard, I found that it wasn't emitting any data. It turned out TaintAppliedAt in status.nodeEvaluations exposed an issue with stale cached rules in NodeReconciler, which could cause the anchor to be lost during the next status update.

I added a fix to recover the missing anchor when needed and make sure it isn't lost again during later status updates. Since the Section 2 dashboard depends on this metric, I wanted to fix this before moving forward.

cc @ajaysundark @AvineshTripathi

@AvineshTripathi

Copy link
Copy Markdown
Contributor

@rawadhossain can we two separate PRs? Maybe the fix can go in the different PR and we can try merge this. Please let me know your thoughts

Comment thread internal/metrics/metrics.go Outdated
// taintAppliedAt is the timestamp when the controller applied the readiness taint to this Node.
//
// +optional
TaintAppliedAt metav1.Time `json:"taintAppliedAt,omitempty,omitzero"`

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.

cc @Karthik-K-N for note as we should keep this field name and semantics same when we split NodeEvaluation status

Comment thread api/v1alpha1/nodereadinessrule_types.go
@kubernetes-prow kubernetes-prow Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2026
@rawadhossain

Copy link
Copy Markdown
Contributor Author

@rawadhossain can we two separate PRs? Maybe the fix can go in the different PR and we can try merge this. Please let me know your thoughts

That makes sense and its cleaner. My only concern is that the cache fix is tied to this metric, and without it the metric doesn't reliably emit data. That's why I kept them together. If you prefer splitting them, I'm happy to do that.

@AvineshTripathi

Copy link
Copy Markdown
Contributor

@rawadhossain i see there are conflicts, can you resolve it please

@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from 6f60849 to d72fbc1 Compare August 4, 2026 21:26
@kubernetes-prow kubernetes-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 4, 2026
@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from d72fbc1 to 9832aaa Compare August 4, 2026 21:36
@rawadhossain

Copy link
Copy Markdown
Contributor Author

Done, resolved the merge conflicts. Thanks.

@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from 9832aaa to 7456ac8 Compare August 4, 2026 21:43
@ajaysundark ajaysundark added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Aug 7, 2026
@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from fbed91b to 3966293 Compare August 8, 2026 14:51
Comment thread internal/metrics/metrics.go Outdated
Help: "Time from readiness taint application or observation to bootstrap completion. Measures only NRC-attributable hold time.",
Buckets: []float64{1, 5, 10, 30, 60, 120, 300, 600, 1200, 1800, 3600},
},
[]string{"rule", "controller"}, // controller: applied, adopted

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.

can you x-ref the design on this one? taint_origin for this label is better with values adopted vs controller, to show initial ownership.

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.

Updated it. taint_origin now uses controller and adopted to show the taint ownership.

@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch 2 times, most recently from 8ede5ad to 987eb12 Compare August 15, 2026 14:55
@ajaysundark

Copy link
Copy Markdown
Contributor

please resolve conflicts

@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
@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from 987eb12 to 5163b26 Compare August 17, 2026 13:29
@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

@ajaysundark resolved the conflicts. PTAL. Thanks.

@rawadhossain
rawadhossain force-pushed the feat/bootstrap-nrc-duration-metric branch from 5163b26 to f889aee Compare August 19, 2026 20:51
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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants