Skip to content

Commit c9fc505

Browse files
gkatz2claude
andcommitted
Clean up health check dead code and timeout
The constructor and functional options guarantee positive values for healthCheckInterval and healthCheckPingTimeout, making two zero-value guards unreachable. The redundant context timeout in checkMCPStatus capped the configurable ping timeout at 5s; the MCPPinger already enforces its own timeout internally. Fixes #4790 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Greg Katz <gkatz@indeed.com>
1 parent 052ecdd commit c9fc505

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

pkg/healthcheck/healthcheck.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ func (hc *HealthChecker) checkMCPStatus(ctx context.Context) *MCPStatus {
106106
LastChecked: time.Now(),
107107
}
108108

109-
// Create a context with timeout for the ping
110-
pingCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
111-
defer cancel()
112-
113-
duration, err := hc.mcpPinger.Ping(pingCtx)
109+
duration, err := hc.mcpPinger.Ping(ctx)
114110

115111
if err != nil {
116112
status.Available = false

pkg/transport/proxy/transparent/transparent_proxy.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,10 @@ func NewTransparentProxyWithOptions(
456456
// Create health checker always for Kubernetes probes
457457
var mcpPinger healthcheck.MCPPinger
458458
if enableHealthCheck {
459-
pingTimeout := proxy.healthCheckPingTimeout
460-
if pingTimeout == 0 {
461-
pingTimeout = DefaultPingerTimeout
462-
}
463459
if proxy.stateless {
464-
mcpPinger = NewStatelessMCPPingerWithTimeout(targetURI, pingTimeout)
460+
mcpPinger = NewStatelessMCPPingerWithTimeout(targetURI, proxy.healthCheckPingTimeout)
465461
} else {
466-
mcpPinger = NewMCPPingerWithTimeout(targetURI, pingTimeout)
462+
mcpPinger = NewMCPPingerWithTimeout(targetURI, proxy.healthCheckPingTimeout)
467463
}
468464
}
469465
proxy.healthChecker = healthcheck.NewHealthChecker(transportType, mcpPinger)
@@ -1246,11 +1242,7 @@ func (p *TransparentProxy) handleHealthCheckFailure(
12461242
}
12471243

12481244
func (p *TransparentProxy) monitorHealth(parentCtx context.Context) {
1249-
interval := p.healthCheckInterval
1250-
if interval == 0 {
1251-
interval = DefaultHealthCheckInterval
1252-
}
1253-
ticker := time.NewTicker(interval)
1245+
ticker := time.NewTicker(p.healthCheckInterval)
12541246
defer ticker.Stop()
12551247

12561248
consecutiveFailures := 0

0 commit comments

Comments
 (0)