diff --git a/internal/observabilityproxy/appscope.go b/internal/observabilityproxy/appscope.go index e41dd1330..561a92ab8 100644 --- a/internal/observabilityproxy/appscope.go +++ b/internal/observabilityproxy/appscope.go @@ -200,6 +200,8 @@ func lookupRefusal(label string, body io.Reader) *HTTPError { case strings.Contains(answer.Error, "timeout exceeded"): return errorf(http.StatusGatewayTimeout, "the application's %s lookup did not answer in time", label) default: - return errorf(http.StatusBadGateway, "the application's %s lookup failed: %s", label, answer.Error) + // The text may name vmstorage nodes, so it stays in the log. + slog.Warn("application lookup refused by the store", "label", label, "error", answer.Error) + return errorf(http.StatusBadGateway, "the application's %s lookup failed", label) } } diff --git a/internal/observabilityproxy/appscope_test.go b/internal/observabilityproxy/appscope_test.go index af028b867..c4b8e5d69 100644 --- a/internal/observabilityproxy/appscope_test.go +++ b/internal/observabilityproxy/appscope_test.go @@ -17,10 +17,12 @@ limitations under the License. package observabilityproxy import ( + "net/http" "net/url" "regexp" "slices" "strconv" + "strings" "testing" "time" ) @@ -114,3 +116,14 @@ func TestMetricsRequestScope(t *testing.T) { t.Errorf("range window = [%s, %s]", rng.from, rng.to) } } + +// TestLookupRefusalKeepsStoreErrorsInternal: a store error other than the +// series limit may name vmstorage nodes; it goes to the log, not into a +// message that could reach the client. +func TestLookupRefusalKeepsStoreErrorsInternal(t *testing.T) { + body := strings.NewReader(`{"status":"error","error":"cannot fetch from vmstorage-longterm-0.vmstorage:8401: connection refused"}`) + herr := lookupRefusal("pod", body) + if herr.Code != http.StatusBadGateway || strings.Contains(herr.Message, "vmstorage") { + t.Fatalf("lookupRefusal = %d %q, want 502 without the store's text", herr.Code, herr.Message) + } +} diff --git a/internal/observabilityproxy/server_app_test.go b/internal/observabilityproxy/server_app_test.go index 8ae395d45..9a56e9e18 100644 --- a/internal/observabilityproxy/server_app_test.go +++ b/internal/observabilityproxy/server_app_test.go @@ -485,6 +485,11 @@ func TestServerApplicationLookupStoreErrors(t *testing.T) { if strings.Contains(string(body), `"errorType"`) { t.Errorf("the store's raw JSON reached the client: %q", body) } + // 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") { + t.Errorf("the store's error text reached the client: %q", body) + } } }