Skip to content

Commit f3ddbcb

Browse files
Add PostgreSQL readiness checks before exec commands
1 parent bb73927 commit f3ddbcb

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

testing/chainsaw/e2e/pgbackrest-restore/templates/change-parameters.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ spec:
2626
postgres-operator.crunchydata.com/cluster=original,
2727
postgres-operator.crunchydata.com/role=master
2828
29+
-
30+
description: >
31+
Wait for PostgreSQL to be ready
32+
script:
33+
skipCommandOutput: true
34+
timeout: 2m
35+
env:
36+
- name: PRIMARY
37+
value: ($primary)
38+
content: |
39+
until kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
40+
-- psql -qAt --command 'SELECT 1' 2>/dev/null; do
41+
sleep 1
42+
done
43+
2944
-
3045
description: >
3146
Read the timestamp at which PostgreSQL last started

testing/chainsaw/e2e/pgbackrest-restore/templates/lose-data.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ spec:
3131
- name: PRIMARY
3232
value: ($primary)
3333
content: |
34+
# Wait for PostgreSQL to be ready
35+
until kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
36+
-- psql -qAt --command 'SELECT 1' 2>/dev/null; do
37+
sleep 1
38+
done
39+
3440
OBJECTIVE=$(
3541
kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
3642
-- psql -qAt --command 'SELECT clock_timestamp()'

testing/chainsaw/e2e/pgbackrest-restore/templates/verify-backup.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ spec:
1717
postgres-operator.crunchydata.com/role=master'
1818
)
1919
20+
# Wait for PostgreSQL to be ready
21+
until kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
22+
-- psql -qAt --command 'SELECT 1' 2>/dev/null; do
23+
sleep 1
24+
done
25+
2026
kubectl exec --namespace "${NAMESPACE}" "${PRIMARY}" \
2127
-- psql --command 'SELECT pg_switch_wal()' --pset footer=off
2228

0 commit comments

Comments
 (0)