Skip to content

Commit

Permalink
Error on no schema configs (#2564)
Browse files Browse the repository at this point in the history
* ruler jsonnet

* jsonnet fixes

* errors instead of panics on no schema configs
  • Loading branch information
owen-d authored Aug 27, 2020
1 parent f6f83fe commit 8627af1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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

0 comments on commit 8627af1

Please sign in to comment.