Skip to content

20190813 Remove the separate ruler API #1579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## master / unreleased

* [CHANGE] Remove direct DB/API access from the ruler
* [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
* [ENHANCEMENT] Allocation improvements in adding samples to Chunk. #1706
* [ENHANCEMENT] Consul client now follows recommended practices for blocking queries wrt returned Index value. #1708
Expand Down
55 changes: 6 additions & 49 deletions pkg/configs/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package client
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"time"

"github.com/cortexproject/cortex/pkg/configs"
"github.com/cortexproject/cortex/pkg/configs/db"
"github.com/cortexproject/cortex/pkg/util"
"github.com/go-kit/kit/log/level"
)
Expand All @@ -26,25 +26,13 @@ type Client interface {

// New creates a new ConfigClient.
func New(cfg Config) (Client, error) {
// All of this falderal is to allow for a smooth transition away from
// using the configs server and toward directly connecting to the database.
// See https://github.com/cortexproject/cortex/issues/619
if cfg.ConfigsAPIURL.URL != nil {
return instrumented{
next: configsClient{
URL: cfg.ConfigsAPIURL.URL,
Timeout: cfg.ClientTimeout,
},
}, nil
}

db, err := db.New(cfg.DBConfig)
if err != nil {
return nil, err
if cfg.ConfigsAPIURL.URL == nil {
return nil, errors.New("configdb url not provided")
}
return instrumented{
next: dbStore{
db: db,
next: configsClient{
URL: cfg.ConfigsAPIURL.URL,
Timeout: cfg.ClientTimeout,
},
}, nil
}
Expand Down Expand Up @@ -113,37 +101,6 @@ func doRequest(endpoint string, timeout time.Duration, since configs.ID) (*Confi
return &config, nil
}

type dbStore struct {
db db.DB
}

// GetRules implements ConfigClient.
func (d dbStore) GetRules(ctx context.Context, since configs.ID) (map[string]configs.VersionedRulesConfig, error) {
if since == 0 {
return d.db.GetAllRulesConfigs(ctx)
}
return d.db.GetRulesConfigs(ctx, since)
}

// GetAlerts implements ConfigClient.
func (d dbStore) GetAlerts(ctx context.Context, since configs.ID) (*ConfigsResponse, error) {
var resp map[string]configs.View
var err error
if since == 0 {
resp, err = d.db.GetAllConfigs(ctx)

}
resp, err = d.db.GetConfigs(ctx, since)
if err != nil {
return nil, err
}

return &ConfigsResponse{
since: since,
Configs: resp,
}, nil
}

// ConfigsResponse is a response from server for GetConfigs.
type ConfigsResponse struct {
// The version since which these configs were changed
Expand Down
4 changes: 0 additions & 4 deletions pkg/configs/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import (
"github.com/weaveworks/common/instrument"

"github.com/cortexproject/cortex/pkg/configs"
"github.com/cortexproject/cortex/pkg/configs/db"
"github.com/cortexproject/cortex/pkg/util/flagext"
)

// Config says where we can find the ruler configs.
type Config struct {
DBConfig db.Config

// DEPRECATED
ConfigsAPIURL flagext.URLValue

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

// RegisterFlags adds the flags required to config this to the given FlagSet
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
cfg.DBConfig.RegisterFlags(f)
f.Var(&cfg.ConfigsAPIURL, "ruler.configs.url", "DEPRECATED. URL of configs API server.")
f.DurationVar(&cfg.ClientTimeout, "ruler.client-timeout", 5*time.Second, "DEPRECATED. Timeout for requests to Weave Cloud configs service.")
flag.Var(&cfg.ConfigsAPIURL, "alertmanager.configs.url", "URL of configs API server.")
Expand Down
2 changes: 2 additions & 0 deletions pkg/cortex/cortex.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Config struct {
Encoding encoding.Config `yaml:"-"` // No yaml for this, it only works with flags.

Ruler ruler.Config `yaml:"ruler,omitempty"`
ConfigDB db.Config `yaml:"configdb,omitempty"`
ConfigStore config_client.Config `yaml:"config_store,omitempty"`
Alertmanager alertmanager.MultitenantAlertmanagerConfig `yaml:"alertmanager,omitempty"`
}
Expand Down Expand Up @@ -101,6 +102,7 @@ func (c *Config) RegisterFlags(f *flag.FlagSet) {
c.Encoding.RegisterFlags(f)

c.Ruler.RegisterFlags(f)
c.ConfigDB.RegisterFlags(f)
c.ConfigStore.RegisterFlags(f)
c.Alertmanager.RegisterFlags(f)

Expand Down
13 changes: 1 addition & 12 deletions pkg/cortex/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,17 +339,6 @@ func (t *Cortex) initRuler(cfg *Config) (err error) {
return
}

// Only serve the API for setting & getting rules configs if we're not
// serving configs from the configs API. Allows for smoother
// migration. See https://github.com/cortexproject/cortex/issues/619
if cfg.ConfigStore.ConfigsAPIURL.URL == nil {
a, err := ruler.NewAPIFromConfig(cfg.ConfigStore.DBConfig)
if err != nil {
return err
}
a.RegisterRoutes(t.server.HTTP)
}

t.server.HTTP.Handle("/ruler_ring", t.ruler)
return
}
Expand All @@ -360,7 +349,7 @@ func (t *Cortex) stopRuler() error {
}

func (t *Cortex) initConfigs(cfg *Config) (err error) {
t.configDB, err = db.New(cfg.ConfigStore.DBConfig)
t.configDB, err = db.New(cfg.ConfigDB)
if err != nil {
return
}
Expand Down
118 changes: 0 additions & 118 deletions pkg/ruler/api.go

This file was deleted.

Loading