Skip to content

Allow pg_cron to work on any configured POSTGRES_DB #95

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

Merged
merged 1 commit into from
Jun 22, 2023

Conversation

stig
Copy link
Contributor

@stig stig commented Jun 22, 2023

For our official CircleCI Docker Convenience Image support policy, please see CircleCI docs.

This policy outlines the release, update, and deprecation policy for CircleCI Docker Convenience Images.


Description

This fixes ownership of the files in the /etc/postgresql directory, so the pg_cron.sh script can amend these files as it expects to do.

Reasons

Due to incorrect ownership of /etc/postgresql/custom-postgresql.conf the pg_cron.sh script was not able to add POSTGRES_DB to the cron.database_name config. Thus the only DB that would work with pg_cron is the 'circle_test' DB, as this was hard-coded in the example file.

This fixes ownership of the files in the /etc/postgresql directory, so the pg_cron.sh script can run without errors.

Checklist

Please check through the following before opening your PR. Thank you!

  • I have made changes to the Dockerfile.template file only
  • I have not made any manual changes to automatically generated files
  • My PR follows best practices as described in the contributing guidelines
  • (Optional, but recommended) My commits are signed

@stig stig requested a review from a team as a code owner June 22, 2023 10:36
@JalexChen
Copy link

i think this 'works', but because pg_cron.sh is still running and appending to the custom-postgresql.conf. even if you can now edit the file, the initial value of cron.database_name = circle_test would still be there, and i believe pg_cron can only run one instance.

you can run jobs in a separate database with some tinkering, but i think the play would be either:

  1. the custom-postgresql.conf database_name value is set to $POSTGRES_DB, and the env is defined in the docker run command to e.g docker run -it -e POSTGRES_DB=something cimg/postgres:xxx

  2. a separate env file that can be modified from defaults, sourced, then used

Due to incorrect ownership of /etc/postgresql/custom-postgresql.conf
the pg_cron.sh script was not able to add POSTGRES_DB to the
`cron.database_name` config. Thus the only DB that would work with
pg_cron is the 'circle_test' DB, as this was hard-coded in the example
file.

This fixes ownership of the files in the /etc/postgresql directory, so
the pg_cron.sh script can run as expected.

Also remove the cron-related lines from custom-postgresql.conf since
pg_cron.sh is adding those two lines and we don't want confusion
around duplicate settings. (Last one wins, for what it's worth.)
@stig
Copy link
Contributor Author

stig commented Jun 22, 2023

i think this 'works', but because pg_cron.sh is still running and appending to the custom-postgresql.conf. even if you can now edit the file, the initial value of cron.database_name = circle_test would still be there, and i believe pg_cron can only run one instance.

you can run jobs in a separate database with some tinkering, but i think the play would be either:

  1. the custom-postgresql.conf database_name value is set to $POSTGRES_DB, and the env is defined in the docker run command to e.g docker run -it -e POSTGRES_DB=something cimg/postgres:xxx
  2. a separate env file that can be modified from defaults, sourced, then used

We had a brief chat, and decided that (even though the last setting wins) the best course of action would be to remove the two settings pg_cron.sh adds from the custom-postgresql.conf settings so there is no ambiguity.

@JalexChen JalexChen merged commit 92e57a6 into CircleCI-Public:main Jun 22, 2023
stig added a commit to stig/cimg-postgres that referenced this pull request Jul 24, 2023
Due to incorrect ownership of /etc/postgresql/custom-postgresql.conf
the pg_cron.sh script was not able to add POSTGRES_DB to the
`cron.database_name` config. Thus the only DB that would work with
pg_cron is the 'circle_test' DB, as this was hard-coded in the example
file.

This fixes ownership of the files in the /etc/postgresql directory, so
the pg_cron.sh script can run as expected.

Also remove the cron-related lines from custom-postgresql.conf since
pg_cron.sh is adding those two lines and we don't want confusion
around duplicate settings. (Last one wins, for what it's worth.)
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