Skip to content

Commit fdcd5b2

Browse files
committed
fix: false-positive Stackdriver error in diagnose
`operator diagnose` contains checks to validate your Telemetry configuration. However, due to a glitch in how the `coalesce` helper handles booleans, it always reports an error with missing Stackdriver configuration if you omit Stackdriver settings (even if you specify other telemetry backend values correctly). This change simply pulls the boolean out of the coalesce call and checks it separately. An updated unit test is included to validate a dogstatsd-only configuration.
1 parent 6dec4f2 commit fdcd5b2

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

command/operator_diagnose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ func (c *OperatorDiagnoseCommand) offlineDiagnostics(ctx context.Context) error
273273
}
274274

275275
// If any Stackdriver setting is present but we're missing the basic fields...
276-
if coalesce(t.StackdriverNamespace, t.StackdriverLocation, t.StackdriverDebugLogs, t.StackdriverNamespace) != nil {
276+
if coalesce(t.StackdriverNamespace, t.StackdriverLocation, t.StackdriverNamespace) != nil || t.StackdriverDebugLogs {
277277
if t.StackdriverProjectID == "" {
278278
return errors.New("incomplete Stackdriver telemetry configuration, missing stackdriver_project_id")
279279
}

command/operator_diagnose_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,18 @@ func TestOperatorDiagnoseCommand_Run(t *testing.T) {
627627
},
628628
},
629629
},
630+
{
631+
"diagnose_telemetry_ok_dogstatsd",
632+
[]string{
633+
"-config", "./server/test-fixtures/diagnose_ok_dogstatsd_telemetry.hcl",
634+
},
635+
[]*diagnose.Result{
636+
{
637+
Name: "Check Telemetry",
638+
Status: diagnose.OkStatus,
639+
},
640+
},
641+
},
630642
{
631643
"diagnose_telemetry_partial_stackdriver",
632644
[]string{
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright IBM Corp. 2016, 2025
2+
# SPDX-License-Identifier: BUSL-1.1
3+
4+
disable_cache = true
5+
disable_mlock = true
6+
ui = true
7+
8+
listener "tcp" {
9+
address = "127.0.0.1:8200"
10+
}
11+
12+
backend "consul" {
13+
advertise_addr = "foo"
14+
token = "foo"
15+
}
16+
17+
telemetry {
18+
dogstatsd_tags = ["tag1:value"]
19+
dogstatsd_addr = "127.0.0.1:8164"
20+
}
21+
22+
cluster_addr = "127.0.0.1:8201"

0 commit comments

Comments
 (0)