Skip to content

Commit a967eb1

Browse files
committed
Merge branch 'release/15.6-lw12' into pcnc/pgroongatesting
2 parents 11b981f + 2e1be6b commit a967eb1

File tree

12 files changed

+256
-47
lines changed

12 files changed

+256
-47
lines changed

.github/workflows/ami-release-nix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
paths:
89
- '.github/workflows/ami-release-nix.yml'
910
- 'common-nix.vars.pkr.hcl'
@@ -54,7 +55,7 @@ jobs:
5455
run: |
5556
packer init stage2-nix-psql.pkr.hcl
5657
GIT_SHA=${{github.sha}}
57-
packer build -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
58+
packer build -var "git_sha=${GIT_SHA}" -var "git-head-version=${GIT_SHA}" -var "packer-execution-id=${GITHUB_RUN_ID}" -var-file="development-arm.vars.pkr.hcl" -var-file="common-nix.vars.pkr.hcl" stage2-nix-psql.pkr.hcl
5859
5960
- name: Grab release version
6061
id: process_release_version

.github/workflows/dockerhub-release-15-6.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
paths:
89
- ".github/workflows/dockerhub-release-15-6.yml"
910
- "common-nix.vars*"
11+
workflow_dispatch:
1012

1113
jobs:
1214
settings:

