Skip to content

Commit 2a67c3f

Browse files
committed
add review comments
Signed-off-by: Mario Fernandez <[email protected]>
1 parent 1a8653f commit 2a67c3f

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

pkg/manifests/manifests.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,17 +1161,6 @@ func (f *Factory) ThanosRulerAlertmanagerConfigSecret() (*v1.Secret, error) {
11611161
return nil, err
11621162
}
11631163

1164-
switch alertingConfiguration.Alertmanagers[0].Scheme {
1165-
case "http":
1166-
if proxy := f.proxy.HTTPProxy(); proxy != "" {
1167-
alertingConfiguration.Alertmanagers[0].ProxyURL = proxy
1168-
}
1169-
case "https":
1170-
if proxy := f.proxy.HTTPSProxy(); proxy != "" {
1171-
alertingConfiguration.Alertmanagers[0].ProxyURL = proxy
1172-
}
1173-
}
1174-
11751164
if f.config.UserWorkloadConfiguration.Alertmanager.Enabled {
11761165
alertingConfiguration.Alertmanagers[0].HTTPConfig.TLSConfig.ServerName = fmt.Sprintf(
11771166
"%s.%s.svc",
@@ -1808,7 +1797,7 @@ func (f *Factory) PrometheusUserWorkload(grpcTLS *v1.Secret) (*monv1.Prometheus,
18081797
PeriodSeconds: 15,
18091798
FailureThreshold: 240,
18101799
}
1811-
1800+
// Inject the proxy env vars into the Prometheus container for configuring external Alertmanagers
18121801
f.injectProxyVariables(&p.Spec.Containers[i])
18131802
case "kube-rbac-proxy-metrics", "kube-rbac-proxy-federate", "kube-rbac-proxy-thanos":
18141803
p.Spec.Containers[i].Image = f.config.Images.KubeRbacProxy

pkg/manifests/manifests_test.go

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
22602260
server_name: alertmanager-main.openshift-monitoring.svc
22612261
static_configs:
22622262
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2263-
proxy_url: https://example.com:8080/
22642263
`,
22652264
},
22662265
{
@@ -2278,7 +2277,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
22782277
server_name: alertmanager-user-workload.openshift-user-workload-monitoring.svc
22792278
static_configs:
22802279
- dnssrv+_web._tcp.alertmanager-operated.openshift-user-workload-monitoring.svc
2281-
proxy_url: https://example.com:8080/
22822280
`,
22832281
},
22842282
{
@@ -2299,7 +2297,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
22992297
server_name: alertmanager-main.openshift-monitoring.svc
23002298
static_configs:
23012299
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2302-
proxy_url: https://example.com:8080/
23032300
- static_configs:
23042301
- alertmanager1-remote.com
23052302
- alertmanager1-remotex.com
@@ -2343,7 +2340,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
23432340
server_name: alertmanager-main.openshift-monitoring.svc
23442341
static_configs:
23452342
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2346-
proxy_url: https://example.com:8080/
23472343
- scheme: https
23482344
path_prefix: /path-prefix
23492345
api_version: v2
@@ -2374,7 +2370,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
23742370
server_name: alertmanager-main.openshift-monitoring.svc
23752371
static_configs:
23762372
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2377-
proxy_url: https://example.com:8080/
23782373
- http_config:
23792374
bearer_token_file: /etc/prometheus/secrets/bearer-token/key
23802375
static_configs:
@@ -2411,7 +2406,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
24112406
server_name: alertmanager-main.openshift-monitoring.svc
24122407
static_configs:
24132408
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2414-
proxy_url: https://example.com:8080/
24152409
- http_config:
24162410
tls_config:
24172411
ca_file: /etc/prometheus/secrets/alertmanager-tls/tls.ca
@@ -2452,7 +2446,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
24522446
server_name: alertmanager-main.openshift-monitoring.svc
24532447
static_configs:
24542448
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2455-
proxy_url: https://example.com:8080/
24562449
- http_config:
24572450
tls_config:
24582451
ca_file: /etc/prometheus/secrets/alertmanager-ca-tls/tls.ca
@@ -2497,7 +2490,6 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
24972490
server_name: alertmanager-main.openshift-monitoring.svc
24982491
static_configs:
24992492
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2500-
proxy_url: https://example.com:8080/
25012493
- scheme: https
25022494
api_version: v2
25032495
http_config:
@@ -2511,6 +2503,36 @@ func TestThanosRulerAdditionalAlertManagerConfigsSecret(t *testing.T) {
25112503
- alertmanager1-remote.com
25122504
- alertmanager1-remotex.com
25132505
proxy_url: https://example.com:8080/
2506+
`,
2507+
},
2508+
{
2509+
name: "proxy env http",
2510+
userWorkloadConfig: `thanosRuler:
2511+
additionalAlertmanagerConfigs:
2512+
- apiVersion: v2
2513+
pathPrefix: /path-prefix
2514+
scheme: http
2515+
staticConfigs:
2516+
- alertmanager1-remote.com
2517+
- alertmanager1-remotex.com
2518+
`,
2519+
expected: `alertmanagers:
2520+
- scheme: https
2521+
api_version: v2
2522+
http_config:
2523+
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
2524+
tls_config:
2525+
ca_file: /etc/prometheus/configmaps/serving-certs-ca-bundle/service-ca.crt
2526+
server_name: alertmanager-main.openshift-monitoring.svc
2527+
static_configs:
2528+
- dnssrv+_web._tcp.alertmanager-operated.openshift-monitoring.svc
2529+
- scheme: http
2530+
path_prefix: /path-prefix
2531+
api_version: v2
2532+
static_configs:
2533+
- alertmanager1-remote.com
2534+
- alertmanager1-remotex.com
2535+
proxy_url: http://example.com:8080/
25142536
`,
25152537
},
25162538
}

0 commit comments

Comments
 (0)