-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds an overwrite flag to force annotation updates #70
Merged
tony-landreth
merged 5 commits into
CrunchyData:main
from
tony-landreth:add-overwrite-to-backup
Oct 27, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
--- | ||
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 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,27 @@ | ||
--- | ||
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not your change, but can you look at line 40 -- I don't like that it uses the word "overwrite" when that's not what we do unless you use the overwrite flag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the new text work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's ~3 cases here that we (maybe) want to cover:
a) take a backup with the settings already in the spec
b) take a backup with new settings that you write to the spec
c) take a backup with new settings that you write to the spec -- even if someone else owns those settings.
Maybe something like (but better than):
(I don't think we actually want parentheses in our docs. Maybe we just want to say "you can take backups with the settings that are there or write those settings" and mention the overwrite situation in the flag description? No, I think people will run into that, we probably want to bring it up in this summary.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this?