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

Gracefully handle additional oneof fields in SeriesResponse #2501

Merged
merged 3 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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