feat(metrics): add per-resource reconcile condition gauge#4812
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gurpalw 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 |
|
Welcome @gurpalw! |
|
Hi @gurpalw. 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 Regular contributors should join the org to skip this step. 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. |
d5ef8df to
6edf2ef
Compare
|
/ok-to-test |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4812 +/- ##
==========================================
+ Coverage 57.08% 57.53% +0.45%
==========================================
Files 396 396
Lines 31572 31628 +56
==========================================
+ Hits 18022 18197 +175
+ Misses 12492 12369 -123
- Partials 1058 1062 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Adds awslbc_controller_reconcile_condition{controller,namespace,name},
set to 1 when the last reconcile of a resource succeeded and 0 when it
is failing, so alerts can identify which resource is failing to
reconcile rather than only the controller. The series is deleted when
the resource is deleted (or an ingress group loses its last member) so
the metric stays bounded to live resources.
The failure/requeue classification lives in a new
runtime.HandleReconcileErrorWithCondition helper used by the ingress,
service, targetGroupBinding, gateway and globalAccelerator reconcilers.
ErrorWithMetrics gains an Unwrap method so errors.As-based requeue
detection can see through it and expected requeues are not reported as
failures.
Adds test coverage for the per-resource reconcile-condition gauge flagged by Codecov as low patch coverage: - lbc: exercise MockCollector condition set/delete recording - service: NotFound-delete branch + condition assertions on reconcile - targetGroupBinding: NotFound, cleanup-success, and deferred branches - globalAccelerator: NotFound-delete branch (first tests for the package) - gateway: NotFound-delete branch via the canonical NewMockCollector - ingress: members-present (condition set) and empty-group (delete) branches
32872ec to
ad73c86
Compare
Issue
Fixes #4808
Description
Adds a per-resource reconciliation-status metric so Prometheus alerts can identify which resource is failing to reconcile, not just that some reconcile in a controller is failing:
1— the last reconcile of the resource succeeded;0— the resource is failing to reconcile.NotFoundon fetch, service no longer of LB type, or an ingress group losing its last member), so the metric never reports a frozen state and cardinality stays bounded to live resources.RequeueNeeded/RequeueNeededAfter) do not mark the resource as failing, matching the existingawslbc_controller_reconcile_errors_totalsemantics — an LB mid-provisioning is not a failure.lbcmetrics.MetricCollector: ingress, service, targetGroupBinding, gateway (NLB/ALB), and globalAccelerator.Implementation notes, following existing patterns in the repo:
statuslabel), mirroring the existing per-resourceSet/Deletelifecycle ofaws_target_group_info(pkg/metrics/aws/target_group.go).awslbc_controller_top_talkers: implicit groups map 1:1 to the Ingress's namespace/name; explicit groups are cluster-scoped and emit an emptynamespacelabel.runtime.HandleReconcileErrorWithConditionhelper next to the existingHandleReconcileError, so each reconciler'sReconcile()is a one-line change and future controllers get the metric for free.ErrorWithMetricsgains anUnwrap()method soerrors.As-based requeue detection (runtime.IsRequeueError) can see through it. Without this, requeue errors wrapped byNewErrorWithMetricswere opaque toerrors.Is/errors.As;HandleReconcileErrorpreviously compensated with manual unwrapping (handleNestedError), which still works unchanged.NotFoundpath.Example alert query (also added to the docs):
awslbc_controller_reconcile_condition == 0Checklist
README.md, or thedocsdirectory)BONUS POINTS checklist: complete for good vibes and maybe prizes?! 🤯
pkg/metrics/lbcusing prometheustestutil)