Skip to content

Commit c0749b1

Browse files
committed
refactor(health): remove deprecated HealthService and related gRPC endpoints; migrate to HTTP health checks
1 parent cf475a1 commit c0749b1

4 files changed

Lines changed: 2 additions & 461 deletions

File tree

pkg/rpc/server/server.go

Lines changed: 2 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -287,100 +287,10 @@ func (p *P2PServer) GetNetInfo(
287287
}), nil
288288
}
289289

290-
// HealthServer implements the HealthService defined in the proto file
291-
// DEPRECATED: This is a legacy compatibility shim for external frameworks.
292-
// New code should use GET /health/live HTTP endpoint instead.
293-
type HealthServer struct {
294-
store store.Store
295-
config config.Config
296-
logger zerolog.Logger
297-
}
298-
299-
// NewHealthServer creates a new HealthServer instance
300-
func NewHealthServer(store store.Store, config config.Config, logger zerolog.Logger) *HealthServer {
301-
return &HealthServer{
302-
store: store,
303-
config: config,
304-
logger: logger,
305-
}
306-
}
307-
308-
// Livez implements the HealthService.Livez RPC
309-
// DEPRECATED: Use GET /health/live HTTP endpoint instead. This endpoint exists only
310-
// for backward compatibility with external testing frameworks.
311-
func (h *HealthServer) Livez(
312-
ctx context.Context,
313-
req *connect.Request[emptypb.Empty],
314-
) (*connect.Response[pb.GetHealthResponse], error) {
315-
// Log deprecation warning
316-
h.logger.Warn().
317-
Str("deprecated_endpoint", "/evnode.v1.HealthService/Livez").
318-
Str("recommended_endpoint", "GET /health/live").
319-
Msg("DEPRECATED: gRPC health endpoint called. Please migrate to HTTP endpoint GET /health/live")
320-
321-
status := pb.HealthStatus_PASS
322-
323-
// For aggregator nodes, check if block production is healthy
324-
if h.config.Node.Aggregator {
325-
state, err := h.store.GetState(ctx)
326-
if err != nil {
327-
h.logger.Error().Err(err).Msg("Failed to get state for health check")
328-
return connect.NewResponse(&pb.GetHealthResponse{
329-
Status: pb.HealthStatus_FAIL,
330-
}), nil
331-
}
332-
333-
// If we have blocks, check if the last block time is recent
334-
if state.LastBlockHeight > 0 {
335-
timeSinceLastBlock := time.Since(state.LastBlockTime)
336-
337-
// Calculate the threshold based on block time
338-
blockTime := h.config.Node.BlockTime.Duration
339-
340-
// For lazy mode, use the lazy block interval instead
341-
if h.config.Node.LazyMode {
342-
blockTime = h.config.Node.LazyBlockInterval.Duration
343-
}
344-
345-
warnThreshold := blockTime * 3 // healthCheckWarnMultiplier
346-
failThreshold := blockTime * 5 // healthCheckFailMultiplier
347-
348-
if timeSinceLastBlock > failThreshold {
349-
h.logger.Error().
350-
Dur("time_since_last_block", timeSinceLastBlock).
351-
Dur("fail_threshold", failThreshold).
352-
Uint64("last_block_height", state.LastBlockHeight).
353-
Time("last_block_time", state.LastBlockTime).
354-
Msg("Health check: node has stopped producing blocks (FAIL)")
355-
status = pb.HealthStatus_FAIL
356-
} else if timeSinceLastBlock > warnThreshold {
357-
h.logger.Warn().
358-
Dur("time_since_last_block", timeSinceLastBlock).
359-
Dur("warn_threshold", warnThreshold).
360-
Uint64("last_block_height", state.LastBlockHeight).
361-
Time("last_block_time", state.LastBlockTime).
362-
Msg("Health check: block production is slow (WARN)")
363-
status = pb.HealthStatus_WARN
364-
}
365-
}
366-
}
367-
368-
// Add deprecation warning to response headers
369-
resp := connect.NewResponse(&pb.GetHealthResponse{
370-
Status: status,
371-
})
372-
resp.Header().Set("X-Deprecated", "true")
373-
resp.Header().Set("X-Deprecated-Message", "Use GET /health/live instead")
374-
resp.Header().Set("Warning", "299 - \"Deprecated endpoint. Use GET /health/live\"")
375-
376-
return resp, nil
377-
}
378-
379-
// NewServiceHandler creates a new HTTP handler for Store, P2P, Health and Config services
290+
// NewServiceHandler creates a new HTTP handler for Store, P2P and Config services
380291
func NewServiceHandler(store store.Store, peerManager p2p.P2PRPC, proposerAddress []byte, logger zerolog.Logger, config config.Config, bestKnown BestKnownHeightProvider) (http.Handler, error) {
381292
storeServer := NewStoreServer(store, logger)
382293
p2pServer := NewP2PServer(peerManager)
383-
healthServer := NewHealthServer(store, config, logger) // Legacy gRPC endpoint
384294
configServer := NewConfigServer(config, proposerAddress, logger)
385295

386296
mux := http.NewServeMux()
@@ -389,7 +299,6 @@ func NewServiceHandler(store store.Store, peerManager p2p.P2PRPC, proposerAddres
389299
reflector := grpcreflect.NewStaticReflector(
390300
rpc.StoreServiceName,
391301
rpc.P2PServiceName,
392-
rpc.HealthServiceName, // Legacy gRPC endpoint
393302
rpc.ConfigServiceName,
394303
)
395304
mux.Handle(grpcreflect.NewHandlerV1(reflector, compress1KB))
@@ -403,14 +312,10 @@ func NewServiceHandler(store store.Store, peerManager p2p.P2PRPC, proposerAddres
403312
p2pPath, p2pHandler := rpc.NewP2PServiceHandler(p2pServer)
404313
mux.Handle(p2pPath, p2pHandler)
405314

406-
// Register HealthService (legacy gRPC endpoint for backward compatibility)
407-
healthPath, healthHandler := rpc.NewHealthServiceHandler(healthServer)
408-
mux.Handle(healthPath, healthHandler)
409-
410315
configPath, configHandler := rpc.NewConfigServiceHandler(configServer)
411316
mux.Handle(configPath, configHandler)
412317

413-
// Register custom HTTP endpoints (including the preferred /health/live endpoint)
318+
// Register custom HTTP endpoints
414319
RegisterCustomHTTPEndpoints(mux, store, peerManager, config, bestKnown, logger)
415320

416321
// Use h2c to support HTTP/2 without TLS

proto/evnode/v1/health.proto

Lines changed: 0 additions & 39 deletions
This file was deleted.

types/pb/evnode/v1/health.pb.go

Lines changed: 0 additions & 196 deletions
This file was deleted.

0 commit comments

Comments
 (0)