mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 12:13:55 +09:00
fix(observability-proxy): pass on only the limit text of a lookup 422
The series-limit refusal of a lookup reached the client with all of cluster vmselect's wrapping, and that context can name vmstorage nodes, the leak the generic 502 had just closed for other errors. The client now gets the message from the limit on. Assisted-by: LLM Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
1 parent
41e61cb288
commit
5fc9e5a0b9
2 files changed
+5
-2
No files matched your search
@@ -196,7 +196,10 @@ func lookupRefusal(label string, body io.Reader) *HTTPError {
|
||||
_ = json.NewDecoder(io.LimitReader(body, 64<<10)).Decode(&answer)
|
||||
switch {
|
||||
case strings.Contains(answer.Error, seriesLimitError):
|
||||
return errorf(http.StatusUnprocessableEntity, "the application's %s lookup: %s", label, answer.Error)
|
||||
// From the limit on: what precedes it is cluster vmselect's context,
|
||||
// which can name vmstorage nodes.
|
||||
limit := answer.Error[strings.Index(answer.Error, seriesLimitError):]
|
||||
return errorf(http.StatusUnprocessableEntity, "the application's %s lookup: %s", label, limit)
|
||||
case strings.Contains(answer.Error, "timeout exceeded"):
|
||||
return errorf(http.StatusGatewayTimeout, "the application's %s lookup did not answer in time", label)
|
||||
default:
|
||||
|
||||
@@ -487,7 +487,7 @@ func TestServerApplicationLookupStoreErrors(t *testing.T) {
|
||||
}
|
||||
// Other store errors may name vmstorage nodes; only the limit
|
||||
// message, which the client can act on, is passed on.
|
||||
if tc.want != http.StatusUnprocessableEntity && strings.Contains(string(body), "vmstorage") {
|
||||
if strings.Contains(string(body), "vmstorage") {
|
||||
t.Errorf("the store's error text reached the client: %q", body)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user