Skip to content

Commit

Permalink
Wrap VolumeResponse. (grafana#11402)
Browse files Browse the repository at this point in the history
**What this PR does / why we need it**:
This fixes a regression in `frontend.encoding=protobuf`:

```
body rpc error: code = Internal desc = invalid response format, got (*queryrange.VolumeResponse)
```

**Checklist**
- [ ] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [ ] Documentation added
- [ ] Tests updated
- [ ] `CHANGELOG.md` updated
- [ ] If the change is worth mentioning in the release notes, add
`add-to-release-notes` label
- [ ] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/setup/upgrade/_index.md`
- [ ] For Helm chart changes bump the Helm chart version in
`production/helm/loki/Chart.yaml` and update
`production/helm/loki/CHANGELOG.md` and
`production/helm/loki/README.md`. [Example
PR](grafana@d10549e)
- [ ] If the change is deprecating or removing a configuration option,
update the `deprecated-config.yaml` and `deleted-config.yaml` files
respectively in the `tools/deprecated-config-checker` directory.
[Example
PR](grafana@0d4416a)
  • Loading branch information
jeschkies authored and rhnasc committed Apr 12, 2024
1 parent d8a03ef commit 3bf0d18
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/querier/queryrange/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ func QueryResponseWrap(res queryrangebase.Response) (*QueryResponse, error) {
p.Response = &QueryResponse_Labels{response}
case *IndexStatsResponse:
p.Response = &QueryResponse_Stats{response}
case *VolumeResponse:
p.Response = &QueryResponse_Volume{response}
case *TopKSketchesResponse:
p.Response = &QueryResponse_TopkSketches{response}
case *QuantileSketchResponse:
Expand Down
23 changes: 23 additions & 0 deletions pkg/querier/queryrange/marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,26 @@ func TestResultToResponse(t *testing.T) {
})
}
}

func TestResponseWrap(t *testing.T) {
for _, tt := range []struct {
name string
response queryrangebase.Response
expected isQueryResponse_Response
}{
{"volume", &VolumeResponse{}, &QueryResponse_Volume{}},
{"series", &LokiSeriesResponse{}, &QueryResponse_Series{}},
{"label", &LokiLabelNamesResponse{}, &QueryResponse_Labels{}},
{"stats", &IndexStatsResponse{}, &QueryResponse_Stats{}},
{"prom", &LokiPromResponse{}, &QueryResponse_Prom{}},
{"streams", &LokiResponse{}, &QueryResponse_Streams{}},
{"topk", &TopKSketchesResponse{}, &QueryResponse_TopkSketches{}},
{"quantile", &QuantileSketchResponse{}, &QueryResponse_QuantileSketches{}},
} {
t.Run(tt.name, func(t *testing.T) {
actual, err := QueryResponseWrap(tt.response)
require.NoError(t, err)
require.IsType(t, tt.expected, actual.Response)
})
}
}

0 comments on commit 3bf0d18

Please sign in to comment.