Skip to content

Commit 1081090

Browse files
authored
refactor: Refactor PostgreSQL config inclusion and paths (#1971)
- Update Dockerfiles to standardize `unix_socket_directories`. - Introduce `include_dir` in `postgresql.conf.j2` to manage configurations within `/etc/postgresql-custom/conf.d/`. - Migrate generated optimizations and custom overrides to the new `conf.d` directory. - Adjust service files (`database-optimizations.service`, `postgres_prestart.sh`) and Ansible tasks to reference the updated configuration paths.
1 parent 6a97ebe commit 1081090

12 files changed

+12
-34
lines changed

Dockerfile-15

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /h
218218
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
219219

220220
RUN sed -i \
221-
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
222221
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
223222
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
224223
/etc/postgresql/postgresql.conf && \

Dockerfile-17

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /h
222222
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
223223

224224
RUN sed -i \
225-
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
226225
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
227226
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
228227
/etc/postgresql/postgresql.conf && \

Dockerfile-orioledb-17

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ COPY --chown=postgres:postgres ansible/files/walg_helper_scripts/wal_fetch.sh /h
222222
COPY ansible/files/walg_helper_scripts/wal_change_ownership.sh /root/wal_change_ownership.sh
223223

224224
RUN sed -i \
225-
-e "s|#unix_socket_directories = '/tmp'|unix_socket_directories = '/var/run/postgresql'|g" \
226225
-e "s|#session_preload_libraries = ''|session_preload_libraries = 'supautils'|g" \
227226
-e "s|#include = '/etc/postgresql-custom/supautils.conf'|include = '/etc/postgresql-custom/supautils.conf'|g" \
228227
/etc/postgresql/postgresql.conf && \

ansible/files/database-optimizations.service.j2 renamed to ansible/files/database_optimizations.service

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/conf.d/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/conf.d/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

ansible/files/postgresql_config/conf.d/custom_overrides.conf

Whitespace-only changes.

ansible/files/postgresql_config/conf.d/generated_optimizations.conf

Whitespace-only changes.

ansible/files/postgresql_config/postgresql.conf.j2

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ listen_addresses = '*' # what IP address(es) to listen on;
6464
#port = 5432 # (change requires restart)
6565
#max_connections = 100 # (change requires restart)
6666
#superuser_reserved_connections = 3 # (change requires restart)
67-
#unix_socket_directories = '/tmp' # comma-separated list of directories
67+
unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories
6868
# (change requires restart)
6969
#unix_socket_group = '' # (change requires restart)
7070
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
@@ -752,11 +752,6 @@ jit_provider = 'llvmjit' # JIT library to use
752752
#include_if_exists = '...' # include file only if it exists
753753
#include = '...' # include file
754754

755-
# Automatically generated optimizations
756-
#include = '/etc/postgresql-custom/generated-optimizations.conf'
757-
# User-supplied custom parameters, override any automatically generated ones
758-
#include = '/etc/postgresql-custom/custom-overrides.conf'
759-
760755
# supautils specific configurations
761756
#include = '/etc/postgresql-custom/supautils.conf'
762757

ansible/files/postgresql_config/postgresql.service.j2 renamed to ansible/files/postgresql_config/postgresql.service

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Description=PostgreSQL database server
33
Documentation=man:postgres(1)
44
{% if supabase_internal is defined %}
5-
Requires=database-optimizations.service
6-
After=database-optimizations.service
5+
Requires=database_optimizations.service
6+
After=database_optimizations.service
77
{% endif %}
88

99
[Service]

ansible/tasks/setup-postgres.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@
147147
group: 'postgres'
148148
mode: '0664'
149149
owner: 'postgres'
150-
path: "/etc/postgresql-custom/{{ pg_config_item }}"
150+
path: "/etc/postgresql-custom/conf.d{{ pg_config_item }}"
151151
state: 'touch'
152152
loop:
153-
- 'custom-overrides.conf'
154-
- 'generated-optimizations.conf'
153+
- 'custom_overrides.conf'
154+
- 'generated_optimizations.conf'
155155
loop_control:
156156
loop_var: 'pg_config_item'
157157

@@ -274,9 +274,9 @@
274274
- name: copy PG and optimizations systemd units
275275
ansible.builtin.template:
276276
dest: "/etc/systemd/system/{{ systemd_svc_item | basename }}"
277-
src: "files/{{ systemd_svc_item }}.j2"
277+
src: "files/{{ systemd_svc_item }}"
278278
loop:
279-
- 'database-optimizations.service'
279+
- 'database_optimizations.service'
280280
- 'postgresql_config/postgresql.service'
281281
loop_control:
282282
loop_var: 'systemd_svc_item'

0 commit comments

Comments
 (0)