From c6d21a3100008e10f02c50ae1a0ad57a51a6bafd Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 20 Sep 2022 16:29:05 +0200 Subject: [PATCH] Refactor logic in PrometheusK8s() to decide if remote-write needs to be configured or not for telemetry --- pkg/manifests/manifests.go | 2 +- pkg/tasks/prometheus.go | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/manifests/manifests.go b/pkg/manifests/manifests.go index 74aa60fa99..d7e77f77c5 100644 --- a/pkg/manifests/manifests.go +++ b/pkg/manifests/manifests.go @@ -1637,7 +1637,7 @@ func (f *Factory) PrometheusK8s(grpcTLS *v1.Secret, trustedCABundleCM *v1.Config } clusterID := f.config.ClusterMonitoringConfiguration.TelemeterClientConfig.ClusterID - if telemetrySecret != nil { + if f.config.ClusterMonitoringConfiguration.TelemeterClientConfig.IsEnabled() && f.config.RemoteWrite { selectorRelabelConfig, err := promqlgen.LabelSelectorsToRelabelConfig(f.config.ClusterMonitoringConfiguration.PrometheusK8sConfig.TelemetryMatches) if err != nil { return nil, errors.Wrap(err, "generate label selector relabel config") diff --git a/pkg/tasks/prometheus.go b/pkg/tasks/prometheus.go index 86fa4886aa..ee5fd967db 100644 --- a/pkg/tasks/prometheus.go +++ b/pkg/tasks/prometheus.go @@ -323,9 +323,6 @@ func (t *PrometheusTask) Run(ctx context.Context) error { if err = t.client.DeleteSecret(ctx, telemetrySecret); err != nil { return errors.Wrap(err, "deleting Prometheus telemetry secret failed") } - - // Reset variable to not send telemetry via remote-write. - telemetrySecret = nil } {