Skip to content

Commit 25b32d4

Browse files
authored
Remove default for database flag (#708)
* Change database.uri flag to default to empty This could theoretically break deployments of the configs service that relied on the default being set. In practice, we anticipate very few configs deployments expecting a database at `configs-db.weave.local` * Only serve DB-backed stuff if DB set In #649, we only served DB-backed endpoints for ruler if the configs API flag was _not_ set. This turns out to be hostile to a smooth migration, as we want to have points where we are serving _both_ sets of endpoints so we can update the service-ui to go from pointing at one to pointing at the other.
1 parent 9b96497 commit 25b32d4

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

cmd/lite/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ func main() {
172172
})
173173
}
174174

175-
// Only serve the API for setting & getting rules configs if we're not
176-
// serving configs from the configs API. Allows for smoother
177-
// migration. See https://github.com/weaveworks/cortex/issues/619
178-
if configStoreConfig.ConfigsAPIURL.URL == nil {
175+
// Only serve the API for setting & getting rules configs if we have a
176+
// database. Allows for smoother migration. See
177+
// https://github.com/weaveworks/cortex/issues/619
178+
if configStoreConfig.DBConfig.URI != "" {
179179
a, err := ruler.NewAPIFromConfig(configStoreConfig.DBConfig)
180180
if err != nil {
181181
level.Error(util.Logger).Log("msg", "error initializing public rules API", "err", err)

cmd/ruler/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ func main() {
103103
}
104104
defer server.Shutdown()
105105

106-
// Only serve the API for setting & getting rules configs if we're not
107-
// serving configs from the configs API. Allows for smoother
108-
// migration. See https://github.com/weaveworks/cortex/issues/619
109-
if configStoreConfig.ConfigsAPIURL.URL == nil {
106+
// Only serve the API for setting & getting rules configs if we have a
107+
// database. Allows for smoother migration. See
108+
// https://github.com/weaveworks/cortex/issues/619
109+
if configStoreConfig.DBConfig.URI != "" {
110110
a, err := ruler.NewAPIFromConfig(configStoreConfig.DBConfig)
111111
if err != nil {
112112
level.Error(util.Logger).Log("msg", "error initializing public rules API", "err", err)

pkg/configs/db/db.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Config struct {
1818

1919
// RegisterFlags adds the flags required to configure this to the given FlagSet.
2020
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
21-
flag.StringVar(&cfg.URI, "database.uri", "postgres://[email protected]/configs?sslmode=disable", "URI where the database can be found (for dev you can use memory://)")
21+
flag.StringVar(&cfg.URI, "database.uri", "", "URI where the database can be found (for dev you can use memory://)")
2222
flag.StringVar(&cfg.MigrationsDir, "database.migrations", "", "Path where the database migration files can be found")
2323
}
2424

pkg/ruler/configs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func NewRulesAPI(cfg ConfigStoreConfig) (RulesAPI, error) {
4343
// All of this falderal is to allow for a smooth transition away from
4444
// using the configs server and toward directly connecting to the database.
4545
// See https://github.com/weaveworks/cortex/issues/619
46-
if cfg.ConfigsAPIURL.URL != nil {
46+
if cfg.DBConfig.URI != "" {
4747
return configsClient{
4848
URL: cfg.ConfigsAPIURL.URL,
4949
Timeout: cfg.ClientTimeout,

0 commit comments

Comments
 (0)