Skip to content

Commit

Permalink
Gracefully handle additional oneof fields in SeriesResponse (thanos-i…
Browse files Browse the repository at this point in the history
…o#2501)

* Gracefully handle additional oneof fields in SeriesResponse

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Removed unnecessary continue

Signed-off-by: Marco Pracucci <marco@pracucci.com>

* Updated CHANGELOG

Signed-off-by: Marco Pracucci <marco@pracucci.com>
  • Loading branch information
pracucci committed Apr 22, 2020
1 parent d8c2a33 commit 0bb67bc
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,12 @@ NOTE: As semantic versioning states all 0.y.z releases can contain breaking chan

We use *breaking* word for marking changes that are not backward compatible (relates only to v0.y.z releases.)

## Unreleased

### Fixed

- [#2501](https://github.com/thanos-io/thanos/pull/2501) Query: gracefully handle additional fields in `SeriesResponse` protobuf message that may be added in the future.

## [v0.12.1](https://github.com/thanos-io/thanos/releases/tag/v0.12.1) - 2020.04.20

### Fixed
Expand Down
8 changes: 5 additions & 3 deletions pkg/query/querier.go
Expand Up @@ -124,10 +124,12 @@ func (s *seriesServer) Send(r *storepb.SeriesResponse) error {
return nil
}

if r.GetSeries() == nil {
return errors.New("no seriesSet")
if r.GetSeries() != nil {
s.seriesSet = append(s.seriesSet, *r.GetSeries())
return nil
}
s.seriesSet = append(s.seriesSet, *r.GetSeries())

// Unsupported field, skip.
return nil
}

Expand Down
14 changes: 8 additions & 6 deletions pkg/store/proxy.go
Expand Up @@ -432,13 +432,15 @@ func startStreamSeriesSet(

if w := rr.r.GetWarning(); w != "" {
s.warnCh.send(storepb.NewWarnSeriesResponse(errors.New(w)))
continue
}
select {
case s.recvCh <- rr.r.GetSeries():
case <-ctx.Done():
s.handleErr(errors.Wrapf(ctx.Err(), "failed to receive any data from %s", s.name), done)
return

if series := rr.r.GetSeries(); series != nil {
select {
case s.recvCh <- series:
case <-ctx.Done():
s.handleErr(errors.Wrapf(ctx.Err(), "failed to receive any data from %s", s.name), done)
return
}
}
}
}()
Expand Down
8 changes: 5 additions & 3 deletions pkg/store/proxy_test.go
Expand Up @@ -1379,10 +1379,12 @@ func (s *storeSeriesServer) Send(r *storepb.SeriesResponse) error {
return nil
}

if r.GetSeries() == nil {
return errors.New("no seriesSet")
if r.GetSeries() != nil {
s.SeriesSet = append(s.SeriesSet, *r.GetSeries())
return nil
}
s.SeriesSet = append(s.SeriesSet, *r.GetSeries())

// Unsupported field, skip.
return nil
}

Expand Down

0 comments on commit 0bb67bc

Please sign in to comment.