Skip to content
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

Error on no schema configs #2564

Merged
merged 4 commits into from
Aug 27, 2020
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
4 changes: 4 additions & 0 deletions pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
var (
currentBoltdbShipperNon24HoursErr = errors.New("boltdb-shipper works best with 24h periodic index config. Either add a new config with future date set to 24h to retain the existing index or change the existing config to use 24h period")
upcomingBoltdbShipperNon24HoursErr = errors.New("boltdb-shipper with future date must always have periodic config for index set to 24h")
zeroLengthConfigError = errors.New("Must specify at least one schema configuration.")
)

// Config is the loki storage configuration
Expand All @@ -51,6 +52,9 @@ type SchemaConfig struct {

// Validate the schema config and returns an error if the validation doesn't pass
func (cfg *SchemaConfig) Validate() error {
if len(cfg.Configs) == 0 {
return zeroLengthConfigError
}
activePCIndex := ActivePeriodConfig(*cfg)

// if current index type is boltdb-shipper and there are no upcoming index types then it should be set to 24 hours.
Expand Down
5 changes: 5 additions & 0 deletions pkg/storage/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,11 @@ func TestSchemaConfig_Validate(t *testing.T) {
configs []chunk.PeriodConfig
err error
}{
{
name: "empty",
configs: []chunk.PeriodConfig{},
err: zeroLengthConfigError,
},
{
name: "NOT using boltdb-shipper",
configs: []chunk.PeriodConfig{{
Expand Down