Skip to content

Commit 1ab37df

Browse files
authored
Merge pull request #1579 from grafana/20190813_remove_separate_ruler_api
20190813 Remove the separate ruler API
2 parents e7fec1c + 2be6d9d commit 1ab37df

File tree

7 files changed

+12
-652
lines changed

7 files changed

+12
-652
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# Changelog
2+
13
## master / unreleased
24

5+
* [CHANGE] Remove direct DB/API access from the ruler
36
* [CHANGE] Removed `Delta` encoding. Any old chunks with `Delta` encoding cannot be read anymore. If `ingester.chunk-encoding` is set to `Delta` the ingester will fail to start. #1706
47
* [ENHANCEMENT] Allocation improvements in adding samples to Chunk. #1706
58
* [ENHANCEMENT] Consul client now follows recommended practices for blocking queries wrt returned Index value. #1708

pkg/configs/client/client.go

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ package client
33
import (
44
"context"
55
"encoding/json"
6+
"errors"
67
"fmt"
78
"net/http"
89
"net/url"
910
"time"
1011

1112
"github.com/cortexproject/cortex/pkg/configs"
12-
"github.com/cortexproject/cortex/pkg/configs/db"
1313
"github.com/cortexproject/cortex/pkg/util"
1414
"github.com/go-kit/kit/log/level"
1515
)
@@ -26,25 +26,13 @@ type Client interface {
2626

2727
// New creates a new ConfigClient.
2828
func New(cfg Config) (Client, error) {
29-
// All of this falderal is to allow for a smooth transition away from
30-
// using the configs server and toward directly connecting to the database.
31-
// See https://github.com/cortexproject/cortex/issues/619
32-
if cfg.ConfigsAPIURL.URL != nil {
33-
return instrumented{
34-
next: configsClient{
35-
URL: cfg.ConfigsAPIURL.URL,
36-
Timeout: cfg.ClientTimeout,
37-
},
38-
}, nil
39-
}
40-
41-
db, err := db.New(cfg.DBConfig)
42-
if err != nil {
43-
return nil, err
29+
if cfg.ConfigsAPIURL.URL == nil {
30+
return nil, errors.New("configdb url not provided")
4431
}
4532
return instrumented{
46-
next: dbStore{
47-
db: db,
33+
next: configsClient{
34+
URL: cfg.ConfigsAPIURL.URL,
35+
Timeout: cfg.ClientTimeout,
4836
},
4937
}, nil
5038
}
@@ -113,37 +101,6 @@ func doRequest(endpoint string, timeout time.Duration, since configs.ID) (*Confi
113101
return &config, nil
114102
}
115103

116-
type dbStore struct {
117-
db db.DB
118-
}
119-
120-
// GetRules implements ConfigClient.
121-
func (d dbStore) GetRules(ctx context.Context, since configs.ID) (map[string]configs.VersionedRulesConfig, error) {
122-
if since == 0 {
123-
return d.db.GetAllRulesConfigs(ctx)
124-
}
125-
return d.db.GetRulesConfigs(ctx, since)
126-
}
127-
128-
// GetAlerts implements ConfigClient.
129-
func (d dbStore) GetAlerts(ctx context.Context, since configs.ID) (*ConfigsResponse, error) {
130-
var resp map[string]configs.View
131-
var err error
132-
if since == 0 {
133-
resp, err = d.db.GetAllConfigs(ctx)
134-
135-
}
136-
resp, err = d.db.GetConfigs(ctx, since)
137-
if err != nil {
138-
return nil, err
139-
}
140-
141-
return &ConfigsResponse{
142-
since: since,
143-
Configs: resp,
144-
}, nil
145-
}
146-
147104
// ConfigsResponse is a response from server for GetConfigs.
148105
type ConfigsResponse struct {
149106
// The version since which these configs were changed

pkg/configs/client/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ import (
99
"github.com/weaveworks/common/instrument"
1010

1111
"github.com/cortexproject/cortex/pkg/configs"
12-
"github.com/cortexproject/cortex/pkg/configs/db"
1312
"github.com/cortexproject/cortex/pkg/util/flagext"
1413
)
1514

1615
// Config says where we can find the ruler configs.
1716
type Config struct {
18-
DBConfig db.Config
19-
2017
// DEPRECATED
2118
ConfigsAPIURL flagext.URLValue
2219

@@ -27,7 +24,6 @@ type Config struct {
2724

2825
// RegisterFlags adds the flags required to config this to the given FlagSet
2926
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
30-
cfg.DBConfig.RegisterFlags(f)
3127
f.Var(&cfg.ConfigsAPIURL, "ruler.configs.url", "DEPRECATED. URL of configs API server.")
3228
f.DurationVar(&cfg.ClientTimeout, "ruler.client-timeout", 5*time.Second, "DEPRECATED. Timeout for requests to Weave Cloud configs service.")
3329
flag.Var(&cfg.ConfigsAPIURL, "alertmanager.configs.url", "URL of configs API server.")

pkg/cortex/cortex.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ type Config struct {
7171
Encoding encoding.Config `yaml:"-"` // No yaml for this, it only works with flags.
7272

7373
Ruler ruler.Config `yaml:"ruler,omitempty"`
74+
ConfigDB db.Config `yaml:"configdb,omitempty"`
7475
ConfigStore config_client.Config `yaml:"config_store,omitempty"`
7576
Alertmanager alertmanager.MultitenantAlertmanagerConfig `yaml:"alertmanager,omitempty"`
7677
}
@@ -101,6 +102,7 @@ func (c *Config) RegisterFlags(f *flag.FlagSet) {
101102
c.Encoding.RegisterFlags(f)
102103

103104
c.Ruler.RegisterFlags(f)
105+
c.ConfigDB.RegisterFlags(f)
104106
c.ConfigStore.RegisterFlags(f)
105107
c.Alertmanager.RegisterFlags(f)
106108

pkg/cortex/modules.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,6 @@ func (t *Cortex) initRuler(cfg *Config) (err error) {
339339
return
340340
}
341341

342-
// Only serve the API for setting & getting rules configs if we're not
343-
// serving configs from the configs API. Allows for smoother
344-
// migration. See https://github.com/cortexproject/cortex/issues/619
345-
if cfg.ConfigStore.ConfigsAPIURL.URL == nil {
346-
a, err := ruler.NewAPIFromConfig(cfg.ConfigStore.DBConfig)
347-
if err != nil {
348-
return err
349-
}
350-
a.RegisterRoutes(t.server.HTTP)
351-
}
352-
353342
t.server.HTTP.Handle("/ruler_ring", t.ruler)
354343
return
355344
}
@@ -360,7 +349,7 @@ func (t *Cortex) stopRuler() error {
360349
}
361350

362351
func (t *Cortex) initConfigs(cfg *Config) (err error) {
363-
t.configDB, err = db.New(cfg.ConfigStore.DBConfig)
352+
t.configDB, err = db.New(cfg.ConfigDB)
364353
if err != nil {
365354
return
366355
}

pkg/ruler/api.go

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)