- 
                Notifications
    You must be signed in to change notification settings 
- Fork 23
fix: race condition when stopping health check during shutdown #2177
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
Conversation
Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
| // Don't run checks if already stopped | ||
| // This prevents the race condition where Stop() sets status to Unhealthy | ||
| // but then check() overrides it back to Healthy | ||
| if hc.isStopped() { | ||
| return | ||
| } | 
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 problem was the Run() running in another goroutine.
So, we ensure that it will skip the check after stopping the http server.
| We should add sleep   | 
| 
 @Ubisoft-potato, the reason I didn't use a delay is because the subscriber doesn't receive http or grpc requests. It only pulls messages from pubsub. | 
Signed-off-by: Alessandro Yuichi Okimoto <yuichijpn@gmail.com>
| 
 Understand! Then we also dont need wait  | 
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.
LGTM! 👍
Fix #2178
I noticed that after stopping the health check, it returns 503, but after a few seconds, it starts returning 200 again, causing issues making the pod ready again to receive new requests.
Things done