HealthChecks state #66117
Unanswered
lkurzyniec
asked this question in
Ideas
HealthChecks state
#66117
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Idea
Currently, there is no way to retrieve the current health checks state directly.
To get the status/state, it is necessary to resolve the
HealthCheckServicefrom the DI container and callCheckHealthAsync().If either
IHealthCheckPublisheris registered, or a health check endpoint is configured (e.g.,endpoints.MapHealthChecks("/healthz/ready", Predicate = healthCheck => healthCheck.Tags.Contains("ready"))) and integrated with a Kubernetes readiness probe, the current state is already available as one of the above "calculate" it by invokingHealthCheckService.CheckHealthAsync()on their own.The proposed approach is to register as singleton a transfer object (ie
HealthChecksState) and stores there aRefreshDateand the HealthReport.That would make a way to easly get the health checks state as well as reduce number of calls to registered health check endpoints (as those are made by either
IHealthCheckPublisherand/or readiness probe).Motivation
Infrastructure Health Validation Before Job Processing
A
HostedServicequeries the database every 5 seconds to retrieve pending jobs. Before processing each batch, I would like to have an option to verify the health state of infrastructure dependencies (e.g., database, Redis) and proceed with job execution only when the health check status isHealthy.Deployment Coordination with Kubernetes Readiness Probes
The Kubernetes readiness probe is configured with a 90-second initial delay due to the service's startup time. During deployment, both the old and new pod instances run concurrently. I would like to pause the
HostedServiceexecution loop until the readiness probe indicatesHealthy, ensuring the old pod has terminated and only the new pod is active.I think, I can contribute on that, as this seems to be quite easy.
Beta Was this translation helpful? Give feedback.
All reactions