Skip to content

Commit

Permalink
Fix arguments for SafeTLSConfig to use prometheus client 0.75.2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rhmdnd committed Jul 31, 2024
1 parent 3ddb72a commit 14ad86e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/manager/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/manager/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 14ad86e

Please sign in to comment.