Skip to content

Commit d9fecca

Browse files
authored
chore: add pg_upgrade scripts publishing workflow; renamed scripts (#683)
* chore: add pg_upgrade scripts publishing workflow; renamed scripts * chore: add pg_upgrade scripts publishing workflow; renamed scripts * chore: fix script; bump version * chore: bump adminapi
1 parent 794bc24 commit d9fecca

File tree

12 files changed

+95
-16
lines changed

12 files changed

+95
-16
lines changed

.github/workflows/check-shellscripts.yml

+7
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,10 @@ jobs:
1818
SHELLCHECK_OPTS: -e SC2001 -e SC2002 -e SC2143
1919
with:
2020
scandir: './ansible/files/admin_api_scripts'
21+
22+
- name: Run ShellCheck on pg_upgrade scripts
23+
uses: ludeeus/action-shellcheck@master
24+
env:
25+
SHELLCHECK_OPTS: -e SC2001 -e SC2002 -e SC2143
26+
with:
27+
scandir: './ansible/files/admin_api_scripts/pg_upgrade_scripts'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish pg_upgrade_scripts
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
paths:
8+
- '.github/workflows/publish-pgupgrade-scripts.yml'
9+
- 'common.vars.pkr.hcl'
10+
workflow_dispatch:
11+
12+
permissions:
13+
id-token: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout Repo
21+
uses: actions/checkout@v3
22+
23+
- name: Grab release version
24+
id: process_release_version
25+
run: |
26+
VERSION=$(sed -e 's/postgres-version = "\(.*\)"/\1/g' common.vars.pkr.hcl)
27+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
28+
29+
- name: Create a tarball containing pg_upgrade scripts
30+
run: |
31+
mkdir -p /tmp/pg_upgrade_scripts
32+
cp -r ansible/files/admin_api_scripts/pg_upgrade_scripts/* /tmp/pg_upgrade_scripts
33+
tar -czvf /tmp/pg_upgrade_scripts.tar.gz -C /tmp/ pg_upgrade_scripts
34+
35+
- name: configure aws credentials - staging
36+
uses: aws-actions/configure-aws-credentials@v1
37+
with:
38+
role-to-assume: ${{ secrets.DEV_AWS_ROLE }}
39+
aws-region: "us-east-1"
40+
41+
- name: Upload pg_upgrade scripts to s3 staging
42+
run: |
43+
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz
44+
45+
- name: configure aws credentials - prod
46+
uses: aws-actions/configure-aws-credentials@v1
47+
with:
48+
role-to-assume: ${{ secrets.PROD_AWS_ROLE }}
49+
aws-region: "us-east-1"
50+
51+
- name: Upload pg_upgrade scripts to s3 prod
52+
run: |
53+
aws s3 cp /tmp/pg_upgrade_scripts.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/pg_upgrade_scripts.tar.gz
54+
55+
- name: Slack Notification on Failure
56+
if: ${{ failure() }}
57+
uses: rtCamp/action-slack-notify@v2
58+
env:
59+
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }}
60+
SLACK_USERNAME: 'gha-failures-notifier'
61+
SLACK_COLOR: 'danger'
62+
SLACK_MESSAGE: 'Publishing pg_upgrade scripts failed'
63+
SLACK_FOOTER: ''

ansible/files/admin_api_scripts/pg_upgrade_check.sh renamed to ansible/files/admin_api_scripts/pg_upgrade_scripts/check.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/env bash
22
## This script provides a method to check the status of the database upgrade
3-
## process, which is updated in /tmp/pg-upgrade-status by pg_upgrade_initiate.sh
3+
## process, which is updated in /tmp/pg-upgrade-status by initiate.sh
44
## This runs on the old (source) instance.
55

66
set -euo pipefail

ansible/files/admin_api_scripts/pg_upgrade_common.sh renamed to ansible/files/admin_api_scripts/pg_upgrade_scripts/common.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/env bash
22

3-
# Common functions and variables used by pg_upgrade_initiate.sh and pg_upgrade_complete.sh
3+
# Common functions and variables used by initiate.sh and complete.sh
44

55
REPORTING_PROJECT_REF="ihmaxnjpcccasmrbkpvo"
66
REPORTING_CREDENTIALS_FILE="/root/upgrade-reporting-credentials"

ansible/files/admin_api_scripts/pg_upgrade_complete.sh renamed to ansible/files/admin_api_scripts/pg_upgrade_scripts/complete.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set -eEuo pipefail
99

1010
SCRIPT_DIR=$(dirname -- "$0";)
1111
# shellcheck disable=SC1091
12-
source "$SCRIPT_DIR/pg_upgrade_common.sh"
12+
source "$SCRIPT_DIR/common.sh"
1313

1414
LOG_FILE="/tmp/pg-upgrade-complete.log"
1515

ansible/files/admin_api_scripts/pg_upgrade_initiate.sh renamed to ansible/files/admin_api_scripts/pg_upgrade_scripts/initiate.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## of the newly launched instance, disabling extensions containing regtypes,
55
## and running pg_upgrade.
66
## It reports the current status of the upgrade process to /tmp/pg-upgrade-status,
7-
## which can then be subsequently checked through pg_upgrade_check.sh.
7+
## which can then be subsequently checked through check.sh.
88

99
# Extensions to disable before running pg_upgrade.
1010
# Running an upgrade with these extensions enabled will result in errors due to
@@ -29,7 +29,7 @@ set -eEuo pipefail
2929

3030
SCRIPT_DIR=$(dirname -- "$0";)
3131
# shellcheck disable=SC1091
32-
source "$SCRIPT_DIR/pg_upgrade_common.sh"
32+
source "$SCRIPT_DIR/common.sh"
3333

3434
LOG_FILE="/var/log/pg-upgrade-initiate.log"
3535

@@ -164,10 +164,10 @@ function initiate_upgrade {
164164
tar zxf "/tmp/persistent/pg_upgrade_bin.tar.gz" -C "/tmp/pg_upgrade_bin"
165165

166166
# copy upgrade-specific pgsodium_getkey script into the share dir
167-
chmod +x "/root/pg_upgrade_pgsodium_getkey.sh"
168-
cp /root/pg_upgrade_pgsodium_getkey.sh "$PGSHARENEW/extension/pgsodium_getkey"
167+
chmod +x "$SCRIPT_DIR/pgsodium_getkey.sh"
168+
cp "$SCRIPT_DIR/pgsodium_getkey.sh" "$PGSHARENEW/extension/pgsodium_getkey"
169169
if [ -d "/var/lib/postgresql/extension/" ]; then
170-
cp /root/pg_upgrade_pgsodium_getkey.sh "/var/lib/postgresql/extension/pgsodium_getkey"
170+
cp "$SCRIPT_DIR/pgsodium_getkey.sh" "/var/lib/postgresql/extension/pgsodium_getkey"
171171
chown postgres:postgres "/var/lib/postgresql/extension/pgsodium_getkey"
172172
fi
173173

ansible/tasks/internal/admin-api.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
loop:
1414
- { file: "grow_fs.sh" }
1515
- { file: "manage_readonly_mode.sh" }
16-
- { file: "pg_upgrade_check.sh" }
17-
- { file: "pg_upgrade_complete.sh" }
18-
- { file: "pg_upgrade_initiate.sh" }
19-
- { file: "pg_upgrade_prepare.sh" }
20-
- { file: "pg_upgrade_pgsodium_getkey.sh" }
2116
- { file: "pg_egress_collect.pl" }
2217

2318
- name: give adminapi user permissions
@@ -58,6 +53,20 @@
5853
owner: adminapi
5954
state: directory
6055

56+
- name: Move shell scripts to /etc/adminapi/pg_upgrade_scripts/
57+
copy:
58+
src: "files/admin_api_scripts/pg_upgrade_scripts/{{ item.file }}"
59+
dest: "/etc/adminapi/pg_upgrade_scripts/{{ item.file }}"
60+
mode: "0755"
61+
owner: adminapi
62+
loop:
63+
- { file: "check.sh" }
64+
- { file: "complete.sh" }
65+
- { file: "initiate.sh" }
66+
- { file: "prepare.sh" }
67+
- { file: "pgsodium_getkey.sh" }
68+
- { file: "common.sh" }
69+
6170
- name: adminapi - create service file
6271
template:
6372
src: files/adminapi.service.j2

ansible/vars.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ postgres_exporter_release_checksum:
4141
arm64: sha256:d869c16791481dc8475487ad84ae4371a63f9b399898ca1c666eead5cccf7182
4242
amd64: sha256:ff541bd3ee19c0ae003d71424a75edfcc8695e828dd20d5b4555ce433c89d60b
4343

44-
adminapi_release: 0.45.1
44+
adminapi_release: 0.46.0
4545
adminmgr_release: 0.5.0
4646

4747
# Postgres Extensions

common.vars.pkr.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
postgres-version = "15.1.0.99"
1+
postgres-version = "15.1.0.100"

docker/all-in-one/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ARG pgbouncer_release=1.18.0
44
ARG postgrest_release=10.1.2
55
ARG gotrue_release=2.47.0
66
ARG kong_release=2.8.1
7-
ARG adminapi_release=0.45.1
7+
ARG adminapi_release=0.46.0
88
ARG adminmgr_release=0.5.0
99
ARG vector_release=0.22.3
1010
ARG postgres_exporter_release=0.9.0

0 commit comments

Comments
 (0)