Skip to content
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

[query] Use optional ptr ints for per query limits to allow for specifying zero to disable limits #3376

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
12 changes: 6 additions & 6 deletions src/cmd/services/m3query/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ type PerQueryLimitsConfiguration struct {
// MaxFetchedSeries limits the number of time series returned for any given
// individual storage node per query, before returning result to query
// service.
MaxFetchedSeries int `yaml:"maxFetchedSeries"`
MaxFetchedSeries *int `yaml:"maxFetchedSeries"`

// MaxFetchedDocs limits the number of index documents matched for any given
// individual storage node per query, before returning result to query
// service.
MaxFetchedDocs int `yaml:"maxFetchedDocs"`
MaxFetchedDocs *int `yaml:"maxFetchedDocs"`

// RequireExhaustive results in an error if the query exceeds any limit.
RequireExhaustive *bool `yaml:"requireExhaustive"`
Expand All @@ -376,13 +376,13 @@ type PerQueryLimitsConfiguration struct {
// handleroptions.FetchOptionsBuilderLimitsOptions.
func (l *PerQueryLimitsConfiguration) AsFetchOptionsBuilderLimitsOptions() handleroptions.FetchOptionsBuilderLimitsOptions {
seriesLimit := defaultStorageQuerySeriesLimit
if v := l.MaxFetchedSeries; v > 0 {
seriesLimit = v
if v := l.MaxFetchedSeries; v != nil {
seriesLimit = *v
}

docsLimit := defaultStorageQueryDocsLimit
if v := l.MaxFetchedDocs; v > 0 {
docsLimit = v
if v := l.MaxFetchedDocs; v != nil {
docsLimit = *v
}

requireExhaustive := defaultRequireExhaustive
Expand Down
10 changes: 7 additions & 3 deletions src/cmd/services/m3query/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,18 @@ func TestConfigLoading(t *testing.T) {
requireExhaustive = true
assert.Equal(t, &LimitsConfiguration{
PerQuery: PerQueryLimitsConfiguration{
MaxFetchedSeries: 12000,
MaxFetchedDocs: 11000,
MaxFetchedSeries: intPtrValue(12000),
MaxFetchedDocs: intPtrValue(11000),
RequireExhaustive: &requireExhaustive,
},
}, &cfg.Limits)
// TODO: assert on more fields here.
}

func intPtrValue(i int) *int {
return &i
}

func TestConfigValidation(t *testing.T) {
baseCfg := func(t *testing.T) *Configuration {
var cfg Configuration
Expand Down Expand Up @@ -131,7 +135,7 @@ func TestConfigValidation(t *testing.T) {
cfg := baseCfg(t)
cfg.Limits = LimitsConfiguration{
PerQuery: PerQueryLimitsConfiguration{
MaxFetchedSeries: tc.limit,
MaxFetchedSeries: intPtrValue(tc.limit),
}}

assert.NoError(t, validator.Validate(cfg))
Expand Down