From 85c9c78bed2d1aae71f917fec4ec7389055a64a7 Mon Sep 17 00:00:00 2001 From: Nicolas Nosenzo Date: Mon, 14 Sep 2026 14:43:12 +0200 Subject: [PATCH] fix(metrics): don't count conflict errors as reconcile failures Optimistic-lock conflicts are expected during normal concurrent reconciles and were inflating multigres_operator_reconcile_errors_total. Signed-off-by: Nicolas Nosenzo --- pkg/monitoring/metrics.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/monitoring/metrics.go b/pkg/monitoring/metrics.go index 6ac73256..08ac9698 100644 --- a/pkg/monitoring/metrics.go +++ b/pkg/monitoring/metrics.go @@ -2,6 +2,7 @@ package monitoring import ( "github.com/prometheus/client_golang/prometheus" + apierrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/metrics" ) @@ -167,9 +168,11 @@ func Collectors() []prometheus.Collector { // RecordReconcileError increments the per-object reconcile error counter. // It is a no-op when err is nil, so callers can defer it unconditionally -// over a named error return value. +// over a named error return value. Conflict errors are excluded: they +// indicate a concurrent update and are expected during normal operation, +// not a reconcile failure. func RecordReconcileError(err error, controller, name, namespace string) { - if err == nil { + if err == nil || apierrors.IsConflict(err) { return } reconcileErrorsTotal.WithLabelValues(controller, name, namespace).Inc()