docs(observability-proxy): name subquery steps in the app lookup texts

Since the lookup reaches subquery steps past the evaluation time, the
applicationScope comment still described only negative offsets, and a
query refused for a subquery step the scan cannot read got a 422 that
listed every other cause but that one.

Assisted-by: LLM
Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-10 04:03:24 +07:00
1 parent d164790946
commit 054fac6ab0
2 files changed
+15 -2

No files matched your search

+3 -2
View File
@@ -95,14 +95,15 @@ func applicationSelectors(ns, kind, name string, pods, pvcs []string) []string {
// applicationScope looks the application's pods and PVCs up in store over
// the samples the request reads: back by the query's own lookback, and
// forward to the latest sample a negative offset reads. A query that reads
// forward to the latest sample a negative offset or a subquery's
// evaluation past its end reads. A query that reads
// further back than the configured lookback, or whose earliest or latest
// sample is unknown, a failed lookup, and a list over its cap all fail the
// request, because a successful answer would silently miss the
// application's series.
func (s *Server) applicationScope(ctx context.Context, r *http.Request, store string, req metricsRequest, ns, kind, name string) ([]string, *HTTPError) {
if req.last.IsZero() {
return nil, errorf(http.StatusUnprocessableEntity, "the query reads samples at a time the application scope cannot cover (an @ anywhere in the query, rollup_candlestick, WITH with a negative offset, or an offset that is not a plain duration); use the namespace root")
return nil, errorf(http.StatusUnprocessableEntity, "the query reads samples at a time the application scope cannot cover (an @ anywhere in the query, rollup_candlestick, WITH with a negative offset, an offset that is not a plain duration, or a subquery step that is not one); use the namespace root")
}
lim := s.cfg.Metrics.App
if req.start.IsZero() || req.start.Before(req.from.Add(-lim.Lookback)) {
@@ -553,3 +553,15 @@ func TestServerApplicationLookupCoversSubquery(t *testing.T) {
t.Fatalf("lookup %s end = %s, want at least %s", r.path, r.form.Get("end"), formatTime(at.Add(2*time.Hour)))
}
}
// TestServerApplicationNamesUnreadableSubqueryStep: the refusal names the
// cause when a subquery step is what the scan cannot read.
func TestServerApplicationNamesUnreadableSubqueryStep(t *testing.T) {
h := newPolicyHarness(t, Config{}, appMetricsUpstream(nil, nil, http.StatusOK), appPolicy, nil)
resp := h.do(http.MethodGet, appRoot+"db.main/metrics/api/v1/query?"+url.Values{"query": {"max_over_time(x[1h:5i])"}}.Encode(), "good", nil, nil)
body, _ := io.ReadAll(resp.Body)
_ = resp.Body.Close()
if resp.StatusCode != http.StatusUnprocessableEntity || !strings.Contains(string(body), "subquery step") {
t.Fatalf("answered %d %q, want 422 naming the subquery step", resp.StatusCode, body)
}
}