Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumEnigmaa committed May 21, 2024
1 parent 9302fa5 commit c0cd3ab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 20 deletions.
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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")
Expand Down
26 changes: 7 additions & 19 deletions pkg/monitoring/mimir/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package mimir

import (
"context"
"fmt"

"github.com/go-logr/logr"
"github.com/pkg/errors"
Expand All @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/monitoring/mimir/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c0cd3ab

Please sign in to comment.