timescale / timescaledb-docker

Release Docker builds of TimescaleDB
Apache License 2.0
295 stars 130 forks source link

add `pg_isready` healthcheck #187

Closed abonander closed 2 years ago

abonander commented 2 years ago

The lack of a healthcheck is making this image painful to use as a service in Gitlab CI because without a healthcheck it will start the container and then immediately move on to running the job script. Sometimes the database stands up quick enough to handle it, and sometimes not, giving us spurious "connection refused" errors.

It looks like the pg_isready command is available in the image as I have tested it locally and it works.

Closes #64

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

abonander commented 2 years ago

So it looks like the official Postgres image opted not to implement a healthcheck for various reasons: https://github.com/docker-library/postgres/issues/282#issuecomment-558867369

In fact, it appears that Gitlab CI implements its own health checks that wait for connections to be accepted on whatever ports are exposed by the image.

So why am I getting spurious "connection refused" errors?

abonander commented 2 years ago

It appears this may be a bug with the Gitlab-CI kubernetes executor: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27969

abonander commented 2 years ago

Since Kubernetes ignores healthchecks in Dockerfiles anyway, merging this PR would not solve our problem and as shown above there's potentially good reasons to not add a health check to the dockerfile anyway.