When a request going through Grafana data source proxy responds with a websocket
upgrade response we cannot override the response body since it produces an error.
This problem seems to have been introduced in Grafana v8.0 by #38962.
In addition #40303 added same problem.
Fixes #41292
(cherry picked from commit 3be452f995)
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
parent
af84e20232
commit
fff0da8fe9
@@ -96,7 +96,7 @@ func executeMiddleware(next http.RoundTripper, datasourceLabel prometheus.Labels
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if res != nil {
|
||||
if res != nil && res.StatusCode != http.StatusSwitchingProtocols {
|
||||
res.Body = httpclient.CountBytesReader(res.Body, func(bytesRead int64) {
|
||||
responseSizeSummary.Observe(float64(bytesRead))
|
||||
})
|
||||
|
||||
@@ -21,7 +21,10 @@ func ResponseLimitMiddleware(limit int64) sdkhttpclient.Middleware {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.Body = httpclient.MaxBytesReader(res.Body, limit)
|
||||
if res != nil && res.StatusCode != http.StatusSwitchingProtocols {
|
||||
res.Body = httpclient.MaxBytesReader(res.Body, limit)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user