Skip to content

fix(prober): classify a probe deadline by the request phase it interrupted - #1264

Merged
bpalermo merged 4 commits into
mainfrom
fix/1252-prober-phase-classify
Oct 5, 2026
Merged

bpalermo merged 4 commits into
mainfrom
fix/1252-prober-phase-classify

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Closes #1252

Problem

A mesh_dns probe whose name lookup was still in flight when its 2 s deadline fired was counted timeout, never dns_timeout. So "dns_* is zero" did not mean DNS was healthy, and a timeout did not say which phase ran out. #1240 had to infer the phase from access-log source-port order.

Root cause, checked against the pinned SDK (go1.27.1): Transport.getConn dials on context.WithCancel(context.WithoutCancel(ctx)) (src/net/http/transport.go:1596). When the request context ends first, it returns context.Cause(treq.ctx) (:1651), a bare context deadline exceeded with no *net.DNSError in the chain. TestTransportHidesResolutionStall pins this. It fails if a future Go starts surfacing the DNSError.

Fix

  • Every probe carries an httptrace.ClientTrace (GetConn, DNSStart/Done, ConnectStart/Done, TLSHandshakeStart/Done, GotConn with Reused, WroteRequest, GotFirstResponseByte). The dial goroutine keeps firing hooks after Do returns, so phaseRecorder keeps everything under a mutex and the probe reads only a copied snapshot.
  • classifyFailure = classifyErr + phase: a deadline in the dns phase becomes dns_timeout. A deadline in any later phase stays timeout.
  • The AETHER_PROBE_FAIL line gains stable keys phase, reused, conn_ms, dns_ms, connect_ms, tls_ms, write_ms, ttfb_ms (-1 = the phase never started; the phase the probe ended in is measured up to the failure). phase is one of dns|connect|tls|write|first_byte|headers|conn_wait|response|"".
  • Dependencies: only stdlib net/http/httptrace was added.

Metric contract

  • aether_probe_requests_total{tier,target,result}: the name is unchanged and the result value set is unchanged (success, http_error, connection_error, timeout, saturated, dns_error, dns_nxdomain, dns_timeout). I did not add connect_timeout/first_byte_timeout. Each new value would be a new series per tier×target×pod. Splitting timeout would also silently change what existing result="timeout" rules match. The log line carries the phase instead.
  • Behaviour change: mesh_dns resolution stalls that outlive the budget move from timeout to dns_timeout.
  • No per-phase histogram. It would multiply the duration histogram's series by about 7 phases for a signal the bounded log line already carries.

Example line

AETHER_PROBE_FAIL {"t":"…","tier":"mesh_dns","target":"echo.aether-test.aether.internal:18081","result":"dns_timeout","err":"Get \"http://echo.aether-test.aether.internal:18081/\": context deadline exceeded","elapsed_ms":2000.3,"phase":"dns","reused":false,"conn_ms":2000.2,"dns_ms":2000.1,"connect_ms":-1,"tls_ms":-1,"write_ms":-1,"ttfb_ms":-1,"pod":"prober-h2mzs","node":"main-worker-05","n":1,"truncated":false}

Tests

  • I wrote the new tests first and ran them against unchanged main. They were red: TestProbePhaseDNSStall: results = map[timeout:1], want exactly {dns_timeout:1}. That proves the old misclassification end to end through probe().
  • phase_test.go covers each case through probe():
    • a stalling resolver (pure-Go resolver whose nameserver reads and never answers): dns_timeout/dns
    • a listener that accepts and never answers: timeout/first_byte
    • a blackholed connect (Dialer.ControlContext holds connect(2)): timeout/connect
    • a reused keep-alive connection that goes silent: first_byte, reused:true, dns/connect -1
    • an http_error: response
    • a fast refusal: connection_error/connect
  • phase_recorder_test.go has a concurrent-hooks test (for --config=race), a phase-ordering table, the timing math, and a classifyFailure table.
  • bazel test //prober/...: pass. bazel test --config=race //prober/internal/prober:prober_test --runs_per_test=10: pass.
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...: pass. make format-check: clean. make gazelle: applied.

Consumers updated

  • docs/runbook.md: field reference, an updated example line, and a timeout vs dns_timeout note.
  • e2e/soak/README.md: attribution and grading notes.
  • docs/configuration.md
  • docs/observability/mesh-dns-alerts.yml: comment only. MeshDNSResolutionFailing already matches dns_error|dns_nxdomain|dns_timeout|timeout, so it fires exactly as before.

No charts/ file changed, so there is no chart bump. The prober chart pins the image digest at package time.

For external alert-rule owners (GitOps repo)

  • Values a rule might match: success, http_error, connection_error, timeout, saturated, dns_error, dns_nxdomain, dns_timeout. The set is unchanged.
  • A rule on {tier="mesh_dns",result="timeout"} alone will see resolution stalls disappear from it. They now count under dns_timeout.
  • A rule on result=~"dns_.*" or result="dns_timeout" will start firing on stalls it could never see before.
  • Rules that match both values are unaffected, and so are success-ratio SLIs (result="success" / total).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

bpalermo and others added 4 commits October 5, 2026 11:18
…upted

A mesh_dns probe whose lookup was still in flight at the 2 s deadline was
counted `timeout`, never `dns_timeout`. net/http's Transport.getConn dials
on context.WithoutCancel(req.Context()) and, when the request context ends
first, returns context.Cause of the request context (go1.27.1
src/net/http/transport.go:1596/1651), so the error carries no
*net.DNSError and classifyErr cannot see the resolution stall.
TestTransportHidesResolutionStall pins that stdlib behaviour.

Every probe now carries an httptrace.ClientTrace (GetConn, DNS, Connect,
TLS, GotConn with Reused, WroteRequest, GotFirstResponseByte) recorded
under a mutex, since the dial goroutine keeps firing hooks after Do
returns. classifyFailure turns a deadline in the dns phase into
dns_timeout; every later phase stays `timeout`. The result label set is
unchanged (no connect_timeout etc.): the phase and per-phase milliseconds
go on the AETHER_PROBE_FAIL line (phase, reused, conn_ms, dns_ms,
connect_ms, tls_ms, write_ms, ttfb_ms; -1 = never started). No per-phase
histogram: it would multiply series by phase for a signal the bounded log
line already carries.

Docs: runbook field reference and timeout vs dns_timeout note, soak
README attribution, configuration.md, mesh-dns-alerts.yml comment.

Closes #1252

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo merged commit 549fa37 into main Oct 5, 2026
24 checks passed
@bpalermo
bpalermo deleted the fix/1252-prober-phase-classify branch October 5, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prober: a DNS stall can never be classified dns_timeout — classify by phase with httptrace

1 participant