Skip to content

HealthCheck forcefully logs error on HealthCheckResult.Unhealthy #56815

Open
@MileaRobertStefan

Description

@MileaRobertStefan

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When implementing a health check using the IHealthCheck interface, the service enters a "shutting down" state where it completes its current tasks before stopping. During this state, the health check returns an "unhealthy" status to prevent the service from accepting new tasks. However, this results in the health check repeatedly logging errors, which in turn triggers alerts.

Expected Behavior

The health check should return "unhealthy" to prevent new tasks from being assigned to the service.
The system should handle the "unhealthy" status gracefully without repeatedly logging errors or triggering alert

Steps To Reproduce

Implement a health check using the IHealthCheck interface.
Initiate the service and allow it to process tasks.
Transition the service into a "shutting down" state where it completes ongoing tasks and then stops.
Observe the health check status during the "shutting down" state.

Exceptions (if any)

I should be able to configure the log level.

.NET Version

8.0.300

Anything else?

Fake errors:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-healthchecksIncludes: Healthchecks (some bugs also in Extensions repo)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions