Open horvbalint opened 5 months ago
Hi,
I can confirm this health check is not working as expected with error code.
Here's example repo to try: Return Custom Error
By default this repo will return error code 401 with message "Unauthorized" and can be configured with environment variable ERROR_CODE and ERROR_MESSAGE
This will be fixed in the upcoming version.
I had to revert it in v284, because it caused unexpected errors.
The main problem of using non-200 return codes is that if you test the health of your application with curl, it will return a non-0 return code (the command itself) if the http return code is not 200. This means the container will be in starting state until all healthcheck's are done.
I need to spend more time on this before doing any changes as it easily could fail already working deployments.
Description
When setting up healthcheck there is a field called "Return Code", this suggests that it is possible to specify the expected response code of the path. This is great I have multiple backends where paths are behind a middleware so they return 401 for the healtcheck pings. Saldy setting this field to 401 does not produce the desired outcome, the healtcheck will fail. More specificaly, the status will stuck in "Starting". As to my knowledge this is because the docker healtcheck does not get the correct return code.
I tried to check the codebase and I think the value of this field is not used anywhere, seemingly it was forgotten. It would be great to have this feature :)
Minimal Reproduction (if possible, example repository)
Start a service that returns 401 on one of its route and enable healthcheck on this route with "Return Code" 401. Try to deploy the service.
Exception or Error
The container will be stuck in starting status.
Version
v4.0.0-beta.277