Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pg_isready healthcheck #187

Closed
wants to merge 1 commit into from
Closed

Conversation

abonander
Copy link

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
Copy link

CLAassistant commented May 27, 2022

CLA assistant check
All committers have signed the CLA.

@@ -77,3 +77,5 @@ RUN set -ex \
&& apk del .fetch-deps .build-deps \
&& rm -rf /build \
&& sed -r -i "s/[#]*\s*(shared_preload_libraries)\s*=\s*'(.*)'/\1 = 'timescaledb,\2'/;s/,'/'/" /usr/local/share/postgresql/postgresql.conf.sample

HEALTCHECK CMD pg_isready -U postgres
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this use $POSTGRES_USER instead?

@abonander
Copy link
Author

So it looks like the official Postgres image opted not to implement a healthcheck for various reasons: docker-library/postgres#282 (comment)

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
Copy link
Author

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

@abonander abonander closed this Jun 2, 2022
@abonander abonander deleted the patch-1 branch June 2, 2022 23:43
@abonander
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add healthcheck to the Docker image
2 participants