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

Portable database health check #70

Merged
merged 2 commits into from
Feb 3, 2023

Conversation

jbradberry
Copy link
Contributor

to ensure that the Django migrations do not run until the database is fully up.

The previous solution, to use the long form of depends_on: in our compose.yaml file, isn't supported by podman-compose: containers/podman-compose#453

to ensure that the Django migrations do not run until the database is
fully up.

The previous solution, to use the long form of `depends_on:` in our
compose.yaml file, isn't supported by podman-compose:
containers/podman-compose#453
until echo -e 'import sys\nfrom django.db import connection\ntry:\n connection.ensure_connection()\nexcept Exception:\n sys.exit(1)\n' | /var/www/venv/bin/python ansible_wisdom/manage.py shell
do
echo "Waiting until the database is ready..."
sleep 5
Copy link
Contributor

@gebhardtr gebhardtr Feb 2, 2023

Choose a reason for hiding this comment

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

Does it make sense to factor this sleep out of the loop and add it as a criterion in the probe? ("keep running launch_wisdom until it succeeds"?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both ways seem equivalent to me.

@jbradberry jbradberry marked this pull request as draft February 2, 2023 21:38
Copy link
Member

@matburt matburt left a comment

Choose a reason for hiding this comment

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

This works for me.

@@ -1,4 +1,10 @@
#!/bin/bash
until echo -e 'import sys\nfrom django.db import connection\ntry:\n connection.ensure_connection()\nexcept Exception:\n sys.exit(1)\n' | /var/www/venv/bin/python ansible_wisdom/manage.py shell
Copy link
Contributor

@jameswnl jameswnl Feb 2, 2023

Choose a reason for hiding this comment

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

How about using this format which makes python code easier on the eyes? https://gist.github.com/jameswnl/b6e6038aafef2dc3ae67e59b20180599
(This is from automation-analytics which is in GitLab. cleaned and dropped there for easier access)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think that's a good idea. Updated.

to more readably construct the Python script to be run.
@jbradberry jbradberry marked this pull request as ready for review February 3, 2023 15:16
@robinbobbitt robinbobbitt merged commit c913399 into ansible:main Feb 3, 2023
@jbradberry jbradberry deleted the portable-db-healthcheck branch February 3, 2023 15:35
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.

None yet

5 participants