Skip to content

Commit d4fceb1

Browse files
authored
QueryFronted should send request to queriers when query_range has start==end (#4877)
* Cortex should still send the request to upstream when Start == end Signed-off-by: Alan Protasio <[email protected]> * Changelog Signed-off-by: Alan Protasio <[email protected]> * Fix test Signed-off-by: Alan Protasio <[email protected]> Signed-off-by: Alan Protasio <[email protected]>
1 parent 42c68cd commit d4fceb1

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
* [BUGFIX] Memberlist: Add join with no retrying when starting service. #4804
6060
* [BUGFIX] Ruler: Fix /ruler/rule_groups returns YAML with extra fields. #4767
6161
* [BUGFIX] Respecting `-tracing.otel.sample-ratio` configuration when enabling OpenTelemetry tracing with X-ray. #4862
62+
* [BUGFIX] QueryFrontend: fixed query_range requests when query has `start` equals to `end`. #4877
6263

6364
## 1.13.0 2022-07-14
6465

pkg/querier/tripperware/queryrange/split_by_interval.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ func (s splitByInterval) Do(ctx context.Context, r tripperware.Request) (tripper
6969
}
7070

7171
func splitQuery(r tripperware.Request, interval time.Duration) ([]tripperware.Request, error) {
72+
// If Start == end we should just run the original request
73+
if r.GetStart() == r.GetEnd() {
74+
return []tripperware.Request{r}, nil
75+
}
76+
7277
// Replace @ modifier function to their respective constant values in the query.
7378
// This way subqueries will be evaluated at the same time as the parent query.
7479
query, err := evaluateAtModifierFunction(r.GetQuery(), r.GetStart(), r.GetEnd())

pkg/querier/tripperware/queryrange/split_by_interval_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ func TestSplitQuery(t *testing.T) {
8484
},
8585
interval: day,
8686
},
87+
{
88+
input: &PrometheusRequest{
89+
Start: 60 * 60 * seconds,
90+
End: 60 * 60 * seconds,
91+
Step: 15 * seconds,
92+
Query: "foo",
93+
},
94+
expected: []tripperware.Request{
95+
&PrometheusRequest{
96+
Start: 60 * 60 * seconds,
97+
End: 60 * 60 * seconds,
98+
Step: 15 * seconds,
99+
Query: "foo",
100+
},
101+
},
102+
interval: day,
103+
},
87104
{
88105
input: &PrometheusRequest{
89106
Start: 0,

0 commit comments

Comments
 (0)