Refactor health check service to be more responsive#7261
Merged
Conversation
davidfowl
reviewed
Jan 27, 2025
davidfowl
reviewed
Jan 27, 2025
davidfowl
reviewed
Jan 27, 2025
davidfowl
reviewed
Jan 27, 2025
davidfowl
approved these changes
Jan 27, 2025
Contributor
davidfowl
left a comment
There was a problem hiding this comment.
Nit about adding comments but LGTM
eerhardt
reviewed
Jan 27, 2025
| ResourceMonitorState? state; | ||
|
|
||
| _latestEvents[resourceName] = resourceEvent; | ||
| lock (_resourceMonitoringStates) |
Member
There was a problem hiding this comment.
This code isn't multi-threaded, right? There is just 1 thread/loop processing these events. So is there a need to lock here?
Member
There was a problem hiding this comment.
I guess there is an internal GetResourceMonitorState that is used for tests that could be on a different thread.
Member
Author
There was a problem hiding this comment.
Yes. I didn't want tests to fail because the dictionary was in a bad state during a get.
The lock will never be contended in the real world, and this isn't performance critical code, so it seemed better to add some safety in the cause of test stability.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #6112
The health check service immediately checks health when a resource moves to a running state. However, if the intial report is unhealthy then it waits 5 seconds before checking again. This PR refactors the health check service to be more responsive.
DelayAsyncmethod is complicated, but the actual health monitoring loop is much simpler.AutoResetEvent👎Checklist
<remarks />and<code />elements on your triple slash comments?breaking-changetemplate):doc-ideatemplate):