Skip to content

Commit 7f85f92

Browse files
authored
Expose grpc client options in ruler. (cortexproject#3523)
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
1 parent 19d0f86 commit 7f85f92

File tree

4 files changed

+58
-8
lines changed

4 files changed

+58
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* [CHANGE] Querier: deprecated `-store.max-look-back-period`. You should use `-querier.max-query-lookback` instead. #3452
66
* [CHANGE] Blocks storage: increased `-blocks-storage.bucket-store.chunks-cache.attributes-ttl` default from `24h` to `168h` (1 week). #3528
77
* [CHANGE] Blocks storage: the config option `-blocks-storage.bucket-store.index-cache.postings-compression-enabled` has been deprecated and postings compression is always enabled. #3538
8+
* [CHANGE] Ruler: gRPC message size default limits on the Ruler-client side have changed: #3523
9+
- limit for outgoing gRPC messages has changed from 2147483647 to 16777216 bytes
10+
- limit for incoming gRPC messages has changed from 4194304 to 104857600 bytes
811
* [FEATURE] Distributor/Ingester: Provide ability to not overflow writes in the presence of a leaving or unhealthy ingester. This allows for more efficient ingester rolling restarts. #3305
912
* [ENHANCEMENT] API: Add GZIP HTTP compression to the API responses. Compression can be enabled via `-api.response-compression-enabled`. #3536
1013
* [ENHANCEMENT] Added zone-awareness support on queries. When zone-awareness is enabled, queries will still succeed if all ingesters in a single zone will fail. #3414
@@ -35,6 +38,7 @@
3538
* [ENHANCEMENT] Exported process metrics to monitor the number of memory map areas allocated. #3537
3639
* - `process_memory_map_areas`
3740
* - `process_memory_map_areas_limit`
41+
* [ENHANCEMENT] Ruler: Expose gRPC client options. #3523
3842
* [BUGFIX] Blocks storage ingester: fixed some cases leading to a TSDB WAL corruption after a partial write to disk. #3423
3943
* [BUGFIX] Blocks storage: Fix the race between ingestion and `/flush` call resulting in overlapping blocks. #3422
4044
* [BUGFIX] Querier: fixed `-querier.max-query-into-future` which wasn't correctly enforced on range queries. #3452

docs/configuration/config-file-reference.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,49 @@ The `ruler_config` configures the Cortex ruler.
10571057
[external_url: <url> | default = ]
10581058
10591059
ruler_client:
1060+
# gRPC client max receive message size (bytes).
1061+
# CLI flag: -ruler.client.grpc-max-recv-msg-size
1062+
[max_recv_msg_size: <int> | default = 104857600]
1063+
1064+
# gRPC client max send message size (bytes).
1065+
# CLI flag: -ruler.client.grpc-max-send-msg-size
1066+
[max_send_msg_size: <int> | default = 16777216]
1067+
1068+
# Deprecated: Use gzip compression when sending messages. If true, overrides
1069+
# grpc-compression flag.
1070+
# CLI flag: -ruler.client.grpc-use-gzip-compression
1071+
[use_gzip_compression: <boolean> | default = false]
1072+
1073+
# Use compression when sending messages. Supported values are: 'gzip',
1074+
# 'snappy' and '' (disable compression)
1075+
# CLI flag: -ruler.client.grpc-compression
1076+
[grpc_compression: <string> | default = ""]
1077+
1078+
# Rate limit for gRPC client; 0 means disabled.
1079+
# CLI flag: -ruler.client.grpc-client-rate-limit
1080+
[rate_limit: <float> | default = 0]
1081+
1082+
# Rate limit burst for gRPC client.
1083+
# CLI flag: -ruler.client.grpc-client-rate-limit-burst
1084+
[rate_limit_burst: <int> | default = 0]
1085+
1086+
# Enable backoff and retry when we hit ratelimits.
1087+
# CLI flag: -ruler.client.backoff-on-ratelimits
1088+
[backoff_on_ratelimits: <boolean> | default = false]
1089+
1090+
backoff_config:
1091+
# Minimum delay when backing off.
1092+
# CLI flag: -ruler.client.backoff-min-period
1093+
[min_period: <duration> | default = 100ms]
1094+
1095+
# Maximum delay when backing off.
1096+
# CLI flag: -ruler.client.backoff-max-period
1097+
[max_period: <duration> | default = 10s]
1098+
1099+
# Number of times to backoff and retry before failing.
1100+
# CLI flag: -ruler.client.backoff-retries
1101+
[max_retries: <int> | default = 10]
1102+
10601103
# Path to the client certificate file, which will be used for authenticating
10611104
# with the server. Also requires the key path to be configured.
10621105
# CLI flag: -ruler.client.tls-cert-path

pkg/cortex/cortex.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (c *Config) Validate(log log.Logger) error {
180180
if err := c.ChunkStore.Validate(log); err != nil {
181181
return errors.Wrap(err, "invalid chunk store config")
182182
}
183-
if err := c.Ruler.Validate(c.LimitsConfig); err != nil {
183+
if err := c.Ruler.Validate(c.LimitsConfig, log); err != nil {
184184
return errors.Wrap(err, "invalid ruler config")
185185
}
186186
if err := c.BlocksStorage.Validate(); err != nil {

pkg/ruler/ruler.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ import (
3333
"github.com/cortexproject/cortex/pkg/tenant"
3434
"github.com/cortexproject/cortex/pkg/util"
3535
"github.com/cortexproject/cortex/pkg/util/flagext"
36+
"github.com/cortexproject/cortex/pkg/util/grpcclient"
3637
"github.com/cortexproject/cortex/pkg/util/services"
37-
"github.com/cortexproject/cortex/pkg/util/tls"
3838
"github.com/cortexproject/cortex/pkg/util/validation"
3939
)
4040

@@ -63,8 +63,8 @@ const (
6363
type Config struct {
6464
// This is used for template expansion in alerts; must be a valid URL.
6565
ExternalURL flagext.URLValue `yaml:"external_url"`
66-
// TLS parameters for the GRPC Client
67-
ClientTLSConfig tls.ClientConfig `yaml:"ruler_client"`
66+
// GRPC Client configuration.
67+
ClientTLSConfig grpcclient.ConfigWithTLS `yaml:"ruler_client"`
6868
// How frequently to evaluate rules by default.
6969
EvaluationInterval time.Duration `yaml:"evaluation_interval"`
7070
// Deprecated. Replaced with pkg/util/validation/Limits.RulerEvaluationDelay field.
@@ -110,7 +110,7 @@ type Config struct {
110110
}
111111

112112
// Validate config and returns error on failure
113-
func (cfg *Config) Validate(limits validation.Limits) error {
113+
func (cfg *Config) Validate(limits validation.Limits, log log.Logger) error {
114114
if !util.StringsContain(supportedShardingStrategies, cfg.ShardingStrategy) {
115115
return errInvalidShardingStrategy
116116
}
@@ -122,6 +122,9 @@ func (cfg *Config) Validate(limits validation.Limits) error {
122122
if err := cfg.StoreConfig.Validate(); err != nil {
123123
return errors.Wrap(err, "invalid storage config")
124124
}
125+
if err := cfg.ClientTLSConfig.Validate(log); err != nil {
126+
return errors.Wrap(err, "invalid ruler gRPC client config")
127+
}
125128
return nil
126129
}
127130

@@ -695,14 +698,14 @@ func (r *Ruler) getShardedRules(ctx context.Context) ([]*GroupStateDesc, error)
695698
return nil, fmt.Errorf("unable to inject user ID into grpc request, %v", err)
696699
}
697700

698-
rgs := []*GroupStateDesc{}
701+
var rgs []*GroupStateDesc
699702

700703
for _, rlr := range rulers.Ingesters {
701-
dialOpts, err := r.cfg.ClientTLSConfig.GetGRPCDialOptions()
704+
dialOpts, err := r.cfg.ClientTLSConfig.DialOption(nil, nil)
702705
if err != nil {
703706
return nil, err
704707
}
705-
conn, err := grpc.Dial(rlr.Addr, dialOpts...)
708+
conn, err := grpc.DialContext(ctx, rlr.Addr, dialOpts...)
706709
if err != nil {
707710
return nil, err
708711
}

0 commit comments

Comments
 (0)