Skip to content

Adding HA tracker kv store type validation #4881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/distributor/ha_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ func (cfg *HATrackerConfig) Validate() error {
return fmt.Errorf(errInvalidFailoverTimeout, cfg.FailoverTimeout, minFailureTimeout)
}

return nil
// Tracker kv store only supports consul and etcd.
storeAllowedList := []string{"consul", "etcd"}
for _, as := range storeAllowedList {
if cfg.KVStore.Store == as {
return nil
}
}
return fmt.Errorf("invalid HATracker KV store type: %s", cfg.KVStore.Store)
}

func GetReplicaDescCodec() codec.Proto {
Expand Down
9 changes: 9 additions & 0 deletions pkg/distributor/ha_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ func TestHATrackerConfig_Validate(t *testing.T) {
}(),
expectedErr: nil,
},
"should failed with invalid kv store": {
cfg: func() HATrackerConfig {
cfg := HATrackerConfig{}
flagext.DefaultValues(&cfg)
cfg.KVStore.Store = "memberlist"
return cfg
}(),
expectedErr: fmt.Errorf("invalid HATracker KV store type: %s", "memberlist"),
},
}

for testName, testData := range tests {
Expand Down