Skip to content

Commit da18a61

Browse files
author
Chris Stockton
committed
Merge branch 'develop' into cs/feat-config-reloads
2 parents 44ba607 + f7bb3fe commit da18a61

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1112
-268
lines changed

.github/workflows/publish-nix-pgupgrade-scripts.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
id: process_release_version
7373
run: |
7474
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
75+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
76+
VERSION=${{ inputs.postgresVersion }}
77+
fi
7578
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
7679
7780
- name: Create a tarball containing pg_upgrade scripts

.github/workflows/testinfra-nix.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ jobs:
6565
- name: Cleanup resources on build cancellation
6666
if: ${{ cancelled() }}
6767
run: |
68-
aws ec2 --region ap-southeast-1 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -n 1 -I {} aws ec2 terminate-instances --region ap-southeast-1 --instance-ids {}
69-
70-
- name: Cleanup resources on build cancellation
68+
aws ec2 --region ap-southeast-1 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --region ap-southeast-1 --instance-ids
69+
70+
- name: Cleanup resources after build
7171
if: ${{ always() }}
7272
run: |
73-
aws ec2 --region ap-southeast-1 describe-instances --filters "Name=tag:testinfra-run-id,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -n 1 -I {} aws ec2 terminate-instances --region ap-southeast-1 --instance-ids {} || true
73+
aws ec2 --region ap-southeast-1 describe-instances --filters "Name=tag:testinfra-run-id,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --region ap-southeast-1 --instance-ids || true
7474
7575
- name: Cleanup AMIs
7676
if: always()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Aside from having [ufw](https://help.ubuntu.com/community/UFW),[fail2ban](https:
5151
| Goodie | Version | Description |
5252
| ------------- | :-------------: | ------------- |
5353
| [PgBouncer](https://www.pgbouncer.org/) | [1.16.1](http://www.pgbouncer.org/changelog.html#pgbouncer-116x) | Set up Connection Pooling. |
54-
| [PostgREST](https://postgrest.org/en/stable/) | [v10.1.1](https://github.com/PostgREST/postgrest/releases/tag/v10.1.1) | Instantly transform your database into an RESTful API. |
54+
| [PostgREST](https://postgrest.org/en/stable/) | [v12.2.3](https://github.com/PostgREST/postgrest/releases/tag/v12.2.3) | Instantly transform your database into an RESTful API. |
5555
| [WAL-G](https://github.com/wal-g/wal-g#wal-g) | [v2.0.1](https://github.com/wal-g/wal-g/releases/tag/v2.0.1) | Tool for physical database backup and recovery. |
5656

5757
## Install

ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ begin
356356
end
357357
, case when rec.grantee = 'postgres'::regrole then 'supabase_admin'
358358
when rec.grantee = 'supabase_admin'::regrole then 'postgres'
359-
else rec.grantee::regrole
359+
when rec.grantee = 0 then 'public'
360+
else rec.grantee::regrole::text
360361
end
361362
));
362363
end if;
@@ -382,7 +383,7 @@ begin
382383
when obj->>'objtype' = 'T' then 'types'
383384
when obj->>'objtype' = 'n' then 'schemas'
384385
end
385-
, rec.grantee::regrole
386+
, case when rec.grantee = 0 then 'public' else rec.grantee::regrole::text end
386387
, case when rec.is_grantable then 'with grant option' else '' end
387388
));
388389
end if;
@@ -529,7 +530,14 @@ $$;
529530
alter database postgres connection limit -1;
530531
531532
-- #incident-2024-09-12-project-upgrades-are-temporarily-disabled
532-
grant pg_read_all_data, pg_signal_backend to postgres;
533+
do $$
534+
begin
535+
if exists (select from pg_authid where rolname = 'pg_read_all_data') then
536+
execute('grant pg_read_all_data to postgres');
537+
end if;
538+
end
539+
$$;
540+
grant pg_signal_backend to postgres;
533541
534542
set session authorization supabase_admin;
535543
drop role supabase_tmp;

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# them depending on regtypes referencing system OIDs or outdated library files.
1212
EXTENSIONS_TO_DISABLE=(
1313
"pg_graphql"
14+
"pg_stat_monitor"
1415
)
1516

1617
PG14_EXTENSIONS_TO_DISABLE=(
@@ -119,20 +120,22 @@ cleanup() {
119120
CI_start_postgres
120121
fi
121122

123+
retry 8 pg_isready -h localhost -U supabase_admin
124+
122125
echo "Re-enabling extensions"
123126
if [ -f $POST_UPGRADE_EXTENSION_SCRIPT ]; then
124-
run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
127+
retry 5 run_sql -f $POST_UPGRADE_EXTENSION_SCRIPT
125128
fi
126129

127130
echo "Removing SUPERUSER grant from postgres"
128-
run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"
131+
retry 5 run_sql -c "ALTER USER postgres WITH NOSUPERUSER;"
129132

130133
echo "Resetting postgres database connection limit"
131-
run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
134+
retry 5 run_sql -c "ALTER DATABASE postgres CONNECTION LIMIT -1;"
132135

133136
if [ -z "$IS_CI" ] && [ -z "$IS_LOCAL_UPGRADE" ]; then
134137
echo "Unmounting data disk from ${MOUNT_POINT}"
135-
umount $MOUNT_POINT
138+
retry 3 umount $MOUNT_POINT
136139
fi
137140
echo "$UPGRADE_STATUS" > /tmp/pg-upgrade-status
138141

@@ -208,7 +211,7 @@ function patch_wrappers {
208211
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
209212
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
210213
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
211-
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
214+
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" || true
212215
fi
213216
fi
214217
done
@@ -222,7 +225,7 @@ function patch_wrappers {
222225
LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
223226
if [ "$WRAPPERS_LIB_PATH" != "$PGLIBNEW/${LIB_FILE_NAME}" ]; then
224227
echo "Copying $WRAPPERS_LIB_PATH to $PGLIBNEW/${LIB_FILE_NAME}"
225-
cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}"
228+
cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}" || true
226229
fi
227230
fi
228231
fi

ansible/files/adminapi.sudoers.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Cmnd_Alias PGBOUNCER = /bin/systemctl start pgbouncer.service, /bin/systemctl st
1717
%adminapi ALL= NOPASSWD: /usr/bin/systemctl restart postgresql.service
1818
%adminapi ALL= NOPASSWD: /usr/bin/systemctl show -p NRestarts postgresql.service
1919
%adminapi ALL= NOPASSWD: /usr/bin/systemctl restart adminapi.service
20+
%adminapi ALL= NOPASSWD: /usr/bin/systemctl is-active commence-backup.service
21+
%adminapi ALL= NOPASSWD: /usr/bin/systemctl start commence-backup.service
2022
%adminapi ALL= NOPASSWD: /bin/systemctl daemon-reload
2123
%adminapi ALL= NOPASSWD: /bin/systemctl restart services.slice
2224
%adminapi ALL= NOPASSWD: /usr/sbin/nft -f /etc/nftables/supabase_managed.conf
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[Unit]
2+
Description=Async commence physical backup
3+
4+
[Service]
5+
Type=simple
6+
User=adminapi
7+
ExecStart=/usr/bin/admin-mgr commence-backup --run-as-service true
8+
Restart=no
9+
OOMScoreAdjust=-1000
10+
11+
[Install]
12+
WantedBy=multi-user.target

ansible/files/envoy_config/lds.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,10 @@ resources:
254254
type.googleapis.com/envoy.extensions.filters.http.rbac.v3.RBACPerRoute
255255
- match:
256256
safe_regex:
257+
google_re2:
258+
max_program_size: 150
257259
regex: >-
258-
/auth/v1/(verify|callback|authorize|sso/saml/(acs|metadata|slo))
260+
/auth/v1/(verify|callback|authorize|sso/saml/(acs|metadata|slo)|\.well-known/(openid-configuration|jwks\.json))
259261
route:
260262
cluster: gotrue
261263
regex_rewrite:

ansible/files/postgresql_config/supautils.conf.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ supautils.policy_grants = '{"postgres":["auth.audit_log_entries","auth.identitie
33
# full list: address_standardizer, address_standardizer_data_us, adminpack, amcheck, autoinc, bloom, btree_gin, btree_gist, citext, cube, dblink, dict_int, dict_xsyn, earthdistance, file_fdw, fuzzystrmatch, hstore, http, hypopg, index_advisor, insert_username, intagg, intarray, isn, lo, ltree, moddatetime, old_snapshot, orioledb, pageinspect, pg_buffercache, pg_cron, pg_freespacemap, pg_graphql, pg_hashids, pg_jsonschema, pg_net, pg_prewarm, pg_repack, pg_stat_monitor, pg_stat_statements, pg_surgery, pg_tle, pg_trgm, pg_visibility, pg_walinspect, pgaudit, pgcrypto, pgjwt, pgroonga, pgroonga_database, pgrouting, pgrowlocks, pgsodium, pgstattuple, pgtap, plcoffee, pljava, plls, plpgsql, plpgsql_check, plv8, postgis, postgis_raster, postgis_sfcgal, postgis_tiger_geocoder, postgis_topology, postgres_fdw, refint, rum, seg, sslinfo, supabase_vault, supautils, tablefunc, tcn, timescaledb, tsm_system_rows, tsm_system_time, unaccent, uuid-ossp, vector, wrappers, xml2
44
# omitted because may be unsafe: adminpack, amcheck, file_fdw, lo, old_snapshot, pageinspect, pg_buffercache, pg_freespacemap, pg_surgery, pg_visibility
55
# omitted because deprecated: intagg, xml2
6-
supautils.privileged_extensions = 'address_standardizer, address_standardizer_data_us, autoinc, bloom, btree_gin, btree_gist, citext, cube, dblink, dict_int, dict_xsyn, earthdistance, fuzzystrmatch, hstore, http, hypopg, index_advisor, insert_username, intarray, isn, ltree, moddatetime, orioledb, pg_cron, pg_graphql, pg_hashids, pg_jsonschema, pg_net, pg_repack, pg_stat_monitor, pg_stat_statements, pg_tle, pg_trgm, pg_walinspect, pgaudit, pgcrypto, pgjwt, pg_prewarm, pgroonga, pgroonga_database, pgrouting, pgrowlocks, pgstattuple, pgsodium, pgtap, plcoffee, pljava, plls, plpgsql, plpgsql_check, plv8, postgis, postgis_raster, postgis_sfcgal, postgis_tiger_geocoder, postgis_topology, postgres_fdw, refint, rum, seg, sslinfo, supabase_vault, supautils, tablefunc, tcn, timescaledb, tsm_system_rows, tsm_system_time, unaccent, uuid-ossp, vector, wrappers'
6+
supautils.privileged_extensions = 'address_standardizer, address_standardizer_data_us, autoinc, bloom, btree_gin, btree_gist, citext, cube, dblink, dict_int, dict_xsyn, earthdistance, fuzzystrmatch, hstore, http, hypopg, index_advisor, insert_username, intarray, isn, ltree, moddatetime, orioledb, pg_cron, pg_graphql, pg_hashids, pg_jsonschema, pg_net, pg_partman, pg_repack, pg_stat_monitor, pg_stat_statements, pg_tle, pg_trgm, pg_walinspect, pgaudit, pgcrypto, pgjwt, pg_prewarm, pgmq, pgroonga, pgroonga_database, pgrouting, pgrowlocks, pgstattuple, pgsodium, pgtap, plcoffee, pljava, plls, plpgsql, plpgsql_check, plv8, postgis, postgis_raster, postgis_sfcgal, postgis_tiger_geocoder, postgis_topology, postgres_fdw, refint, rum, seg, sslinfo, supabase_vault, supautils, tablefunc, tcn, timescaledb, tsm_system_rows, tsm_system_time, unaccent, uuid-ossp, vector, wrappers'
77
supautils.privileged_extensions_custom_scripts_path = '/etc/postgresql-custom/extension-custom-scripts'
88
supautils.privileged_extensions_superuser = 'supabase_admin'
99
supautils.privileged_role = 'postgres'

ansible/tasks/internal/admin-api.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@
7979
src: files/adminapi.service.j2
8080
dest: /etc/systemd/system/adminapi.service
8181

82+
- name: adminapi - create service file for commence backup process
83+
template:
84+
src: files/commence-backup.service.j2
85+
dest: /etc/systemd/system/commence-backup.service
86+
8287
- name: UFW - Allow connections to adminapi ports
8388
ufw:
8489
rule: allow

0 commit comments

Comments
 (0)