diff --git a/main.go b/main.go index 1d40ecd8..b705ad8a 100644 --- a/main.go +++ b/main.go @@ -42,6 +42,7 @@ import ( "github.com/giantswarm/observability-operator/pkg/common/organization" "github.com/giantswarm/observability-operator/pkg/common/password" "github.com/giantswarm/observability-operator/pkg/monitoring/heartbeat" + "github.com/giantswarm/observability-operator/pkg/monitoring/mimir" "github.com/giantswarm/observability-operator/pkg/monitoring/prometheusagent" //+kubebuilder:scaffold:imports ) @@ -195,11 +196,16 @@ func main() { PrometheusVersion: prometheusVersion, } + mimirService := mimir.MimirService{ + Client: mgr.GetClient(), + } + if err = (&controller.ClusterMonitoringReconciler{ Client: mgr.GetClient(), ManagementCluster: managementCluster, HeartbeatRepository: heartbeatRepository, PrometheusAgentService: prometheusAgentService, + MimirService: mimirService, MonitoringEnabled: monitoringEnabled, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Cluster") diff --git a/pkg/monitoring/mimir/service.go b/pkg/monitoring/mimir/service.go index 54de33ee..15fe0603 100644 --- a/pkg/monitoring/mimir/service.go +++ b/pkg/monitoring/mimir/service.go @@ -2,6 +2,7 @@ package mimir import ( "context" + "fmt" "github.com/go-logr/logr" "github.com/pkg/errors" @@ -23,7 +24,7 @@ func (ms *MimirService) ConfigureMimir(ctx context.Context, mc string) error { logger := log.FromContext(ctx).WithValues("cluster", mc) logger.Info("ensuring mimir config") - err := ms.CreateOrUpdateIngressSecret(ctx, mc, logger) + err := ms.CreateIngressSecret(ctx, mc, logger) if err != nil { logger.Error(err, "failed to create or update mimir config") return errors.WithStack(err) @@ -34,7 +35,7 @@ func (ms *MimirService) ConfigureMimir(ctx context.Context, mc string) error { return nil } -func (ms *MimirService) CreateOrUpdateIngressSecret(ctx context.Context, mc string, logger logr.Logger) error { +func (ms *MimirService) CreateIngressSecret(ctx context.Context, mc string, logger logr.Logger) error { objectKey := client.ObjectKey{ Name: ingressSecretName, Namespace: ingressSecretNamespace, @@ -67,23 +68,6 @@ func (ms *MimirService) CreateOrUpdateIngressSecret(ctx context.Context, mc stri return errors.WithStack(err) } - // UPDATE SECRET - /* password, err := readRemoteWritePasswordFromSecret(*current) - if err != nil { - return errors.WithStack(err) - } - - desired, err := pas.buildRemoteWriteSecret(cluster, password, mimirEnabled) - if err != nil { - return errors.WithStack(err) - } - if !reflect.DeepEqual(current.Data, desired.Data) || !reflect.DeepEqual(current.Finalizers, desired.Finalizers) { - err = pas.Client.Update(ctx, desired) - if err != nil { - return errors.WithStack(err) - } - } */ - return nil } @@ -94,11 +78,13 @@ func (ms *MimirService) DeleteIngressSecret(ctx context.Context) error { } current := &corev1.Secret{} // Get the current secret if it exists. + fmt.Println("GETTING SECRET") err := ms.Client.Get(ctx, objectKey, current) if apierrors.IsNotFound(err) { // Ignore cases where the secret is not found (if it was manually deleted, for instance). return nil } else if err != nil { + fmt.Println("ERROR FINDING SECRET") return errors.WithStack(err) } @@ -107,11 +93,13 @@ func (ms *MimirService) DeleteIngressSecret(ctx context.Context) error { controllerutil.RemoveFinalizer(desired, monitoring.MonitoringFinalizer) err = ms.Client.Patch(ctx, current, client.MergeFrom(desired)) if err != nil { + fmt.Println("ERROR REMOVING FINALIZER") return errors.WithStack(err) } err = ms.Client.Delete(ctx, desired) if err != nil { + fmt.Println("ERROR DELETING SECRET") return errors.WithStack(err) } diff --git a/pkg/monitoring/mimir/utils.go b/pkg/monitoring/mimir/utils.go index bbb8f0e4..7d415ca4 100644 --- a/pkg/monitoring/mimir/utils.go +++ b/pkg/monitoring/mimir/utils.go @@ -31,7 +31,7 @@ func GetMimirIngressPassword(ctx context.Context, mc string) (string, error) { err = c.Get(ctx, client.ObjectKey{ Name: fmt.Sprintf("%s-remote-write-secret", mc), - Namespace: "org-gintswarm", + Namespace: "org-giantswarm", }, secret) if err != nil { return "", err