From 49af12e3a3fb12c0bebe4d3af3fdb23ad3407a01 Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Mon, 31 Aug 2020 10:52:14 -0400 Subject: [PATCH 1/2] Fix overwriting maxSourceResolution when auto downsampling is enabled Signed-off-by: Ben Ye --- pkg/api/query/v1.go | 3 ++- pkg/api/query/v1_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/api/query/v1.go b/pkg/api/query/v1.go index 7cc30675b2..6cf2b80496 100644 --- a/pkg/api/query/v1.go +++ b/pkg/api/query/v1.go @@ -195,7 +195,8 @@ func (qapi *QueryAPI) parseDownsamplingParamMillis(r *http.Request, defaultVal t val := r.FormValue(maxSourceResolutionParam) if qapi.enableAutodownsampling || (val == "auto") { maxSourceResolution = defaultVal - } else if val != "" { + } + if val != "" && val != "auto" { var err error maxSourceResolution, err = parseDuration(val) if err != nil { diff --git a/pkg/api/query/v1_test.go b/pkg/api/query/v1_test.go index 05a91dcc15..bec886d622 100644 --- a/pkg/api/query/v1_test.go +++ b/pkg/api/query/v1_test.go @@ -1040,6 +1040,14 @@ func TestParseDownsamplingParamMillis(t *testing.T) { result: int64((1 * time.Hour) / 6), fail: true, }, + // maxSourceResolution param can be overwritten. + { + maxSourceResolutionParam: "1m", + enableAutodownsampling: true, + step: time.Hour, + result: int64(time.Minute / (1000 * 1000)), + fail: false, + }, } for i, test := range tests { From 132dd5e7a417518743c2eadcace15c46294f9808 Mon Sep 17 00:00:00 2001 From: Ben Ye Date: Mon, 31 Aug 2020 10:54:47 -0400 Subject: [PATCH 2/2] add changelog Signed-off-by: Ben Ye --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ba6f62bf1..e33e565270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ We use *breaking :warning:* word for marking changes that are not backward compa * [#3095](https://github.com/thanos-io/thanos/pull/3095) Rule: update manager when all rule files are removed. * [#3098](https://github.com/thanos-io/thanos/pull/3098) ui: Fix Block Viewer for Compactor and Store +* [#3105](https://github.com/thanos-io/thanos/pull/3105) Query: Fix overwriting maxSourceResolution when auto downsampling is enabled. ## [v0.15.0-rc.0](https://github.com/thanos-io/thanos/releases/tag/v0.15.0-rc.0) - 2020.08.26