feat: Add reconciliation retry observability metrics - #288
Conversation
Signed-off-by: Rawad Hossain <rawad.hossain00@gmail.com>
✅ Deploy Preview for node-readiness-controller canceled.
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rawadhossain The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/assign |
AvineshTripathi
left a comment
There was a problem hiding this comment.
I did some initial review and I had some questions:
- Are we planning to visualize these metrics? If so, then how?
- What type of answer will an operator get from these? I feel these are metrics for the controller itself, which will tell how controller is behaving in concurrent env
| // Update rule status | ||
| if err := r.Controller.updateRuleStatus(ctx, rule); err != nil { | ||
| log.Error(err, "Failed to update rule status", "rule", rule.Name) | ||
| metrics.ReconcileRequeue.WithLabelValues(rule.Name, "status_update_error").Inc() |
There was a problem hiding this comment.
there are other places too in Reconcile where we requeue for e.g. https://github.com/kubernetes-sigs/node-readiness-controller/blob/main/internal/controller/nodereadinessrule_controller.go#L151
maybe a defer function would make more sense here. Thoughts?
There was a problem hiding this comment.
I looked into using a defer, but I don't think it simplifies things much. We'd still need to set the reason at each requeue site so the deferred function knows which label to increment. It would also require named returns, handling early exits before rule is available, and a separate defer in reconcileDelete() for taint_cleanup_error, so I'm not sure if a defer would help much here.
For the line you linked (L151), we actually left that one out on purpose, processAllNodesForRule() always returns nil, so that error path is never reached. But updateRuleStatus(), can actually fail and return a real error, so I felt that was worth instrumenting.
There was a problem hiding this comment.
I agree but in past we have add a discussion to allow processAllNodesForRule to return error. Also there are other places too like https://github.com/kubernetes-sigs/node-readiness-controller/blob/main/internal/controller/nodereadinessrule_controller.go#L122
That's a fair point. Both metrics are meant to land in Grafana as alert companions along with the existing SLOs. It may feel a bit controller centric, but here's how I was looking at it.
For |
|
I dont mind having these metrics but not sure if they should go on any dashboards. wdyt @ajaysundark |
|
Hey @AvineshTripathi @ajaysundark, just to close the loop on this I'm okay to drop |
|
From the last meeting, did we see the possibility of api_error metrics going as a log and not metrics? Intuitively I too feel being a log makes more sense |
|
Hi @AvineshTripathi, you're right and I dug into this properly after the meeting discussion. I also looked into moving it fully to logs, but the project has no log aggregation setup. I've raised PR #320 with this approach, so I'll close this PR. |
| // Counts error driven requeues in RuleReconciler, keyed by the failing stage. | ||
| ReconcileRequeue = prometheus.NewCounterVec( | ||
| prometheus.CounterOpts{ | ||
| Name: "node_readiness_reconcile_requeue_total", |
There was a problem hiding this comment.
Controller-runtime already exposes requeue metrics: https://github.com/kubernetes-sigs/controller-runtime/blob/6ec95076a056c7a36c0d8acc8316da796426df7e/pkg/internal/controller/metrics/metrics.go#L39. We dont need to duplicate them.
Description
This PR adds two new metrics
What each metric does
node_readiness_api_conflicts_totalTracks how many API conflicts occur during controller operations. Previously, only conflicts that exhausted all retries were visible through
node_readiness_failures_total. If a retry succeeded, there was no signal that a conflict had happened. This metric makes those retries visible and helps identify API server contention earlier.node_readiness_reconcile_requeue_totalTracks why a rule reconciliation is requeued. Right now, we know a rule is being requeued, but we don't know which stage caused it. This metric records the reason for the requeue, making it easier to identify where reconciliation is failing.
The metric is labeled by
reason, currently covering:status_update_errorcleanup_errortaint_cleanup_errorRelated to Issue #182
Type of Change
/kind feature
Testing
Checklist
make testpassesmake lintpasses