Skip to content

Commit b0275ce

Browse files
authored
fix: respect debug mode setting in configmap v1 (#1191)
[comment]: # (Note that your PR title should follow the conventional commit format: https://conventionalcommits.org/en/v1.0.0/#summary) # PR Description [comment]: # (The below checklist is for PRs adding new features. If a box is not checked, add a reason why it's not needed.) # New Feature Checklist - [ ] List telemetry added about the feature. - [ ] Link to the one-pager about the feature. - [ ] List any tasks necessary for release (3P docs, AKS RP chart changes, etc.) after merging the PR. - [ ] Attach results of scale and perf testing. [comment]: # (The below checklist is for code changes. Not all boxes necessarily need to be checked. Build, doc, and template changes do not need to fill out the checklist.) # Tests Checklist - [ ] Have end-to-end Ginkgo tests been run on your cluster and passed? To bootstrap your cluster to run the tests, follow [these instructions](/otelcollector/test/README.md#bootstrap-a-dev-cluster-to-run-ginkgo-tests). - Labels used when running the tests on your cluster: - [ ] `operator` - [ ] `windows` - [ ] `arm64` - [ ] `arc-extension` - [ ] `fips` - [ ] Have new tests been added? For features, have tests been added for this feature? For fixes, is there a test that could have caught this issue and could validate that the fix works? - [ ] Is a new scrape job needed? - [ ] The scrape job was added to the folder [test-cluster-yamls](/otelcollector/test/test-cluster-yamls/) in the correct configmap or as a CR. - [ ] Was a new test label added? - [ ] A string constant for the label was added to [constants.go](/otelcollector/test/utils/constants.go). - [ ] The label and description was added to the [test README](/otelcollector/test/README.md). - [ ] The label was added to this [PR checklist](/.github/pull_request_template). - [ ] The label was added as needed to [testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml). - [ ] Are additional API server permissions needed for the new tests? - [ ] These permissions have been added to [api-server-permissions.yaml](/otelcollector/test/testkube/api-server-permissions.yaml). - [ ] Was a new test suite (a new folder under `/tests`) added? - [ ] The new test suite is included in [testkube-test-crs.yaml](/otelcollector/test/testkube/testkube-test-crs.yaml).
1 parent 8631a1f commit b0275ce

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

otelcollector/shared/configmap/mp/tomlparser-debug-mode.go

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,50 @@ func ConfigureDebugModeSettings(metricsConfigBySection map[string]map[string]str
8585
}
8686

8787
func populateSettingValuesFromConfigMap(metricsConfigBySection map[string]map[string]string) bool {
88-
debugSettings, ok := metricsConfigBySection["prometheus-collector-settings"]
89-
if !ok {
90-
fmt.Println("The 'prometheus-collector-settings' section is not present in the parsed data. Using default value: false")
88+
debugSettings := "false"
89+
configSchemaVersion := os.Getenv("AZMON_AGENT_CFG_SCHEMA_VERSION")
90+
91+
if configSchemaVersion == "" {
92+
fmt.Println("AZMON_AGENT_CFG_SCHEMA_VERSION environment variable is not set. Using default value: false")
9193
return false
9294
}
9395

94-
val, ok := debugSettings["debug-mode"]
95-
if !ok {
96-
fmt.Println("The 'debug-mode' section is not present in the parsed data. Using default value: false")
96+
configSchemaVersion = strings.TrimSpace(configSchemaVersion)
97+
98+
if configSchemaVersion == "v1" {
99+
debugModeSection, ok := metricsConfigBySection["debug-mode"]
100+
if !ok {
101+
fmt.Println("The 'debug-mode' section is not present in the parsed data. Using default value: false")
102+
return false
103+
}
104+
105+
val, ok := debugModeSection["enabled"]
106+
if !ok {
107+
fmt.Println("The 'enabled' field in 'debug-mode' section is not present in the parsed data. Using default value: false")
108+
return false
109+
}
110+
debugSettings = val
111+
112+
} else if configSchemaVersion == "v2" {
113+
prometheusSettings, ok := metricsConfigBySection["prometheus-collector-settings"]
114+
if !ok {
115+
fmt.Println("The 'prometheus-collector-settings' section is not present in the parsed data. Using default value: false")
116+
return false
117+
}
118+
119+
val, ok := prometheusSettings["debug-mode"]
120+
if !ok {
121+
fmt.Println("The 'debug-mode' section is not present in the parsed data. Using default value: false")
122+
return false
123+
}
124+
debugSettings = val
125+
126+
} else {
127+
fmt.Printf("Unsupported config schema version: %s. Using default value: false\n", configSchemaVersion)
97128
return false
98129
}
99130

100-
enabled := strings.ToLower(val) == "true"
131+
enabled := strings.ToLower(debugSettings) == "true"
101132
fmt.Printf("Using configmap setting for debug mode: %v\n", enabled)
102133
return enabled
103134
}

0 commit comments

Comments
 (0)