From 158dd0056078273c488c6c53852f4d7d036b0005 Mon Sep 17 00:00:00 2001 From: Andrew O'Neill Date: Fri, 30 Aug 2024 10:04:07 -0700 Subject: [PATCH] Rollback 3187 --- .chloggen/propagate-global-scrape-protocols.yaml | 6 +++--- controllers/builder_test.go | 4 ++-- internal/manifests/collector/config_replace.go | 2 +- internal/manifests/collector/config_replace_test.go | 4 ++-- internal/manifests/collector/configmap_test.go | 2 +- .../testdata/config_expected_targetallocator.yaml | 2 +- .../relabel_config_expected_with_sd_config.yaml | 2 +- .../adapters/config_to_prom_config.go | 8 ++++---- .../adapters/config_to_prom_config_test.go | 12 ++++++------ .../targetallocator-kubernetessd/00-assert.yaml | 2 +- .../targetallocator-kubernetessd/chainsaw-test.yaml | 1 - .../targetallocator-prometheuscr/00-assert.yaml | 2 +- .../targetallocator-prometheuscr/chainsaw-test.yaml | 1 - tests/e2e/smoke-targetallocator/00-assert.yaml | 2 +- tests/e2e/smoke-targetallocator/chainsaw-test.yaml | 1 - 15 files changed, 24 insertions(+), 27 deletions(-) diff --git a/.chloggen/propagate-global-scrape-protocols.yaml b/.chloggen/propagate-global-scrape-protocols.yaml index c9606ca18a..cb47033b7b 100755 --- a/.chloggen/propagate-global-scrape-protocols.yaml +++ b/.chloggen/propagate-global-scrape-protocols.yaml @@ -5,12 +5,12 @@ change_type: enhancement component: target allocator # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). -note: introduces the global field in the TA config to allow for setting scrape protocols +note: Rollback 3187 # One or more tracking issues related to the change -issues: [3160] +issues: [3242] # (Optional) One or more lines of additional information to render under the primary note. # These lines will be padded with 2 spaces and then inserted directly into the document. # Use pipe (|) for multiline entries. -subtext: +subtext: This Rollsback 3187 which breaks TargetAllocator config for clusters with custom domains. diff --git a/controllers/builder_test.go b/controllers/builder_test.go index 2c5070fa84..ec538eaf42 100644 --- a/controllers/builder_test.go +++ b/controllers/builder_test.go @@ -1421,7 +1421,7 @@ service: Annotations: map[string]string{}, }, Data: map[string]string{ - "collector.yaml": "exporters:\n logging: 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 - logging\n receivers:\n - prometheus\n", + "collector.yaml": "exporters:\n logging: 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 - logging\n receivers:\n - prometheus\n", }, }, &corev1.ServiceAccount{ @@ -1878,7 +1878,7 @@ prometheus_cr: Annotations: map[string]string{}, }, Data: map[string]string{ - "collector.yaml": "exporters:\n logging: 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 - logging\n receivers:\n - prometheus\n", + "collector.yaml": "exporters:\n logging: 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 - logging\n receivers:\n - prometheus\n", }, }, &corev1.ServiceAccount{ diff --git a/internal/manifests/collector/config_replace.go b/internal/manifests/collector/config_replace.go index cc21aa29e5..6ea55dc44d 100644 --- a/internal/manifests/collector/config_replace.go +++ b/internal/manifests/collector/config_replace.go @@ -71,7 +71,7 @@ func ReplaceConfig(otelcol v1beta1.OpenTelemetryCollector, targetAllocator *v1al // To avoid issues caused by Prometheus validation logic, which fails regex validation when it encounters // $$ in the prom config, we update the YAML file directly without marshaling and unmarshalling. - updPromCfgMap, getCfgPromErr := ta.AddTAConfigToPromConfig(promCfgMap, naming.TAService(targetAllocator.Name), targetAllocator.Namespace) + updPromCfgMap, getCfgPromErr := ta.AddTAConfigToPromConfig(promCfgMap, naming.TAService(targetAllocator.Name)) if getCfgPromErr != nil { return "", getCfgPromErr } diff --git a/internal/manifests/collector/config_replace_test.go b/internal/manifests/collector/config_replace_test.go index bcc55d9d0b..c57c95efec 100644 --- a/internal/manifests/collector/config_replace_test.go +++ b/internal/manifests/collector/config_replace_test.go @@ -43,7 +43,7 @@ func TestPrometheusParser(t *testing.T) { assert.NotContains(t, prometheusConfig, "scrape_configs") expectedTAConfig := map[interface{}]interface{}{ - "endpoint": "http://test-targetallocator.default.svc.cluster.local:80", + "endpoint": "http://test-targetallocator:80", "interval": "30s", "collector_id": "${POD_NAME}", } @@ -68,7 +68,7 @@ func TestPrometheusParser(t *testing.T) { assert.NotContains(t, prometheusConfig, "scrape_configs") expectedTAConfig := map[interface{}]interface{}{ - "endpoint": "http://test-targetallocator.default.svc.cluster.local:80", + "endpoint": "http://test-targetallocator:80", "interval": "30s", "collector_id": "${POD_NAME}", } diff --git a/internal/manifests/collector/configmap_test.go b/internal/manifests/collector/configmap_test.go index 7236ef1f1c..fc66cf3794 100644 --- a/internal/manifests/collector/configmap_test.go +++ b/internal/manifests/collector/configmap_test.go @@ -84,7 +84,7 @@ receivers: config: {} target_allocator: collector_id: ${POD_NAME} - endpoint: http://test-targetallocator.default.svc.cluster.local:80 + endpoint: http://test-targetallocator:80 interval: 30s service: pipelines: diff --git a/internal/manifests/collector/testdata/config_expected_targetallocator.yaml b/internal/manifests/collector/testdata/config_expected_targetallocator.yaml index af8d7b189f..a43a2bcc56 100644 --- a/internal/manifests/collector/testdata/config_expected_targetallocator.yaml +++ b/internal/manifests/collector/testdata/config_expected_targetallocator.yaml @@ -9,7 +9,7 @@ receivers: scrape_timeout: 10s target_allocator: collector_id: ${POD_NAME} - endpoint: http://test-targetallocator.default.svc.cluster.local:80 + endpoint: http://test-targetallocator:80 interval: 30s service: pipelines: diff --git a/internal/manifests/collector/testdata/relabel_config_expected_with_sd_config.yaml b/internal/manifests/collector/testdata/relabel_config_expected_with_sd_config.yaml index 25329ad5c3..439ec1e310 100644 --- a/internal/manifests/collector/testdata/relabel_config_expected_with_sd_config.yaml +++ b/internal/manifests/collector/testdata/relabel_config_expected_with_sd_config.yaml @@ -10,7 +10,7 @@ receivers: scrape_configs: - honor_labels: true http_sd_configs: - - url: http://test-targetallocator.default.svc.cluster.local:80/jobs/service-x/targets?collector_id=$POD_NAME + - url: http://test-targetallocator:80/jobs/service-x/targets?collector_id=$POD_NAME job_name: service-x metric_relabel_configs: - action: keep diff --git a/internal/manifests/targetallocator/adapters/config_to_prom_config.go b/internal/manifests/targetallocator/adapters/config_to_prom_config.go index 29200e05d7..e0d7cd38e2 100644 --- a/internal/manifests/targetallocator/adapters/config_to_prom_config.go +++ b/internal/manifests/targetallocator/adapters/config_to_prom_config.go @@ -196,7 +196,7 @@ func UnescapeDollarSignsInPromConfig(cfg string) (map[interface{}]interface{}, e // This function removes any existing service discovery configurations (e.g., `sd_configs`, `dns_sd_configs`, `file_sd_configs`, etc.) // from the `scrape_configs` section and adds a single `http_sd_configs` configuration. // The `http_sd_configs` points to the TA (Target Allocator) endpoint that provides the list of targets for the given job. -func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string, taNamespace string) (map[interface{}]interface{}, error) { +func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string) (map[interface{}]interface{}, error) { prometheusConfigProperty, ok := prometheus["config"] if !ok { return nil, errorNoComponent("prometheusConfig") @@ -249,7 +249,7 @@ func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServi escapedJob := url.QueryEscape(jobName) scrapeConfig["http_sd_configs"] = []interface{}{ map[string]interface{}{ - "url": fmt.Sprintf("http://%s.%s.svc.cluster.local:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, taNamespace, escapedJob), + "url": fmt.Sprintf("http://%s:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, escapedJob), }, } } @@ -260,7 +260,7 @@ func AddHTTPSDConfigToPromConfig(prometheus map[interface{}]interface{}, taServi // AddTAConfigToPromConfig adds or updates the target_allocator configuration in the Prometheus configuration. // If the `EnableTargetAllocatorRewrite` feature flag for the target allocator is enabled, this function // removes the existing scrape_configs from the collector's Prometheus configuration as it's not required. -func AddTAConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string, taNamespace string) (map[interface{}]interface{}, error) { +func AddTAConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceName string) (map[interface{}]interface{}, error) { prometheusConfigProperty, ok := prometheus["config"] if !ok { return nil, errorNoComponent("prometheusConfig") @@ -281,7 +281,7 @@ func AddTAConfigToPromConfig(prometheus map[interface{}]interface{}, taServiceNa return nil, errorNotAMap("target_allocator") } - targetAllocatorCfg["endpoint"] = fmt.Sprintf("http://%s.%s.svc.cluster.local:80", taServiceName, taNamespace) + targetAllocatorCfg["endpoint"] = fmt.Sprintf("http://%s:80", taServiceName) targetAllocatorCfg["interval"] = "30s" targetAllocatorCfg["collector_id"] = "${POD_NAME}" diff --git a/internal/manifests/targetallocator/adapters/config_to_prom_config_test.go b/internal/manifests/targetallocator/adapters/config_to_prom_config_test.go index 45bef4c082..2ad7b741c6 100644 --- a/internal/manifests/targetallocator/adapters/config_to_prom_config_test.go +++ b/internal/manifests/targetallocator/adapters/config_to_prom_config_test.go @@ -279,7 +279,7 @@ func TestAddHTTPSDConfigToPromConfig(t *testing.T) { "job_name": "test_job", "http_sd_configs": []interface{}{ map[string]interface{}{ - "url": fmt.Sprintf("http://%s.default.svc.cluster.local:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, url.QueryEscape("test_job")), + "url": fmt.Sprintf("http://%s:80/jobs/%s/targets?collector_id=$POD_NAME", taServiceName, url.QueryEscape("test_job")), }, }, }, @@ -287,7 +287,7 @@ func TestAddHTTPSDConfigToPromConfig(t *testing.T) { }, } - actualCfg, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName, "default") + actualCfg, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName) assert.NoError(t, err) assert.Equal(t, expectedCfg, actualCfg) }) @@ -308,7 +308,7 @@ func TestAddHTTPSDConfigToPromConfig(t *testing.T) { taServiceName := "test-service" - _, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName, "default") + _, err := ta.AddHTTPSDConfigToPromConfig(cfg, taServiceName) assert.Error(t, err) assert.EqualError(t, err, "no scrape_configs available as part of the configuration") }) @@ -338,13 +338,13 @@ func TestAddTAConfigToPromConfig(t *testing.T) { expectedResult := map[interface{}]interface{}{ "config": map[interface{}]interface{}{}, "target_allocator": map[interface{}]interface{}{ - "endpoint": "http://test-targetallocator.default.svc.cluster.local:80", + "endpoint": "http://test-targetallocator:80", "interval": "30s", "collector_id": "${POD_NAME}", }, } - result, err := ta.AddTAConfigToPromConfig(cfg, taServiceName, "default") + result, err := ta.AddTAConfigToPromConfig(cfg, taServiceName) assert.NoError(t, err) assert.Equal(t, expectedResult, result) @@ -374,7 +374,7 @@ func TestAddTAConfigToPromConfig(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - _, err := ta.AddTAConfigToPromConfig(tc.cfg, taServiceName, "default") + _, err := ta.AddTAConfigToPromConfig(tc.cfg, taServiceName) assert.Error(t, err) assert.EqualError(t, err, tc.errText) diff --git a/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml index 267d76ed37..93f7e176a2 100644 --- a/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-kubernetessd/00-assert.yaml @@ -26,7 +26,7 @@ data: config: {} target_allocator: collector_id: ${POD_NAME} - endpoint: http://prometheus-kubernetessd-targetallocator.chainsaw-targetallocator-kubernetessd.svc.cluster.local:80 + endpoint: http://prometheus-kubernetessd-targetallocator:80 interval: 30s service: pipelines: diff --git a/tests/e2e-targetallocator/targetallocator-kubernetessd/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-kubernetessd/chainsaw-test.yaml index e6cdf4bfcd..8e5aae1b58 100755 --- a/tests/e2e-targetallocator/targetallocator-kubernetessd/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-kubernetessd/chainsaw-test.yaml @@ -5,7 +5,6 @@ metadata: creationTimestamp: null name: targetallocator-kubernetessd spec: - namespace: chainsaw-targetallocator-kubernetessd steps: - name: step-00 try: diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml index 9a95fabc90..dd705e927b 100644 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/00-assert.yaml @@ -31,7 +31,7 @@ data: config: {} target_allocator: collector_id: ${POD_NAME} - endpoint: http://prometheus-cr-targetallocator.chainsaw-targetallocator-prometheuscr.svc.cluster.local:80 + endpoint: http://prometheus-cr-targetallocator:80 interval: 30s service: pipelines: diff --git a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml index e9591dd57d..c361477488 100755 --- a/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml +++ b/tests/e2e-targetallocator/targetallocator-prometheuscr/chainsaw-test.yaml @@ -5,7 +5,6 @@ metadata: creationTimestamp: null name: targetallocator-prometheuscr spec: - namespace: chainsaw-targetallocator-prometheuscr steps: - name: step-00 try: diff --git a/tests/e2e/smoke-targetallocator/00-assert.yaml b/tests/e2e/smoke-targetallocator/00-assert.yaml index 095ea679d5..14e41f7002 100644 --- a/tests/e2e/smoke-targetallocator/00-assert.yaml +++ b/tests/e2e/smoke-targetallocator/00-assert.yaml @@ -40,7 +40,7 @@ data: - PrometheusText0.0.4 target_allocator: collector_id: ${POD_NAME} - endpoint: http://stateful-targetallocator.chainsaw-smoke-targetallocator.svc.cluster.local:80 + endpoint: http://stateful-targetallocator:80 interval: 30s service: pipelines: diff --git a/tests/e2e/smoke-targetallocator/chainsaw-test.yaml b/tests/e2e/smoke-targetallocator/chainsaw-test.yaml index aca5291cae..ea19c198f6 100755 --- a/tests/e2e/smoke-targetallocator/chainsaw-test.yaml +++ b/tests/e2e/smoke-targetallocator/chainsaw-test.yaml @@ -5,7 +5,6 @@ metadata: creationTimestamp: null name: smoke-targetallocator spec: - namespace: chainsaw-smoke-targetallocator steps: - name: step-00 try: