CircleCI-Public / cimg-postgres

MIT License
8 stars 24 forks source link

Allow pg_cron to work on any configured POSTGRES_DB #95

Closed stig closed 1 year ago

stig commented 1 year ago

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!

JalexChen commented 1 year ago

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

stig commented 1 year ago

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.