From c6777b9b0bfc32eef8168c0d77629a4a9f9be8ce Mon Sep 17 00:00:00 2001 From: Quentin Bisson Date: Mon, 27 May 2024 11:52:37 +0200 Subject: [PATCH] Do not reconcile if mimir is disabled (#29) --- CHANGELOG.md | 4 ++++ internal/controller/cluster_monitoring_controller.go | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfb1a6b2..4dc8f59b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Do nothing if mimir is disabled to avoid deleting prometheus-meta-operator managed resources. + ## [0.0.3] - 2024-05-24 ### Changed diff --git a/internal/controller/cluster_monitoring_controller.go b/internal/controller/cluster_monitoring_controller.go index ba96b33b..d2685361 100644 --- a/internal/controller/cluster_monitoring_controller.go +++ b/internal/controller/cluster_monitoring_controller.go @@ -80,8 +80,13 @@ func (r *ClusterMonitoringReconciler) Reconcile(ctx context.Context, req ctrl.Re return ctrl.Result{}, errors.WithStack(err) } + if !r.MonitoringEnabled { + logger.Info("Monitoring is disabled at the installation level") + return ctrl.Result{}, nil + } + // Handle deletion reconciliation loop. - if !cluster.ObjectMeta.DeletionTimestamp.IsZero() || !r.MonitoringEnabled { + if !cluster.ObjectMeta.DeletionTimestamp.IsZero() { logger.Info("Handling deletion for Cluster", "cluster", cluster.Name) return r.reconcileDelete(ctx, cluster) } @@ -158,6 +163,5 @@ func (r *ClusterMonitoringReconciler) reconcileDelete(ctx context.Context, clust } logger.Info("removed finalizer", "finalizer", monitoring.MonitoringFinalizer) } - controllerutil.RemoveFinalizer(cluster, monitoring.MonitoringFinalizer) return ctrl.Result{}, nil }