cloud-service-broker icon indicating copy to clipboard operation
cloud-service-broker copied to clipboard

[FR] Add HEALTHCHECK to Dockerfile

Open mogul opened this issue 4 years ago • 2 comments

Is your feature request related to a problem? Please describe.

When using the Docker image in automated testing, after we start the CSB and then run tests (with the eden OSBAPI client), we see:

Could not find service in catalog: Could not fetch catalog: Failed doing HTTP request: Get http://127.0.0.1:8080/v2/catalog: read tcp 127.0.0.1:54568->127.0.0.1:8080: read: connection reset by peer

This is because after startup of the CSB, there is a period where the broker is still reading files and not yet ready to serve requests, and there's no good way to know when the CSB is actually ready.

Describe the solution you'd like

The Dockerfile should include a HEALTHCHECK directive so that scripts and Makefiles can explicitly wait for the container to be healthy before proceeding.

Describe alternatives you've considered

We previously added in a delay to wait at least X seconds after starting the image before proceeding to run tests, where X was picked by trial and error. This felt like a pretty poor workaround, given that the performance between the GitHub Actions runner and our local machines varies widely, and we didn't want to inject any more delay than was necessary into our manual iteration time.

Additional Context

I worked out what the healthcheck should be over here (though you may want to change the interval and retry count). With the healthcheck in place, here's a one-liner that waits for the container to be healthy.

Priority

Low

Priority Context

I'd like to remove as much complexity from my Makefile as possible, and having a built-in healthcheck will benefit other users of the CSB in various contexts. However, I'm clearly able to work around the problem now by supplying the docker run arguments.

Platform

N/A

Applicable Services

N/A

mogul avatar Dec 04 '20 15:12 mogul

HEALTHCHECK seems to be global to the container, but is only necessary in one use case for the container - when running the server in a test mode. The other use cases like building brokerpaks, generating docs, running the test examples; a global health check may not work.

Happy to have someone do some investigation here and offer a PR to the dockerfile

erniebilling avatar Dec 04 '20 17:12 erniebilling

Note this may be a good reason for specifying the HEALTHCHECK via CLI params as I did in the example... If so then this should be documented for folks to find... even if only in the form of specifying those parameters in your own Makefile for them to copy from!

mogul avatar Dec 19 '20 18:12 mogul