Skip to content

Config validation failure when setting flusher.exit_after_flush=false #5488

Open
@kralicky

Description

@kralicky

Describe the bug
If the following is set in the Cortex config file:

flusher:
  exit_after_flush: false

validation will fail with the following error:

error validating config: the Flusher configuration in YAML has been specified as an empty YAML node

due to the fact that setting exit_after_flush to false results in the flusher config becoming equivalent to an empty struct with all zero-valued fields.

To Reproduce
Minimal unit test to reproduce the error:

diff --git a/cmd/cortex/main_test.go b/cmd/cortex/main_test.go
index 5c7194912..67ebb4493 100644
--- a/cmd/cortex/main_test.go
+++ b/cmd/cortex/main_test.go
@@ -79,6 +79,11 @@ func TestFlagParsing(t *testing.T) {
 			stderrMessage: "the Querier configuration in YAML has been specified as an empty YAML node",
 		},
 
+		"root level configuration option specified with all zero values": {
+			yaml:           "flusher: { exit_after_flush: false }",
+			stderrExcluded: "empty YAML node",
+		},
+
 		"version": {
 			arguments:     []string{"-version"},
 			stdoutMessage: "Cortex, version",

Expected behavior
The validation rule should probably check if the actual yaml node is empty. I think this can be done with yaml/v3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions