Improve health check handlers for endpoint and console (GET/HEAD, safer error handling) #942
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.
Type of Change
Related Issues
#935Summary of Changes
Summary
This PR improves the health check endpoints for both the S3 endpoint and the console:
/health(S3 endpoint) viaHealthCheckHandler/rustfs/console/healthviahealth_checkinconsole.rsThe goal is to support proper
GET/HEADsemantics, avoid panics in error paths, and keep the responses stable for monitoring systems.Changes
HealthCheckHandler:GETandHEAD405 Method Not AllowedwithAllow: GET, HEADfor othersHEAD, return only status and headers with an empty bodyhealth_checkhandler:GETandHEADGETreturns detailed JSON health infoHEADreturns only status and headers with an empty bodyunwrap()calls in health check paths with safe fallbacks:unwrap_or_default,unwrap_or_else, and explicit error loggingSystemTimeissueswith existing probes and monitoring tools.
Motivation
load balancers and monitoring systems.
HEADsemantics so that probes can cheaply verify livenessand readiness without transferring bodies.
Allowheader) so thatAPI behavior is clear and predictable.
Testing
GET /healthreturns HTTP 200 with JSON body.HEAD /healthreturns HTTP 200 with headers, empty body.GET /rustfs/console/healthreturns detailed status JSON.HEAD /rustfs/console/healthreturns HTTP 200 with headers, empty body.POST) on these endpoints return 405 withAllow: GET, HEAD.cargo test -p rustfs --testsChecklist
make pre-commitImpact
Additional Notes
Thank you for your contribution! Please ensure your PR follows the community standards (CODE_OF_CONDUCT.md) and sign the CLA if this is your first contribution.