diff --git a/internal/controller/styra/system_controller.go b/internal/controller/styra/system_controller.go index 8f934969..223b725e 100644 --- a/internal/controller/styra/system_controller.go +++ b/internal/controller/styra/system_controller.go @@ -97,13 +97,11 @@ func (r *SystemReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr log.Info("Fetching System") var system v1beta1.System if err := r.Get(ctx, req.NamespacedName, &system); err != nil { - r.Metrics.ReconcileTime.WithLabelValues("delete").Observe(time.Since(start).Seconds()) if k8serrors.IsNotFound(err) { log.Info("Could not find System in kubernetes") - r.deleteMetrics(req) + r.Metrics.ReconcileTime.WithLabelValues("delete").Observe(time.Since(start).Seconds()) return ctrl.Result{}, nil } - r.deleteMetrics(req) return ctrl.Result{}, errors.Wrap(err, "unable to fetch System") } @@ -178,7 +176,7 @@ func (r *SystemReconciler) deleteMetrics(req ctrl.Request) { return } if deleted := r.Metrics.ControllerSystemStatusReady.DeletePartialMatch( - prometheus.Labels{"System": req.Name, "namespace": req.Namespace}, + prometheus.Labels{"system_name": req.Name, "namespace": req.Namespace}, ); deleted != 1 { log.Log.Error(errors.New("Failed to delete metric"), "Incorrect number of deleted metrics", "deleted", deleted) }