-
Notifications
You must be signed in to change notification settings - Fork 685
Remove HealthStatus defaulting to healthy when there is no value from a health check #6209
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
Remove HealthStatus defaulting to healthy when there is no value from a health check #6209
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
I think the tests are failing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs test. Could probably add an assert on health status to an existing test that looks at custom resource snapshot properties after publish.
I'm not sure the approach here is correct. With the changes here, I expect the UI to show "Running (Unhealthy)" for resources that don't have health checks. In This distinction was added as a fix for the following scenario:
The |
No, it should show Running, not unhealthy. If we don't have health checks then we're in a "we don't know any better and I have to assume the resource is ready" state. |
Sorry I wasn't clear. I agree with you, and that's what happens today. I should have written:
|
It is a helix issue |
That's a confusing distinction. It carries the meaning of "no current health status available." This meaning also applies to resources that do not contain health checks, because we do not have a health status available for them. So when resources aren't defaulting to healthy,
With the current text, we don't need to make that distinction between
If we do want to indicate that there are health checks present, but that a result has not come back yet, we may want to consider adding a different status, maybe Running (waiting for health check) |
Could you clarify? I also added a null assert in |
tests/Aspire.Dashboard.Components.Tests/Controls/StateColumnDisplayTests.cs
Outdated
Show resolved
Hide resolved
Write a test for each scenario that people are talking about here and assert the health status. That draws a line in the sand for how each scenario would work. I see:
Maybe others? I didn't look at each comment closely. |
private static CustomResourceSnapshot UpdateHealthStatus(IResource resource, CustomResourceSnapshot previousState) | ||
{ | ||
// A resource is also healthy if it has no health check annotations and is in the running state. | ||
if (!resource.TryGetAnnotationsIncludingAncestorsOfType<HealthCheckAnnotation>(out _) && previousState.State?.Text == KnownResourceStates.Running) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to run every publish, it never changes. Can the caller do this instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It becomes much cheaper to call if the first condition is previousState.HealthStatus is not HealthStatus.Healthy
- would you have concerns about that?
private static CustomResourceSnapshot UpdateHealthStatus(IResource resource, CustomResourceSnapshot previousState) | ||
{ | ||
// A resource is also healthy if it has no health check annotations and is in the running state. | ||
if (!resource.TryGetAnnotationsIncludingAncestorsOfType<HealthCheckAnnotation>(out _) && previousState.State?.Text == KnownResourceStates.Running) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new HasAnnotationIncludingAncestorsOfType<T>
method in #6357 would make this cheaper to call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It becomes much cheaper to call if the first condition is previousState.HealthStatus is not HealthStatus.Healthy
- changed
FYI I have some changes to make in the next hour. Nothing too contraversial. In the interest of time, I'm going to add them directly to this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumbs up for dashboard changes
Maybe we can start writing dashboard view model tests |
I tested and the problem is in aspire/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs Lines 398 to 402 in f19600f
There isn't a I'm guessing this problem is unique to the health checks sandbox test app because the health report is manually specified in the snapshot and isn't driven by the annotation like typical usage. aspire/playground/HealthChecks/HealthChecksSandbox.AppHost/Program.cs Lines 43 to 49 in f19600f
It seems like the snapshot health reports is the better place to calculate the health status from. But this is the first time I've looked at health checks so someone with more knowledge here should decide. |
@adamint will be opening a PR shortly |
The bug is a little more generalized than just the health check test app. The root cause is that there should be a check to see if a resource has a |
I don't think that's true. |
maybe we make this property internal. The only thing publishing health state would be via the annotations |
Description
The proposed changes are
HealthReportSnapshot.Status
nullable@davidfowl @drewnoakes
Fixes #6125
Checklist
<remarks />
and<code />
elements on your triple slash comments?Microsoft Reviewers: Open in CodeFlow