Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: grpc health service #4020

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mouchar
Copy link

@mouchar mouchar commented Mar 4, 2025

Overview

Implements gRPC Health check using standard grpc library.

Reuses the health as reported by gosundheit health checker. Grpc health server
implements also streaming Watch method, so it was necessary to add
Stop() failback to stop server even if some clients ignore NOT_SERVING
status. Timeout for graceful shutdown was chosen to match timeouts for
http and telemetry servers.

What this PR does / why we need it

Dex already provides health check endpoint via HTTP. For integrations based on
gRPC, notably if we want to use client-side health checks for higher reliability,
as described here, we also need
to report service health using grpc.health.v1.Health service.

Special notes for your reviewer

Golang is not my mother tongue, so if there is something utterly wrong, please let me
know.

Implements gRPC Health check using standard grpc library. Reuses the
health as reported by gosundheit health checker. Grpc health server
implements also streaming Watch method, so it was necessary to add
Stop() failback to stop server even if some clients ignore NOT_SERVING
status. Timeout for graceful shutdown was chosen to match timeouts for
http and telemetry servers.

Signed-off-by: Robert Moucha <[email protected]>
Comment on lines +519 to +531
go func() {
var status healthgrpc.HealthCheckResponse_ServingStatus
for {
switch healthChecker.IsHealthy() {
case true:
status = healthgrpc.HealthCheckResponse_SERVING
default:
status = healthgrpc.HealthCheckResponse_NOT_SERVING
}
healthcheck.SetServingStatus("", status)
time.Sleep(healthCheckPeriod)
}
}()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could ae avoid using goroutines in goroutines here and use a separate group for the health endpoint?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants