Skip to content

Commit dfbf0b8

Browse files
authored
Rollback 3187 (#3248)
# Conflicts: # controllers/builder_test.go
1 parent 09d0758 commit dfbf0b8

File tree

15 files changed

+37
-24
lines changed

15 files changed

+37
-24
lines changed

.chloggen/3242-rollback-of-3187.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: bug_fix
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: target allocator
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: Rollback 3187
9+
10+
# One or more tracking issues related to the change
11+
issues: [3242]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext: This Rollsback 3187 which breaks TargetAllocator config for clusters with custom domains.

controllers/builder_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ service:
14211421
Annotations: map[string]string{},
14221422
},
14231423
Data: map[string]string{
1424-
"collector.yaml": "exporters:\n debug: null\nreceivers:\n prometheus:\n config: {}\n target_allocator:\n collector_id: ${POD_NAME}\n endpoint: http://test-targetallocator.test.svc.cluster.local:80\n interval: 30s\nservice:\n pipelines:\n metrics:\n exporters:\n - debug\n receivers:\n - prometheus\n",
1424+
"collector.yaml": "exporters:\n debug: null\nreceivers:\n prometheus:\n config: {}\n target_allocator:\n collector_id: ${POD_NAME}\n endpoint: http://test-targetallocator:80\n interval: 30s\nservice:\n pipelines:\n metrics:\n exporters:\n - debug\n receivers:\n - prometheus\n",
14251425
},
14261426
},
14271427
&corev1.ServiceAccount{
@@ -1878,7 +1878,7 @@ prometheus_cr:
18781878
Annotations: map[string]string{},
18791879
},
18801880
Data: map[string]string{
1881-
"collector.yaml": "exporters:\n debug: null\nreceivers:\n prometheus:\n config: {}\n target_allocator:\n collector_id: ${POD_NAME}\n endpoint: http://test-targetallocator.test.svc.cluster.local:80\n interval: 30s\nservice:\n pipelines:\n metrics:\n exporters:\n - debug\n receivers:\n - prometheus\n",
1881+
"collector.yaml": "exporters:\n debug: null\nreceivers:\n prometheus:\n config: {}\n target_allocator:\n collector_id: ${POD_NAME}\n endpoint: http://test-targetallocator:80\n interval: 30s\nservice:\n pipelines:\n metrics:\n exporters:\n - debug\n receivers:\n - prometheus\n",
18821882
},
18831883
},
18841884
&corev1.ServiceAccount{

internal/manifests/collector/config_replace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func ReplaceConfig(otelcol v1beta1.OpenTelemetryCollector, targetAllocator *v1al
7171

7272
// To avoid issues caused by Prometheus validation logic, which fails regex validation when it encounters
7373
// $$ in the prom config, we update the YAML file directly without marshaling and unmarshalling.
74-
updPromCfgMap, getCfgPromErr := ta.AddTAConfigToPromConfig(promCfgMap, naming.TAService(targetAllocator.Name), targetAllocator.Namespace)
74+
updPromCfgMap, getCfgPromErr := ta.AddTAConfigToPromConfig(promCfgMap, naming.TAService(targetAllocator.Name))
7575
if getCfgPromErr != nil {
7676
return "", getCfgPromErr
7777
}

internal/manifests/collector/config_replace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestPrometheusParser(t *testing.T) {
4343
assert.NotContains(t, prometheusConfig, "scrape_configs")
4444

4545
expectedTAConfig := map[interface{}]interface{}{
46-
"endpoint": "http://test-targetallocator.default.svc.cluster.local:80",
46+
"endpoint": "http://test-targetallocator:80",
4747
"interval": "30s",
4848
"collector_id": "${POD_NAME}",
4949
}
@@ -68,7 +68,7 @@ func TestPrometheusParser(t *testing.T) {
6868
assert.NotContains(t, prometheusConfig, "scrape_configs")
6969

7070
expectedTAConfig := map[interface{}]interface{}{
71-
"endpoint": "http://test-targetallocator.default.svc.cluster.local:80",
71+
"endpoint": "http://test-targetallocator:80",
7272
"interval": "30s",
7373
"collector_id": "${POD_NAME}",
7474
}

internal/manifests/collector/configmap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ receivers:
8484
config: {}
8585
target_allocator:
8686
collector_id: ${POD_NAME}
87-
endpoint: http://test-targetallocator.default.svc.cluster.local:80
87+
endpoint: http://test-targetallocator:80
8888
interval: 30s
8989
service:
9090
pipelines:

internal/manifests/collector/testdata/config_expected_targetallocator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ receivers:
99
scrape_timeout: 10s
1010
target_allocator:
1111
collector_id: ${POD_NAME}
12-
endpoint: http://test-targetallocator.default.svc.cluster.local:80
12+
endpoint: http://test-targetallocator:80
1313
interval: 30s
1414
service:
1515
pipelines:

internal/manifests/collector/testdata/relabel_config_expected_with_sd_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ receivers:
1010
scrape_configs:
1111
- honor_labels: true
1212
http_sd_configs:
13-
- url: http://test-targetallocator.default.svc.cluster.local:80/jobs/service-x/targets?collector_id=$POD_NAME
13+
- url: http://test-targetallocator:80/jobs/service-x/targets?collector_id=$POD_NAME
1414
job_name: service-x
1515
metric_relabel_configs:
1616
- action: keep

internal/manifests/targetallocator/adapters/config_to_prom_config.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ func UnescapeDollarSignsInPromConfig(cfg string) (map[interface{}]interface{}, e
196196
// This function removes any existing service discovery configurations (e.g., `sd_configs`, `dns_sd_configs`, `file_sd_configs`, etc.)
197197
// from the `scrape_configs` section and adds a single `http_sd_configs` configuration.
198198
// The `http_sd_configs` points to the TA (Target Allocator) endpoint that provides the list of targets for the given job.
199-
func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string, taNamespace string) (map[interface{}]interface{}, error) {
199+
func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string) (map[interface{}]interface{}, error) {
200200
prometheusConfigProperty, ok := prometheus["config"]
201201
if !ok {
202202
return nil, errorNoComponent("prometheusConfig")
@@ -249,7 +249,7 @@ func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServi
249249
escapedJob := url.QueryEscape(jobName)
250250
scrapeConfig["http_sd_configs"] = []interface{}{
251251
map[string]interface{}{
252-
"url": fmt.Sprintf("http://%s.%s.svc.cluster.local:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, taNamespace, escapedJob),
252+
"url": fmt.Sprintf("http://%s:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, escapedJob),
253253
},
254254
}
255255
}
@@ -260,7 +260,7 @@ func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServi
260260
// AddTAConfigToPromConfig adds or updates the target_allocator configuration in the Prometheus configuration.
261261
// If the `EnableTargetAllocatorRewrite` feature flag for the target allocator is enabled, this function
262262
// removes the existing scrape_configs from the collector's Prometheus configuration as it's not required.
263-
func AddTAConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string, taNamespace string) (map[interface{}]interface{}, error) {
263+
func AddTAConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string) (map[interface{}]interface{}, error) {
264264
prometheusConfigProperty, ok := prometheus["config"]
265265
if !ok {
266266
return nil, errorNoComponent("prometheusConfig")
@@ -281,7 +281,7 @@ func AddTAConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceNa
281281
return nil, errorNotAMap("target_allocator")
282282
}
283283

284-
targetAllocatorCfg["endpoint"] = fmt.Sprintf("http://%s.%s.svc.cluster.local:80", taServiceName, taNamespace)
284+
targetAllocatorCfg["endpoint"] = fmt.Sprintf("http://%s:80", taServiceName)
285285
targetAllocatorCfg["interval"] = "30s"
286286
targetAllocatorCfg["collector_id"] = "${POD_NAME}"
287287

internal/manifests/targetallocator/adapters/config_to_prom_config_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ func TestAddHTTPSDConfigToPromConfig(t *testing.T) {
279279
"job_name": "test_job",
280280
"http_sd_configs": []interface{}{
281281
map[string]interface{}{
282-
"url": fmt.Sprintf("http://%s.default.svc.cluster.local:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, url.QueryEscape("test_job")),
282+
"url": fmt.Sprintf("http://%s:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, url.QueryEscape("test_job")),
283283
},
284284
},
285285
},
286286
},
287287
},
288288
}
289289

290-
actualCfg, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName, "default")
290+
actualCfg, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName)
291291
assert.NoError(t, err)
292292
assert.Equal(t, expectedCfg, actualCfg)
293293
})
@@ -308,7 +308,7 @@ func TestAddHTTPSDConfigToPromConfig(t *testing.T) {
308308

309309
taServiceName := "test-service"
310310

311-
_, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName, "default")
311+
_, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName)
312312
assert.Error(t, err)
313313
assert.EqualError(t, err, "no scrape_configs available as part of the configuration")
314314
})
@@ -338,13 +338,13 @@ func TestAddTAConfigToPromConfig(t *testing.T) {
338338
expectedResult := map[interface{}]interface{}{
339339
"config": map[interface{}]interface{}{},
340340
"target_allocator": map[interface{}]interface{}{
341-
"endpoint": "http://test-targetallocator.default.svc.cluster.local:80",
341+
"endpoint": "http://test-targetallocator:80",
342342
"interval": "30s",
343343
"collector_id": "${POD_NAME}",
344344
},
345345
}
346346

347-
result, err := ta.AddTAConfigToPromConfig(cfg, taServiceName, "default")
347+
result, err := ta.AddTAConfigToPromConfig(cfg, taServiceName)
348348

349349
assert.NoError(t, err)
350350
assert.Equal(t, expectedResult, result)
@@ -374,7 +374,7 @@ func TestAddTAConfigToPromConfig(t *testing.T) {
374374

375375
for _, tc := range testCases {
376376
t.Run(tc.name, func(t *testing.T) {
377-
_, err := ta.AddTAConfigToPromConfig(tc.cfg, taServiceName, "default")
377+
_, err := ta.AddTAConfigToPromConfig(tc.cfg, taServiceName)
378378

379379
assert.Error(t, err)
380380
assert.EqualError(t, err, tc.errText)

tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data:
2626
config: {}
2727
target_allocator:
2828
collector_id: ${POD_NAME}
29-
endpoint: http://prometheus-kubernetessd-targetallocator.chainsaw-targetallocator-kubernetessd.svc.cluster.local:80
29+
endpoint: http://prometheus-kubernetessd-targetallocator:80
3030
interval: 30s
3131
service:
3232
pipelines:

0 commit comments

Comments
 (0)