Repository navigation
fix: stop health probes from tearing down caller-derived upstreams - #66
Merged
Merged
Conversation
A health probe runs on nobody's behalf, so an upstream using passthrough or token-exchange has no credential to present: creds.Apply fails, the connect fails, and guardedDo charges that failure to the upstream. Every poll then consumed its rate budget, recorded a circuit-breaker failure — five polls open the circuit for the clients it serves perfectly well — and, once a real session existed, charged the upstream and server budgets for traffic no caller asked for. /health reported healthy == 0 and answered 503, so a gateway whose federation is entirely caller-derived never became Ready while serving every authenticated caller correctly. The active probe loop had the same defect and worse: probeEndpoints runs on context.Background(), so it ejected every endpoint on its first round. Report such an upstream "unprobed" rather than down, count it as neither healthy nor unhealthy, and judge the 503 against what the gateway can actually reach. healthCheck is likewise ignored for them, with a warning at startup rather than a validation error so an existing config keeps serving. The unprobed flag is omitempty, so a federation without caller-derived credentials keeps the exact response shape it had. This also makes UpstreamCredentials.PerRequest — until now dead code — load-bearing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
blakebauman
added a commit
that referenced
this pull request
Aug 14, 2026
#66 landed as a squash, so its commits are not ancestors of this branch and git sees both sides editing the lines it introduced. This branch already contains main's content in full — verified by diffing the trees — plus this PR's changes, so the merge keeps the branch tree as-is.
This was referenced Aug 14, 2026
blakebauman
added a commit
that referenced
this pull request
Aug 14, 2026
Covers #65, #66 and #68. Filed under "Unreleased" rather than a dated version: entries here are written as part of a release and land in the release commit, so a dated heading on main before the tag is the exact drift the release runbook warns about. It becomes the version heading when these ship. Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
blakebauman
added a commit
that referenced
this pull request
Aug 14, 2026
Dates the changelog entry for the three caller-derived credential fixes (#65, #66, #68) and bumps the chart: appVersion to v1.12.1, which is what a default helm install deploys, and the chart's own version to 0.2.2, since a published OCI tag is immutable. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A health probe runs on nobody's behalf. An upstream using
passthroughortoken-exchangehas no credential outside a request, socreds.Applyfails (auth/upstream.go:109-127), the connect fails, andguardedDocharges that failure to the upstream:u.limiter.Allowconsumes the upstream's rate budgetu.breaker.Record(ctx, false)— five polls open the circuit for the clients it serves perfectly wellchargeBudgetsbills the upstream and server budgets for traffic no caller asked forhealthy == 0→/healthanswers503(gateway.go:1750)The chart wires readiness to
/health, so a gateway whose federation is entirely caller-derived never becomes Ready while serving every authenticated caller correctly.healthCheck.intervalMshad the same defect and worse:probeEndpointsruns oncontext.Background()(gateway/upstream.go:591), so it ejected every endpoint on its first round and never restored them.The fix
"unprobed": trueand counted as neither healthy nor unhealthy.collectUpstreamHealthreturns aprobeablecount alongsidehealthy; the 503 is judged against what the gateway can actually reach, andstatus: "ok"meanshealthy == probeable.startHealthProbesskips them with a warning rather than a validation error, so an existing config keeps serving.Unprobedisomitempty, so a federation without caller-derived credentials keeps the exact response shape it had.This also makes
UpstreamCredentials.PerRequest()load-bearing. It was dead code — nothing in the tree called it — which is why the session question it names was never wired up anywhere.Tests
TestHealthDoesNotProbeCallerDerivedUpstreams— ten collections (well past the threshold of 5), assertingunprobed,healthy=0/probeable=0,/health200 withstatus: ok, and then that a real authenticatedtools/callstill succeeds. That last assertion is the point: on the previous code the circuit is open by then.TestHealthStillReportsProbeableUpstreamsDown— the carve-out is not a blanket amnesty; one reachable-but-dead upstream still yields 503.TestActiveProbesSkipCallerDerivedUpstreams— no probe loop, no ejected endpoints.Docs
docs/operations.mdendpoint table and a new paragraph indocs/deploy.md's Probes section explaining why this is a correctness fix rather than a cosmetic one.Gate
gofmt,go mod tidy -diff,go vet,go build,go test -race ./...,golangci-lint run(0 issues) all pass locally.🤖 Generated with Claude Code