-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use force-conflicts instead of overwrite
- Loading branch information
Anthony Landreth
committed
Oct 26, 2023
1 parent
f7c4e7b
commit 3f35acf
Showing
8 changed files
with
141 additions
and
30 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
testing/kuttl/e2e/backup/12--backup-with-force-conflicts.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
# The cluster should not have changed. | ||
apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
kind: PostgresCluster | ||
metadata: | ||
name: backup-cluster | ||
spec: | ||
backups: | ||
pgbackrest: | ||
manual: | ||
options: | ||
- --type=full | ||
repoName: repo4 | ||
|
||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
pgbackrest_backup_annotation() { | ||
kubectl get --namespace "${NAMESPACE}" postgrescluster/backup-cluster \ | ||
--output 'go-template={{ index .metadata.annotations "postgres-operator.crunchydata.com/pgbackrest-backup" }}' | ||
} | ||
kubectl --namespace "${NAMESPACE}" annotate postgrescluster/backup-cluster \ | ||
postgres-operator.crunchydata.com/pgbackrest-backup="$(date)" --overwrite || exit | ||
PRIOR=$(pgbackrest_backup_annotation) | ||
RESULT=$(kubectl-pgo --namespace "${NAMESPACE}" backup backup-cluster --force-conflicts) | ||
CURRENT=$(pgbackrest_backup_annotation) | ||
if [ "${CURRENT}" = "${PRIOR}" ]; then | ||
printf 'Expected annotation to change, got %q' "${CURRENT}" | ||
exit 1 | ||
fi | ||
echo "RESULT from taking backup: ${RESULT}" | ||
if [[ -n $RESULT && "$RESULT" == "postgresclusters/backup-cluster backup initiated" ]]; then | ||
exit 0 | ||
fi | ||
exit 1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
apiVersion: postgres-operator.crunchydata.com/v1beta1 | ||
kind: PostgresCluster | ||
metadata: | ||
name: restore-cluster | ||
spec: | ||
postgresVersion: 14 | ||
instances: | ||
- name: instance1 | ||
dataVolumeClaimSpec: | ||
accessModes: [ReadWriteOnce] | ||
resources: { requests: { storage: 1Gi } } | ||
backups: | ||
pgbackrest: | ||
repos: | ||
- name: repo2 | ||
volume: | ||
volumeClaimSpec: | ||
accessModes: [ReadWriteOnce] | ||
resources: { requests: { storage: 1Gi } } | ||
restore: | ||
enabled: true | ||
repoName: repo2 | ||
options: | ||
- --db-include=restore-cluster | ||
|
||
--- | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- script: | | ||
pgbackrest_restore_annotation() { | ||
kubectl --namespace "${NAMESPACE}" get postgrescluster/restore-cluster \ | ||
--output "jsonpath-as-json={.metadata.annotations['postgres-operator\.crunchydata\.com/pgbackrest-restore']}" | ||
} | ||
kubectl --namespace "${NAMESPACE}" annotate postgrescluster/restore-cluster \ | ||
postgres-operator.crunchydata.com/pgbackrest-restore="$(date)" --overwrite || exit | ||
PRIOR=$(pgbackrest_restore_annotation) | ||
# Running restore will update the annotation. | ||
echo yes | kubectl-pgo --namespace="${NAMESPACE}" restore restore-cluster --options="--db-include=restore-cluster" --repoName="repo2" --force-conflicts | ||
CURRENT=$(pgbackrest_restore_annotation) | ||
if [ "${CURRENT}" != "${PRIOR}" ]; then | ||
exit 0 | ||
fi | ||
printf 'Expected annotation to change, got PRIOR %q CURRENT %q' "${PRIOR}" "${CURRENT}" | ||
echo "RESULT from taking restore: ${RESULT}" | ||
exit 1 |