Repository navigation
Harden remote health check status reporting - #7330
Merged
Merged
Conversation
Follow-up to #4844, which turned remote health checks on by default and keeps failing remotes running as unhealthy. - Redact ping errors and pinger logs to the remote URL's scheme and host. The unauthenticated /health response echoed the ping error, which quoted the full remote URL, so secrets in its path or query were readable by anyone who could reach the proxy. - Stop firing health callbacks once the proxy is shutting down, and have the runner keep stopping/stopped/removing and skip deleted workloads, so stopping or removing an unhealthy remote no longer leaves it unhealthy or recreates its status file. - Make HealthCheckRecoveredCallback return an error and retry it on later passing checks, so one failed status write no longer leaves a recovered remote stuck as unhealthy. - Fix the health check docs that contradicted the opt-out and the repeated-write behaviour. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7330 +/- ##
==========================================
+ Coverage 82.30% 82.35% +0.04%
==========================================
Files 935 936 +1
Lines 95295 95494 +199
==========================================
+ Hits 78436 78642 +206
+ Misses 16854 16847 -7
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…eview # Conflicts: # docs/arch/08-workloads-lifecycle.md
rdimitrov
approved these changes
Nov 26, 2026
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.
Summary
Follow-up to #4844, which made remote MCP health checks on by default and keeps a failing remote's proxy running as
unhealthyuntil it recovers. Review findings posted after that PR merged turned up three bugs in the new paths. #4844 is not in a release yet, so none of these has shipped./healthexposed secrets in the remote URL. Mark failing remote MCP servers unhealthy instead of starting #4844 pointed the health pinger at the remote's full path and query. When a ping fails, the*url.Errortext quotes that full URL.HealthCheckercopies it intomcp.error, and the proxy serves it on the unauthenticated/healthendpoint, so a token in?api_key=…or in the path was readable by anyone who could reach the proxy. The pingers now rebuild the*url.Errorwith only the scheme and host, keeping the inner error soerrors.Isstill works. RedirectLocationvalues get the same treatment. The pinger's debug logs and the startup debug log inhttp.godrop the path and query too.thv stop/rmsends SIGTERM and then writesstoppedor deletes the status file without waiting. A ping in flight then failed, and the degraded monitor firedonHealthCheckFailed, which wroteunhealthyoverstoppedor recreated the deleted status file. The monitor now returns without counting or calling back once its context is cancelled or the proxy is stopping. The runner's unhealthy callback also keepsstopping/stopped/removingand skips a workload whose status is missing or unreadable.unhealthy. The failure callback re-fires on every failed check, but the recovery callback fired once. If that read or write failed (the status file lock gives up after 1s), nothing put it right until the next outage.HealthCheckRecoveredCallbacknow returnserror, and the proxy keeps a pending recovery and calls it again on each passing check until it returns nil.monitorHealthnow tracks this in explicitreportedUnhealthy/recoveryPendingstate instead of leaving the counter at the threshold.03-transport-architecture.mdthat said remote checks were "always enabled" (they can be turned off) and that the status is written "only on these transitions" (it is rewritten during an outage). The docs also now state that each remote check is a request to the MCP endpoint, which opens and drops a connection for SSE remotes.Type of change
Test plan
task test)task test-e2e)task lint-fix)Locally,
task lint-fixcrashes inside staticcheck on the go1.27 toolchain. I rangolangci-lint run --disable staticcheck,unusedon./pkg/transport/... ./pkg/runner/...(0 issues) and am relying on CI for the full run.go test -racepasses for those packages. I also turned off the redaction, the shutdown guard and the recovery retry one at a time and confirmed the new tests fail each time.Changes
pkg/transport/proxy/transparent/pinger.goLocationerror, which quotes the raw headerpkg/transport/proxy/transparent/transparent_proxy.goreportedUnhealthy/recoveryPendingstate; recovery retried until handledpkg/transport/types/transport.goHealthCheckRecoveredCallbackreturnserrorpkg/transport/http.gopkg/runner/runner.go*_test.godocs/arch/*.md,docs/observability.md/healthredactionDoes this introduce a user-facing change?
Yes:
/healtherror text. Before: when a remote ping fails,mcp.errorcontained the full remote URL, including path and query. After: it names only the scheme and host, e.g.Get "https://mcp.example.com": dial tcp ….thv stop/thv rmcould leave the workloadunhealthy, or recreate its status after removal. After: it endsstopped, or stays removed.unhealthy. After: it returns torunningon a later passing check.Special notes for reviewers
Stopthat lands between the guard and the callback can still let one callback through. Separately, the workload manager writes status from another process, so its write can land between the runner's read and write.thv stopwritesstoppedlast, which covers the common case. Fully closing it needs compare-and-set inStatusManager, which is out of scope. The docs say this.Locationredaction relies on Go's error text. Go builds that error with%vand no error chain, so it is caught by its message prefix. A test pins it, so a Go change that rewords it fails CI rather than leaking.transparent_proxy.gostill log full upstream URLs: the per-response debug log ofreq.URLand the redirect warn/info lines. Unlike/health, these need log access to read. Worth a separate change.unhealthycan replaceauth_retrying. A remote that recovers is then shownrunningwhile token refresh may still be retrying.🤖 Generated with Claude Code