-
Notifications
You must be signed in to change notification settings - Fork 757
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
ResourceUtilizationHealthCheck only reports CPU _or_ memory issues, not both #4677
Comments
I just bumped into this myself and agree with @Tratcher’s recommendation.
Anything I can do to help? |
Thank you for bumping this issue, @willibrandon. To me it totally makes sense. @geeknoid @rsreepathi @mwierzchowski @mobratil what do you think of this? |
To start the ball rolling, we'll need an API proposal which we'll then discuss and take to the ASP.NET API Review Board for further approval. |
/cc: @evgenyfedorov2 |
Hi @willibrandon , thanks for stepping in. It does not look like we have to make any changes to public API surface, we probably can just create those two proposed What do you think? |
@evgenyfedorov2 - I apologize I am usually more prompt than this. Yes I agree that we can just create those two proposed |
Or perhaps it would be more appropriate to return a HealthReport?
|
From my observations, dotnet/aspnetcore has two implementations: Task<HealthCheckResult> CheckHealthAsync(...)
Task<HealthReport> CheckHealthAsync(...) The first one is used whenever there is a single component to be checked for health (this is the part of the In our case, we use the first signature, however, we check multiple components (i.e., CPU and memory), and this doesn't feel correct. I believe, we should have defined multiple health checks - one for the CPU utilisation, one for memory consumption, etc. Then those health checks should get registered via the standard mechanisms and aggregated via |
IMO the component should keep doing what it is meant for (resource utilization health checks) and the simplest fix would be to just send a compound message per health level:
Creating two separate healthchecks is a different issue, though could make sense since healthchecks reports is a thing that would solve the aggregation issue (a breaking change if this one is removed instead). Also someone can already track CPU only or memory only with this component (by setting custom limits for each). |
@sebastienros, to clarify I understand your suggestion correctly, do you mean the following?
|
@RussKie something like this, yes. An alternative could be to have the degraded message also added, but still return the highest of the levels. Example with CPU unhealthy and memory degraded:
That would also make the code easier. Just keep the current checks, but don't return, just append to the message. And in the end return the highest detected level. |
As a short-term solution/workaround this is probably ok, but to me this still feels as conflating two (or more) checks into one, which feels like conflicting with the purpose of the IHealthCheck contract. |
@RussKie definitely. I assume that the goal here was performance. Two healthchecks would mean two calls to |
A compound message in the |
Description
When checking health based on resource utilization, the conditions are checked in series and only the first failure is reported.
extensions/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheck.cs
Lines 39 to 60 in 68810ca
Reproduction Steps
Test on a system with both high CPU and memory.
Expected behavior
Both CPU and memory issues should be reported.
Actual behavior
Only the first issue found is reported.
Regression?
No response
Known Workarounds
No response
Configuration
8.0
Other information
Recommendation: ResourceUtilizationHealthCheck should be split into two IHealthCheck implementations, one for CPU and one for memory. That way both states can be reported independently.
The text was updated successfully, but these errors were encountered: