Skip to content

Commit 0987406

Browse files
hunleydsamrose
andauthored
refactor(postgresq): switch to 'include_dir' and then renames conf files to ensure ordering (#1820)
Co-authored-by: Sam Rose <[email protected]>
1 parent e67b478 commit 0987406

18 files changed

+111
-729
lines changed

Dockerfile-15

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,21 @@ COPY --from=walg /tmp/wal-g /usr/local/bin/
158158
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
159159
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf
160160
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf
161-
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf
162-
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
161+
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql-custom/00-logging.conf
162+
COPY --chown=postgres:postgres ansible/files/postgresql_config/autoexplain.conf /etc/postgresql-custom/auto_explain.conf
163+
COPY --chown=postgres:postgres ansible/files/postgresql_config/pgcron.conf /etc/postgresql-custom/pg_cron.conf
164+
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/05-supautils.conf
163165
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
164166
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
165-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf
166-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
167+
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/04-read-replica.conf
168+
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/03-wal-g.conf
167169
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
168170
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
169171

170172
RUN sed -i \
171173
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
172174
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
173-
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
174-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
175+
/etc/postgresql/postgresql.conf && \
175176
echo "cron.database_name = 'postgres'" >> /etc/postgresql/postgresql.conf && \
176177
#echo "pljava.libjvm_location = '/usr/lib/jvm/java-11-openjdk-${TARGETARCH}/lib/server/libjvm.so'" >> /etc/postgresql/postgresql.conf && \
177178
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \

Dockerfile-17

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,21 @@ COPY --from=walg /tmp/wal-g /usr/local/bin/
162162
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
163163
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf
164164
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf
165-
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf
166-
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
165+
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql-custom/00-logging.conf
166+
COPY --chown=postgres:postgres ansible/files/postgresql_config/autoexplain.conf /etc/postgresql-custom/auto_explain.conf
167+
COPY --chown=postgres:postgres ansible/files/postgresql_config/pgcron.conf /etc/postgresql-custom/pg_cron.conf
168+
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/05-supautils.conf
167169
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
168170
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
169-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf
170-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
171+
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/04-read-replica.conf
172+
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/03-wal-g.conf
171173
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
172174
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
173175

174176
RUN sed -i \
175177
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
176178
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
177-
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
178-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
179+
/etc/postgresql/postgresql.conf && \
179180
echo "cron.database_name = 'postgres'" >> /etc/postgresql/postgresql.conf && \
180181
#echo "pljava.libjvm_location = '/usr/lib/jvm/java-11-openjdk-${TARGETARCH}/lib/server/libjvm.so'" >> /etc/postgresql/postgresql.conf && \
181182
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
@@ -189,7 +190,7 @@ RUN sed -i \
189190
RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf"
190191
#as of pg 16.4 + this db_user_namespace totally deprecated and will break the server if setting is present
191192
RUN sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;' "/etc/postgresql/postgresql.conf"
192-
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g' "/etc/postgresql-custom/supautils.conf"
193+
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g' "/etc/postgresql-custom/05-supautils.conf"
193194

194195

195196

Dockerfile-orioledb-17

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,21 @@ COPY --from=walg /tmp/wal-g /usr/local/bin/
162162
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql.conf.j2 /etc/postgresql/postgresql.conf
163163
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_hba.conf.j2 /etc/postgresql/pg_hba.conf
164164
COPY --chown=postgres:postgres ansible/files/postgresql_config/pg_ident.conf.j2 /etc/postgresql/pg_ident.conf
165-
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql/logging.conf
166-
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/supautils.conf
165+
COPY --chown=postgres:postgres ansible/files/postgresql_config/postgresql-stdout-log.conf /etc/postgresql-custom/00-logging.conf
166+
COPY --chown=postgres:postgres ansible/files/postgresql_config/autoexplain.conf /etc/postgresql-custom/auto_explain.conf
167+
COPY --chown=postgres:postgres ansible/files/postgresql_config/pgcron.conf /etc/postgresql-custom/pg_cron.conf
168+
COPY --chown=postgres:postgres ansible/files/postgresql_config/supautils.conf.j2 /etc/postgresql-custom/05-supautils.conf
167169
COPY --chown=postgres:postgres ansible/files/postgresql_extension_custom_scripts /etc/postgresql-custom/extension-custom-scripts
168170
COPY --chown=postgres:postgres ansible/files/pgsodium_getkey_urandom.sh.j2 /usr/lib/postgresql/bin/pgsodium_getkey.sh
169-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/read-replica.conf
170-
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/wal-g.conf
171+
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_read_replica.conf.j2 /etc/postgresql-custom/04-read-replica.conf
172+
COPY --chown=postgres:postgres ansible/files/postgresql_config/custom_walg.conf.j2 /etc/postgresql-custom/03-wal-g.conf
171173
COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /home/postgres/wal_fetch.sh
172174
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
173175

174176
RUN sed -i \
175177
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
176178
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
177-
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
178-
-e "s|#include = '/etc/postgresql-custom/wal-g.conf'|include = '/etc/postgresql-custom/wal-g.conf'|g" /etc/postgresql/postgresql.conf && \
179+
/etc/postgresql/postgresql.conf && \
179180
echo "cron.database_name = 'postgres'" >> /etc/postgresql/postgresql.conf && \
180181
#echo "pljava.libjvm_location = '/usr/lib/jvm/java-11-openjdk-${TARGETARCH}/lib/server/libjvm.so'" >> /etc/postgresql/postgresql.conf && \
181182
echo "pgsodium.getkey_script= '/usr/lib/postgresql/bin/pgsodium_getkey.sh'" >> /etc/postgresql/postgresql.conf && \
@@ -189,7 +190,7 @@ RUN sed -i \
189190
RUN sed -i 's/ timescaledb,//g;' "/etc/postgresql/postgresql.conf"
190191
#as of pg 16.4 + this db_user_namespace totally deprecated and will break the server if setting is present
191192
RUN sed -i 's/db_user_namespace = off/#db_user_namespace = off/g;' "/etc/postgresql/postgresql.conf"
192-
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g' "/etc/postgresql-custom/supautils.conf"
193+
RUN sed -i 's/ timescaledb,//g; s/ plv8,//g; s/ postgis,//g; s/ pgrouting,//g' "/etc/postgresql-custom/05-supautils.conf"
193194
RUN sed -i 's/\(shared_preload_libraries.*\)'\''\(.*\)$/\1, orioledb'\''\2/' "/etc/postgresql/postgresql.conf"
194195
RUN echo "default_table_access_method = 'orioledb'" >> "/etc/postgresql/postgresql.conf"
195196

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ EOF
515515
mkdir -p "$MOUNT_POINT/conf"
516516
cp -R /etc/postgresql-custom/* "$MOUNT_POINT/conf/"
517517
# removing supautils config as to allow the latest one provided by the latest image to be used
518-
rm -f "$MOUNT_POINT/conf/supautils.conf" || true
518+
rm -f "$MOUNT_POINT/conf/05-supautils.conf" || true
519519
rm -rf "$MOUNT_POINT/conf/extension-custom-scripts" || true
520520

521521
# removing wal-g config as to allow it to be explicitly enabled on the new instance

ansible/files/database-optimizations.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Description=Postgresql optimizations
44
[Service]
55
Type=oneshot
66
# we do not want failures from these commands to cause downstream service startup to fail
7-
ExecStart=-/opt/supabase-admin-api optimize db --destination-config-file-path /etc/postgresql-custom/generated-optimizations.conf
7+
ExecStart=-/opt/supabase-admin-api optimize db --destination-config-file-path /etc/postgresql-custom/01-generated-optimizations.conf
88
ExecStart=-/opt/supabase-admin-api optimize pgbouncer --destination-config-file-path /etc/pgbouncer-custom/generated-optimizations.ini
99
User=adminapi
1010

ansible/files/postgres_prestart.sh.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ check_orioledb_enabled() {
1515
}
1616

1717
get_shared_buffers() {
18-
local opt_conf="/etc/postgresql-custom/generated-optimizations.conf"
18+
local opt_conf="/etc/postgresql-custom/01-generated-optimizations.conf"
1919
if [ ! -f "$opt_conf" ]; then
2020
return 0
2121
fi
@@ -134,4 +134,4 @@ if [ $(locale -a | grep -c en_US.utf8) -eq 0 ]; then
134134
locale-gen
135135
fi
136136

137-
main
137+
main
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# auto_explain
2+
3+
auto_explain.log_min_duration = 10s
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# pg_cron
2+
3+
cron.database_name = 'postgres'

0 commit comments

Comments
 (0)