Skip to content

Commit

Permalink
🐛 Fix migration helm jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
georgepstaylor committed Aug 27, 2024
1 parent 3b367f6 commit 3a884cc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
17 changes: 13 additions & 4 deletions jobs/migrate-db/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ data:
set -e
echo "${SRC_DB_HOST}:5432:${SRC_DB_NAME}:${SRC_DB_USER}:${SRC_DB_PASS}" > ~/.pgpass
echo "${DST_DB_HOST}:5432:${DST_DB_NAME}:${DST_DB_USER}:${DST_DB_PASS}" >> ~/.pgpass
cat ~/.pgpass
chmod 0600 ~/.pgpass
chown job:job ~/.pgpass
set -x
pg_dump --jobs=4 --host="$SRC_DB_HOST" --username="$SRC_DB_USER" --dbname="$SRC_DB_NAME" --no-owner --no-privileges --verbose --format=directory --file=/tmp/db-dump
pg_restore --jobs=4 --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" --clean --if-exists --no-owner --no-privileges --verbose /tmp/db-dump
rm -rv /tmp/db-dump ~/.pgpass
# Dump the source database
pg_dump --jobs=4 --host="$SRC_DB_HOST" --username="$SRC_DB_USER" --dbname="$SRC_DB_NAME" --no-owner --no-privileges --verbose --format=directory --file=/home/job/db-dump
psql --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" -c "drop schema if exists public cascade;"
psql --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" -c "create schema public;"
# Restore the source database dump to the destination database
pg_restore --jobs=4 --host="$DST_DB_HOST" --username="$DST_DB_USER" --dbname="$DST_DB_NAME" --no-owner --no-privileges --verbose /home/job/db-dump
rm -rv /home/job/db-dump ~/.pgpass
---
apiVersion: batch/v1
kind: Job
Expand All @@ -25,7 +34,7 @@ spec:
spec:
containers:
- name: migrate-db
image: postgres:14
image: ghcr.io/ministryofjustice/hmpps-delius-alfresco-db-utils:latest
imagePullPolicy: IfNotPresent
resources:
limits:
Expand Down
8 changes: 4 additions & 4 deletions jobs/migrate-s3/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ data:
set -xe
aws configure set default.s3.max_concurrent_requests 2000
aws configure set default.s3.use_accelerate_endpoint true
# aws configure set default.s3.use_accelerate_endpoint true
aws s3 sync s3://$SRC_BUCKET/$DIR s3://$DST_BUCKET/$DIR --delete --only-show-errors
aws s3 sync s3://$SRC_BUCKET/$DIR s3://$DST_BUCKET/$DIR --delete --only-show-errors --region eu-west-2
echo sync of $DIR directory completed
{{- range .Values.dirs }}
Expand All @@ -29,8 +29,8 @@ spec:
imagePullPolicy: IfNotPresent
resources:
limits:
cpu: 4
memory: 8Gi
cpu: 1
memory: 1Gi
command:
- /bin/entrypoint.sh
env:
Expand Down
2 changes: 1 addition & 1 deletion jobs/refresh-db/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
spec:
containers:
- name: refresh-db
image: ghcr.io/ministryofjustice/hmpps-delius-alfresco-db-utils:NIT-1403-alfresco-move-away-from-long-running-github-workflows-10114657186
image: ghcr.io/ministryofjustice/hmpps-delius-alfresco-db-utils:latest
imagePullPolicy: IfNotPresent
resources:
limits:
Expand Down
Empty file removed test.yml
Empty file.

0 comments on commit 3a884cc

Please sign in to comment.