Error on no schema configs (#2564)

* ruler jsonnet

* jsonnet fixes

* errors instead of panics on no schema configs
k31
Owen Diehl 5 years ago committed by GitHub
parent f6f83fe5fd
commit 8627af1199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/storage/store.go
  2. 5
      pkg/storage/store_test.go

@ -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
@ -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.

@ -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{{

Loading…
Cancel
Save