.github/workflows/nix-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ on:
44
push:
55
branches:
66
- develop
7+
- release/*
78
pull_request:
9+
workflow_dispatch:
810

911
permissions:
1012
contents: read
@@ -56,4 +58,4 @@ jobs:
5658
-e AWS_SESSION_TOKEN=${{ env.AWS_SESSION_TOKEN }} \
5759
base_nix bash -c "./workspace/docker/nix/build_nix.sh"
5860
name: build psql bundle on ${{ matrix.arch }}
59-
61+
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Publish nix pg_upgrade_bin flake version
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
postgresVersion:
7+
description: 'Optional. Postgres version to publish against, i.e. 15.1.1.78'
8+
required: false
9+
10+
permissions:
11+
id-token: write
12+
13+
jobs:
14+
publish-staging:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout Repo
19+
uses: actions/checkout@v3
20+
21+
- name: Grab release version
22+
id: process_release_version
23+
run: |
24+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
25+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
26+
VERSION=${{ inputs.postgresVersion }}
27+
fi
28+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
29+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
30+
31+
- name: Create a tarball containing the latest nix flake version
32+
working-directory: /tmp/
33+
run: |
34+
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
35+
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
36+
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
37+
38+
- name: configure aws credentials - staging
39+
uses: aws-actions/configure-aws-credentials@v1
40+
with:
41+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
42+
aws-region: "us-east-1"
43+
44+
- name: Upload pg_upgrade scripts to s3 staging
45+
run: |
46+
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
47+
48+
- name: Slack Notification on Failure
49+
if: ${{ failure() }}
50+
uses: rtCamp/action-slack-notify@v2
51+
env:
52+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
53+
SLACK_USERNAME: 'gha-failures-notifier'
54+
SLACK_COLOR: 'danger'
55+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
56+
SLACK_FOOTER: ''
57+
58+
publish-prod:
59+
runs-on: ubuntu-latest
60+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
61+
62+
steps:
63+
- name: Checkout Repo
64+
uses: actions/checkout@v3
65+
66+
- name: Grab release version
67+
id: process_release_version
68+
run: |
69+
VERSION=$(grep 'postgres-version' common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g')
70+
if [[ "${{ inputs.postgresVersion }}" != "" ]]; then
71+
VERSION=${{ inputs.postgresVersion }}
72+
fi
73+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
74+
echo "major_version=$(echo $VERSION | cut -d'.' -f1)" >> "$GITHUB_OUTPUT"
75+
76+
- name: Create a tarball containing the latest nix flake version
77+
working-directory: /tmp/
78+
run: |
79+
mkdir -p ${{ steps.process_release_version.outputs.major_version }}
80+
echo $GITHUB_SHA > ${{ steps.process_release_version.outputs.major_version }}/nix_flake_version
81+
tar -czvf pg_upgrade_bin.tar.gz ${{ steps.process_release_version.outputs.major_version }}
82+
83+
- name: configure aws credentials - prod
84+
uses: aws-actions/configure-aws-credentials@v1
85+
with:
86+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
87+
aws-region: "us-east-1"
88+
89+
- name: Upload pg_upgrade scripts to s3 prod
90+
run: |
91+
aws s3 cp /tmp/pg_upgrade_bin.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz
92+
93+
- name: Slack Notification on Failure
94+
if: ${{ failure() }}
95+
uses: rtCamp/action-slack-notify@v2
96+
env:
97+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
98+
SLACK_USERNAME: 'gha-failures-notifier'
99+
SLACK_COLOR: 'danger'
100+
SLACK_MESSAGE: 'Publishing pg_upgrade binaries flake version failed'
101+
SLACK_FOOTER: ''

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- develop
7-
- sam/nix-and-conventional-ami
7+
- release/*
88
paths:
9-
- '.github/workflows/publish-pgupgrade-scripts.yml'
9+
- '.github/workflows/publish-nix-pgupgrade-scripts.yml'
1010
- 'common-nix.vars.pkr.hcl'
1111
workflow_dispatch:
1212
inputs:
@@ -62,7 +62,7 @@ jobs:
6262

6363
publish-prod:
6464
runs-on: ubuntu-latest
65-
if: github.ref_name == 'develop'
65+
if: github.ref_name == 'develop' || contains( github.ref, 'release' )
6666

6767
steps:
6868
- name: Checkout Repo

ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,58 @@ EOF
171171
done
172172
}
173173

174+
function patch_wrappers {
175+
local IS_NIX_UPGRADE=$1
176+
177+
WRAPPERS_ENABLED=$(run_sql -A -t -c "SELECT EXISTS(SELECT 1 FROM pg_extension WHERE extname = 'wrappers');")
178+
if [ "$WRAPPERS_ENABLED" = "f" ]; then
179+
echo "Wrappers extension not enabled. Skipping."
180+
return
181+
fi
182+
183+
# This is a workaround for older versions of wrappers which don't have the expected
184+
# naming scheme, containing the version in their library's file name
185+
# e.g. wrappers-0.1.16.so, rather than wrappers.so
186+
# pg_upgrade errors out when it doesn't find an equivalent file in the new PG version's
187+
# library directory, so we're making sure the new version has the expected (old version's)
188+
# file name.
189+
# After the upgrade completes, the new version's library file is used.
190+
# i.e.
191+
# - old version: wrappers-0.1.16.so
192+
# - new version: wrappers-0.1.18.so
193+
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
194+
if [ "$IS_NIX_UPGRADE" = "true" ]; then
195+
if [ -d "$PGLIBOLD" ]; then
196+
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
197+
OLD_LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
198+
199+
find /nix/store/ -name "wrappers*so" -print0 | while read -r -d $'\0' WRAPPERS_LIB_PATH; do
200+
if [ -f "$WRAPPERS_LIB_PATH" ]; then
201+
WRAPPERS_LIB_PATH_DIR=$(dirname "$WRAPPERS_LIB_PATH")
202+
if [ "$WRAPPERS_LIB_PATH" != "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}" ]; then
203+
echo "Copying $WRAPPERS_LIB_PATH to $WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
204+
cp "$WRAPPERS_LIB_PATH" "$WRAPPERS_LIB_PATH_DIR/${OLD_LIB_FILE_NAME}"
205+
fi
206+
fi
207+
done
208+
fi
209+
else
210+
if [ -d "$PGLIBOLD" ]; then
211+
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)
212+
if [ -f "$WRAPPERS_LIB_PATH" ]; then
213+
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
214+
if [ -f "$OLD_WRAPPER_LIB_PATH" ]; then
215+
LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
216+
if [ "$WRAPPERS_LIB_PATH" != "$PGLIBNEW/${LIB_FILE_NAME}" ]; then
217+
echo "Copying $WRAPPERS_LIB_PATH to $PGLIBNEW/${LIB_FILE_NAME}"
218+
cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}"
219+
fi
220+
fi
221+
fi
222+
fi
223+
fi
224+
}
225+
174226
function initiate_upgrade {
175227
mkdir -p "$MOUNT_POINT"
176228
SHARED_PRELOAD_LIBRARIES=$(cat "$POSTGRES_CONFIG_PATH" | grep shared_preload_libraries | sed "s/shared_preload_libraries =\s\{0,1\}'\(.*\)'.*/\1/")
@@ -324,30 +376,7 @@ function initiate_upgrade {
324376
export LD_LIBRARY_PATH="${PGLIBNEW}"
325377
fi
326378

327-
# This is a workaround for older versions of wrappers which don't have the expected
328-
# naming scheme, containing the version in their library's file name
329-
# e.g. wrappers-0.1.16.so, rather than wrappers.so
330-
# pg_upgrade errors out when it doesn't find an equivalent file in the new PG version's
331-
# library directory, so we're making sure the new version has the expected (old version's)
332-
# file name.
333-
# After the upgrade completes, the new version's library file is used.
334-
# i.e.
335-
# - old version: wrappers-0.1.16.so
336-
# - new version: wrappers-0.1.18.so
337-
# - workaround to make pg_upgrade happy: copy wrappers-0.1.18.so to wrappers-0.1.16.so
338-
if [ -d "$PGLIBOLD" ]; then
339-
WRAPPERS_LIB_PATH=$(find "$PGLIBNEW" -name "wrappers*so" -print -quit)
340-
if [ -f "$WRAPPERS_LIB_PATH" ]; then
341-
OLD_WRAPPER_LIB_PATH=$(find "$PGLIBOLD" -name "wrappers*so" -print -quit)
342-
if [ -f "$OLD_WRAPPER_LIB_PATH" ]; then
343-
LIB_FILE_NAME=$(basename "$OLD_WRAPPER_LIB_PATH")
344-
if [ "$WRAPPERS_LIB_PATH" != "$PGLIBNEW/${LIB_FILE_NAME}" ]; then
345-
echo "Copying $OLD_WRAPPER_LIB_PATH to $WRAPPERS_LIB_PATH"
346-
cp "$WRAPPERS_LIB_PATH" "$PGLIBNEW/${LIB_FILE_NAME}"
347-
fi
348-
fi
349-
fi
350-
fi
379+
patch_wrappers "$IS_NIX_UPGRADE"
351380

352381
echo "9. Creating new data directory, initializing database"
353382
chown -R postgres:postgres "$MOUNT_POINT/"

ansible/playbook.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,9 @@
206206
shell: |
207207
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix profile remove osquery"
208208
when: stage2_nix
209+
210+
- name: nix collect garbage
211+
become: yes
212+
shell: |
213+
sudo -u ubuntu bash -c ". /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh && nix-collect-garbage -d"
214+
when: stage2_nix

ansible/tasks/setup-postgrest.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
- name: PostgREST - system user
22
user: name=postgrest
33

4+
- name: PostgREST - add Postgres PPA gpg key
5+
apt_key:
6+
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
7+
state: present
8+
9+
- name: PostgREST - add Postgres PPA
10+
apt_repository:
11+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
12+
state: present
13+
14+
- name: PostgREST - update apt cache
15+
apt:
16+
update_cache: yes
17+
418
# libpq is a C library that enables user programs to communicate with
519
# the PostgreSQL database server.
620
- name: PostgREST - system dependencies
@@ -9,9 +23,20 @@
923
- libpq5
1024
- libnuma-dev
1125

26+
- name: PostgREST - remove Postgres PPA gpg key
27+
apt_key:
28+
url: https://www.postgresql.org/media/keys/ACCC4CF8.asc
29+
state: absent
30+
31+
- name: PostgREST - remove Postgres PPA
32+
apt_repository:
33+
repo: "deb http://apt.postgresql.org/pub/repos/apt/ focal-pgdg {{ postgresql_major }}"
34+
state: absent
35+
1236
- name: postgis - ensure dependencies do not get autoremoved
1337
shell: |
1438
set -e
39+
apt-mark manual libpq5*
1540
apt-mark manual libnuma*
1641
apt-mark auto libnuma*-dev
1742

ansible/vars.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ postgres_exporter_release_checksum:
5050
arm64: sha256:29ba62d538b92d39952afe12ee2e1f4401250d678ff4b354ff2752f4321c87a0
5151
amd64: sha256:cb89fc5bf4485fb554e0d640d9684fae143a4b2d5fa443009bd29c59f9129e84
5252

53-
adminapi_release: 0.64.2
53+
adminapi_release: 0.66.1
5454
adminmgr_release: 0.22.1
5555

5656
# Postgres Extensions

common-nix.vars.pkr.hcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.6.1.110-pcgroonga"
1+
postgres-version = "15.6.1.114-pcgroonga"

0 commit comments

Comments
 (0)