Skip to content

Commit 7e61cfa

Browse files
author
tony-landreth
committed
More cleanup around exporter logic
1 parent 50554dd commit 7e61cfa

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

internal/controller/postgrescluster/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ func (r *Reconciler) Reconcile(
383383
err = r.reconcilePGBouncer(ctx, cluster, instances, primaryCertificate, rootCA)
384384
}
385385
if err == nil {
386-
err = r.reconcilePGMonitor(ctx, cluster, instances, monitoringSecret)
386+
err = r.reconcilePGMonitorExporter(ctx, cluster, instances, monitoringSecret)
387387
}
388388
if err == nil {
389389
err = r.reconcileDatabaseInitSQL(ctx, cluster, instances)

internal/controller/postgrescluster/instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ func (r *Reconciler) reconcileInstance(
12231223
}
12241224

12251225
// Add postgres-exporter to the instance Pod spec
1226-
if err == nil && !feature.Enabled(ctx, feature.OpenTelemetryMetrics) {
1226+
if err == nil {
12271227
err = addPGMonitorExporterToInstancePodSpec(ctx, cluster, &instance.Spec.Template, exporterQueriesConfig, exporterWebConfig)
12281228
}
12291229

internal/controller/postgrescluster/pgmonitor.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,6 @@ import (
3131
//go:embed "metrics_setup.sql"
3232
var metricsSetupForOTelCollector string
3333

34-
// If pgMonitor is enabled the pgMonitor sidecar(s) have been added to the
35-
// instance pod. reconcilePGMonitor will update the database to
36-
// create the necessary objects for the tool to run
37-
func (r *Reconciler) reconcilePGMonitor(ctx context.Context,
38-
cluster *v1beta1.PostgresCluster, instances *observedInstances,
39-
monitoringSecret *corev1.Secret) error {
40-
41-
err := r.reconcilePGMonitorExporter(ctx, cluster, instances, monitoringSecret)
42-
43-
return err
44-
}
45-
4634
// reconcilePGMonitorExporter performs setup the postgres_exporter sidecar
4735
// - PodExec to run the sql in the primary database
4836
// Status.Monitoring.ExporterConfiguration is used to determine when the
@@ -247,7 +235,7 @@ func addPGMonitorExporterToInstancePodSpec(
247235
template *corev1.PodTemplateSpec,
248236
exporterQueriesConfig, exporterWebConfig *corev1.ConfigMap) error {
249237

250-
if !pgmonitor.ExporterEnabled(cluster) && !feature.Enabled(ctx, feature.OpenTelemetryMetrics) {
238+
if !pgmonitor.ExporterEnabled(cluster) || feature.Enabled(ctx, feature.OpenTelemetryMetrics) {
251239
return nil
252240
}
253241

0 commit comments

Comments
 (0)