Skip to content

Healthchecks to ensure django container kicks off only after db container is healthy.#23

Open
radhaksri wants to merge 2 commits intoopenkilt:masterfrom
radhaksri:master
Open

Healthchecks to ensure django container kicks off only after db container is healthy.#23
radhaksri wants to merge 2 commits intoopenkilt:masterfrom
radhaksri:master

Conversation

@radhaksri
Copy link

Prior to this proposed fix, django container kicks off as soon as the db container is created. This ends up in these errors on the django container startup as shown in the attached file.

all_containers_launch.log

The proposed fix implements a health check that uses pg_isready to establish that postgres db is indeed ready, and for the django container to wait for db container to be healthy before kicking off migrations.

…ff django container

Setting up health checks for postgres db to be ready before kicking off django container
Removed version tag - redundant as per docker.
@radhaksri
Copy link
Author

@inistor, @matthill, @denisgolius, @k0ste : Created this PR to let django container start only after db container is healthy. Please review and merge as you see fit!

Comment on lines 43 to 44
depends_on:
- "django"
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand the architecture correctly, the worker container depends directly on the DB, not on django - so its depends_on directive should be similar to django's.

Comment on lines -14 to -15


Copy link
Contributor

Choose a reason for hiding this comment

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

Pedantic: this PR should only perform changes related to its purpose, omitting styling or typos - it's easier to follow

@@ -1,4 +1,3 @@
version: "3.9"
Copy link
Contributor

Choose a reason for hiding this comment

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

Pedantic: this PR should only perform changes related to its purpose, omitting styling or typos - it's easier to follow

Comment on lines +57 to +61
healthcheck:
test: [ "CMD-SHELL", "sh -c 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'" ]
interval: 10s
timeout: 5s
retries: 5
Copy link
Contributor

Choose a reason for hiding this comment

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

A simpler healthcheck directive might be better:

    healthcheck:
        test: pg_isready
        interval: 5s

See this PR.

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.

2 participants