Skip to content

Commit

Permalink
Fixing CR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Tanaka <[email protected]>
  • Loading branch information
pedro-stanaka committed Sep 12, 2022
1 parent 1d60c15 commit 3ebf35b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/query_frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func registerQueryFrontend(app *extkingpin.App) {
"One should also set query-range.split-min-horizontal-shards to a value greater than 1 to enable splitting.").
Default("0").DurationVar(&cfg.QueryRangeConfig.MinQuerySplitInterval)

cmd.Flag("query-range.max-split-interval", "Split query range bellow this interval in query-range.horizontal-shards. Queries with a range longer than this value will be split in multiple requests of this length.").
cmd.Flag("query-range.max-split-interval", "Split query range below this interval in query-range.horizontal-shards. Queries with a range longer than this value will be split in multiple requests of this length.").
Default("0").DurationVar(&cfg.QueryRangeConfig.MaxQuerySplitInterval)

cmd.Flag("query-range.horizontal-shards", "Split queries in this many requests when query duration is below query-range.max-split-interval.").
Expand Down
2 changes: 1 addition & 1 deletion docs/components/query-frontend.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ Flags:
range request; beyond this, the downstream
error is returned.
--query-range.max-split-interval=0
Split query range bellow this interval in
Split query range below this interval in
query-range.horizontal-shards. Queries with a
range longer than this value will be split in
multiple requests of this length.
Expand Down
6 changes: 3 additions & 3 deletions pkg/queryfrontend/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ type LabelsConfig struct {
func (cfg *Config) Validate() error {
if cfg.QueryRangeConfig.ResultsCacheConfig != nil {
if cfg.QueryRangeConfig.SplitQueriesByInterval <= 0 && !cfg.isDynamicSplitSet() {
return errors.New("split queries or split threshold interval should be greater than 0 when caching is enabled")
return errors.New("split queries or split threshold interval should be greater than 0 when caching is enabled")
}
if err := cfg.QueryRangeConfig.ResultsCacheConfig.Validate(querier.Config{}); err != nil {
return errors.Wrap(err, "invalid ResultsCache config for query_range tripperware")
Expand All @@ -258,8 +258,8 @@ func (cfg *Config) Validate() error {
}

if cfg.isDynamicSplitSet() {
err := cfg.validateDynamicSplitParams()
if err != nil {

if err := cfg.validateDynamicSplitParams(); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/queryfrontend/roundtrip.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ func dynamicIntervalFn(config QueryRangeConfig) queryrange.IntervalFn {
}

queryInterval := time.Duration(r.GetEnd()-r.GetStart()) * time.Millisecond
// if the query is multiple of max interval, we use the max interval to split.
// If the query is multiple of max interval, we use the max interval to split.
if queryInterval/config.MaxQuerySplitInterval >= 2 {
return config.MaxQuerySplitInterval
}

// if the query duration is less than max interval, we split it equally in HorizontalShards.
// If the query duration is less than max interval, we split it equally in HorizontalShards.
return time.Duration(queryInterval.Milliseconds()/config.HorizontalShards) * time.Millisecond
}
}
Expand Down
8 changes: 0 additions & 8 deletions pkg/queryfrontend/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,6 @@ func TestRoundTripSplitIntervalMiddleware(t *testing.T) {
minHorizontalShards: 4,
expected: 2,
},
{
name: "split to 2 requests, due to split interval",
req: testRequest,
handlerFunc: promqlResults,
codec: queryRangeCodec,
splitInterval: 1 * time.Hour,
expected: 2,
},
{
name: "labels request won't be split",
req: testLabelsRequest,
Expand Down

0 comments on commit 3ebf35b

Please sign in to comment.