From 87e20d9399b2a33a89fac16700efafcd7eca4e44 Mon Sep 17 00:00:00 2001 From: Danny Kopping Date: Fri, 19 Aug 2022 21:53:32 +0200 Subject: [PATCH] Setting sane defaults for ruler in SSD "read" mode (#6551) Also removing support for configdb, since this is not supported but was the default storage type Signed-off-by: Danny Kopping Signed-off-by: Danny Kopping --- pkg/loki/modules.go | 10 ++-------- pkg/ruler/base/storage.go | 14 +++----------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/pkg/loki/modules.go b/pkg/loki/modules.go index 50f7cab01d..90ea9908ae 100644 --- a/pkg/loki/modules.go +++ b/pkg/loki/modules.go @@ -781,17 +781,11 @@ func (t *Loki) initRulerStorage() (_ services.Service, err error) { // unfortunately there is no way to generate a "default" config and compare default against actual // to determine if it's unconfigured. the following check, however, correctly tests this. // Single binary integration tests will break if this ever drifts - if t.Cfg.isModuleEnabled(All) && t.Cfg.Ruler.StoreConfig.IsDefaults() { - level.Info(util_log.Logger).Log("msg", "RulerStorage is not configured in single binary mode and will not be started.") + if (t.Cfg.isModuleEnabled(All) || t.Cfg.isModuleEnabled(Read)) && t.Cfg.Ruler.StoreConfig.IsDefaults() { + level.Info(util_log.Logger).Log("msg", "Ruler storage is not configured; ruler will not be started.") return } - // Loki doesn't support the configdb backend, but without excessive mangling/refactoring - // it's hard to enforce this at validation time. Therefore detect this and fail early. - if t.Cfg.Ruler.StoreConfig.Type == "configdb" { - return nil, errors.New("configdb is not supported as a Loki rules backend type") - } - // Make sure storage directory exists if using filesystem store if t.Cfg.Ruler.StoreConfig.Type == "local" && t.Cfg.Ruler.StoreConfig.Local.Directory != "" { err := chunk_util.EnsureDirectory(t.Cfg.Ruler.StoreConfig.Local.Directory) diff --git a/pkg/ruler/base/storage.go b/pkg/ruler/base/storage.go index aacea77c57..00ff572568 100644 --- a/pkg/ruler/base/storage.go +++ b/pkg/ruler/base/storage.go @@ -30,8 +30,7 @@ import ( // RuleStoreConfig configures a rule store. // TODO remove this legacy config in Cortex 1.11. type RuleStoreConfig struct { - Type string `yaml:"type"` - ConfigDB configClient.Config `yaml:"configdb"` + Type string `yaml:"type"` // Object Storage Configs Azure azure.BlobStorageConfig `yaml:"azure"` @@ -46,14 +45,13 @@ type RuleStoreConfig struct { // RegisterFlags registers flags. func (cfg *RuleStoreConfig) RegisterFlags(f *flag.FlagSet) { - cfg.ConfigDB.RegisterFlagsWithPrefix("ruler.", f) cfg.Azure.RegisterFlagsWithPrefix("ruler.storage.", f) cfg.GCS.RegisterFlagsWithPrefix("ruler.storage.", f) cfg.S3.RegisterFlagsWithPrefix("ruler.storage.", f) cfg.Swift.RegisterFlagsWithPrefix("ruler.storage.", f) cfg.Local.RegisterFlagsWithPrefix("ruler.storage.", f) cfg.BOS.RegisterFlagsWithPrefix("ruler.storage.", f) - f.StringVar(&cfg.Type, "ruler.storage.type", "configdb", "Method to use for backend rule storage (configdb, azure, gcs, s3, swift, local)") + f.StringVar(&cfg.Type, "ruler.storage.type", "", "Method to use for backend rule storage (configdb, azure, gcs, s3, swift, local)") } // Validate config and returns error on failure @@ -72,7 +70,7 @@ func (cfg *RuleStoreConfig) Validate() error { // IsDefaults returns true if the storage options have not been set func (cfg *RuleStoreConfig) IsDefaults() bool { - return cfg.Type == "configdb" && cfg.ConfigDB.ConfigsAPIURL.URL == nil + return cfg.Type == "" } // NewLegacyRuleStore returns a rule store backend client based on the provided cfg. @@ -91,12 +89,6 @@ func NewLegacyRuleStore(cfg RuleStoreConfig, hedgeCfg hedging.Config, clientMetr var client client.ObjectClient switch cfg.Type { - case "configdb": - c, err := configClient.New(cfg.ConfigDB) - if err != nil { - return nil, err - } - return configdb.NewConfigRuleStore(c), nil case "azure": client, err = azure.NewBlobStorage(&cfg.Azure, clientMetrics.AzureMetrics, hedgeCfg) case "gcs":