federation: nil pointer deference when using remove read

```
level=error ts=2018-06-13T07:19:04.515149169Z caller=stdlib.go:89 component=web caller="http: panic serving [::1" msg="]:56202: runtime error: invalid memory address or nil pointer dereference"
level=error ts=2018-06-13T07:19:04.516199547Z caller=stdlib.go:89 component=web caller="http: panic serving [::1" msg="]:56204: runtime error: invalid memory address or nil pointer dereference"
level=error ts=2018-06-13T07:19:04.51717692Z caller=stdlib.go:89 component=web caller="http: panic serving [::1" msg="]:56206: runtime error: invalid memory address or nil pointer dereference"
level=error ts=2018-06-13T07:19:04.564952878Z caller=stdlib.go:89 component=web caller="http: panic serving [::1" msg="]:56208: runtime error: invalid memory address or nil pointer dereference"
level=error ts=2018-06-13T07:19:04.566575791Z caller=stdlib.go:89 component=web caller="http: panic serving [::1" msg="]:56210: runtime error: invalid memory address or nil pointer dereference"
level=error ts=2018-06-13T07:19:04.567106063Z caller=stdlib.go:89 component=web caller="http: panic serving [::1" msg="]:56212: runtime error: invalid memory address or nil pointer dereference"
```

When remove read is enabled, federation will call `q.Select(nil, mset...)`
which will break remote reads because it currently doesn't handle empty
SelectParams.

Signed-off-by: Corentin Chary <c.chary@criteo.com>
This commit is contained in:
Corentin Chary 2018-06-13 09:19:17 +02:00 committed by Tom Wilkie
parent d0ee4da932
commit 530107f8ef
1 changed files with 6 additions and 3 deletions

View File

@ -95,10 +95,13 @@ func ToQuery(from, to int64, matchers []*labels.Matcher, p *storage.SelectParams
if err != nil {
return nil, err
}
var rp *prompb.ReadHints = nil
rp := &prompb.ReadHints{
StepMs: p.Step,
Func: p.Func,
if p != nil {
rp = &prompb.ReadHints{
StepMs: p.Step,
Func: p.Func,
}
}
return &prompb.Query{