fix: close HTTP response body in health check for core-keeper#5328
Conversation
2e3e2a9 to
5514af4
Compare
|
Hi @judehung , This PR addresses a file descriptor leak in the Core Keeper registry health check and includes unit tests to verify the fix. Please let me know if any changes are needed. Thanks! |
judehung
left a comment
There was a problem hiding this comment.
Thanks for the fix—your changes look reasonable to me. However, registry_test.go is not formatted according to gofmt, which is causing the PR checks to fail.
You can run the following command in your environment to format registry_test.go correctly.:
gofmt -w ./internal/core/keeper/registry/registry_test.go
| @@ -0,0 +1,422 @@ | |||
| // | |||
| // Copyright (C) 2024 IOTech Ltd | |||
There was a problem hiding this comment.
Please update the copyright header to the correct year
| // Copyright (C) 2024 IOTech Ltd | |
| // Copyright (C) 2025 IOTech Ltd | |
0bb72fb to
f3869a9
Compare
|
Hi @judehung ,Thanks for the review! I've addressed your feedback:
The copyright year is now updated. Please let me know if there's anything else that needs to be addressed. |
|
@remo-lab Note that |
f3869a9 to
14b6209
Compare
|
HI @judehung ,Thanks for the review and guidance. I’ve updated the PR title and squashed the commits to comply with the Semantic PR requirements. Please let me know if anything else needs adjustment. |
Signed-off-by: remo-lab <remopanda7@gmail.com>
14b6209 to
bf871de
Compare
|




Fixes a resource leak in the Core Keeper registry health check where the HTTP response body was not closed.
Since health checks run periodically per registered service, this caused file descriptors to accumulate over time, potentially leading to “too many open files” errors.
The fix ensures the response body is always closed on all execution paths. Unit tests were added to validate the behavior.
Fixes #5327
✔️ ✔️The Core Keeper registry health check performs periodic HTTP requests for each registered service but did not close the HTTP response body on any execution path.
Since these checks run continuously in background goroutines, the unclosed response bodies caused file descriptors to accumulate over time.
In production deployments with multiple services, this could lead to file descriptor exhaustion, resulting in failed HTTP requests, degraded health monitoring, or service instability.
Closing the response body on all paths prevents this resource leak without altering existing behavior.
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:describing the break)Testing Instructions
Run unit tests: