From 14ad86e05c731c8dea9c49792be1667d4f6a6fed Mon Sep 17 00:00:00 2001 From: Lance Bragstad Date: Tue, 30 Jul 2024 12:36:55 -0500 Subject: [PATCH] Fix arguments for SafeTLSConfig to use prometheus client 0.75.2 The function for `SafeTLSConfig` changed to accept a pointer to a string instead of a string. Update our usage so that the dependency bump doesn't fail. --- cmd/manager/operator.go | 3 ++- cmd/manager/operator_test.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/manager/operator.go b/cmd/manager/operator.go index 94b15e5a6..beaf27773 100644 --- a/cmd/manager/operator.go +++ b/cmd/manager/operator.go @@ -682,6 +682,7 @@ func getDefaultRoles(platform PlatformType) []string { } func generateOperatorServiceMonitor(service *v1.Service, namespace, secretName string) *monitoring.ServiceMonitor { + serverName := "metrics." + namespace + ".svc" serviceMonitor := GenerateServiceMonitor(service) for i := range serviceMonitor.Spec.Endpoints { if serviceMonitor.Spec.Endpoints[i].Port == ctrlMetrics.ControllerMetricsServiceName { @@ -698,7 +699,7 @@ func generateOperatorServiceMonitor(service *v1.Service, namespace, secretName s } serviceMonitor.Spec.Endpoints[i].TLSConfig = &monitoring.TLSConfig{ SafeTLSConfig: monitoring.SafeTLSConfig{ - ServerName: "metrics." + namespace + ".svc", + ServerName: &serverName, }, CAFile: serviceMonitorTLSCAFile, } diff --git a/cmd/manager/operator_test.go b/cmd/manager/operator_test.go index e2c63ea84..b7802f242 100644 --- a/cmd/manager/operator_test.go +++ b/cmd/manager/operator_test.go @@ -26,9 +26,10 @@ var _ = Describe("Operator Startup Function tests", func() { metricService := operatorMetricService("foobar") sm := generateOperatorServiceMonitor(metricService, "foobar", "secret") controllerMetricServiceFound := false + expectedServerName := "metrics.foobar.svc" for _, ep := range sm.Spec.Endpoints { if ep.Port == metrics.ControllerMetricsServiceName && ep.TLSConfig != nil { - Expect(ep.TLSConfig.ServerName).To(BeEquivalentTo("metrics.foobar.svc")) + Expect(ep.TLSConfig.ServerName).To(BeEquivalentTo(&expectedServerName)) controllerMetricServiceFound = true } }