-
Notifications
You must be signed in to change notification settings - Fork 203
K8SPXC-1431 fix pvc deletion with finalizer #2232
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
base: main
Are you sure you want to change the base?
Conversation
| local backup_name="$1" | ||
| local finalizer_flag="off" |
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.
[shfmt] reported by reviewdog 🐶
| local backup_name="$1" | |
| local finalizer_flag="off" | |
| local backup_name="$1" | |
| local finalizer_flag="off" |
| desc "Checking finalizers on backup $backup_name" | ||
| # Check if pxc-backup has the finalizer "percona.com/delete-backup" | ||
| if kubectl get pxc-backup "$backup_name" -o jsonpath='{.metadata.finalizers}' | grep -q "percona.com/delete-backup"; then | ||
| finalizer_flag="on" | ||
| fi |
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.
[shfmt] reported by reviewdog 🐶
| desc "Checking finalizers on backup $backup_name" | |
| # Check if pxc-backup has the finalizer "percona.com/delete-backup" | |
| if kubectl get pxc-backup "$backup_name" -o jsonpath='{.metadata.finalizers}' | grep -q "percona.com/delete-backup"; then | |
| finalizer_flag="on" | |
| fi | |
| desc "Checking finalizers on backup $backup_name" | |
| # Check if pxc-backup has the finalizer "percona.com/delete-backup" | |
| if kubectl get pxc-backup "$backup_name" -o jsonpath='{.metadata.finalizers}' | grep -q "percona.com/delete-backup"; then | |
| finalizer_flag="on" | |
| fi |
| finalizer_flag="on" | ||
| fi | ||
|
|
||
| echo "Finalizer is $finalizer_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.
[shfmt] reported by reviewdog 🐶
| echo "Finalizer is $finalizer_flag" | |
| echo "Finalizer is $finalizer_flag" |
| echo "Looking for PVCs containing '$backup_name'" | ||
| pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name") |
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.
[shfmt] reported by reviewdog 🐶
| echo "Looking for PVCs containing '$backup_name'" | |
| pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name") | |
| echo "Looking for PVCs containing '$backup_name'" | |
| pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name") |
| if [[ -z "$pvc" ]]; then | ||
| echo "No PVCs found with substring '$backup_name'" | ||
| return 1 | ||
| fi |
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.
[shfmt] reported by reviewdog 🐶
| if [[ -z "$pvc" ]]; then | |
| echo "No PVCs found with substring '$backup_name'" | |
| return 1 | |
| fi | |
| if [[ -z $pvc ]]; then | |
| echo "No PVCs found with substring '$backup_name'" | |
| return 1 | |
| fi |
| apply_config "$pxcClientFile" | ||
| if [[ $IMAGE_PXC =~ 5\.7 ]] && [[ $cluster == 'demand-backup' || $cluster == 'demand-backup-cloud' ]]; then | ||
| cat_config "$config" \ | ||
| cat_config "$config"\ |
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.
[shfmt] reported by reviewdog 🐶
| cat_config "$config"\ | |
| cat_config "$config" \ |
| } | ||
|
|
||
| check_pvc_md5() { | ||
| local backup_name="$1" |
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.
[shfmt] reported by reviewdog 🐶
| local backup_name="$1" | |
| local backup_name="$1" |
| } | ||
|
|
||
| get_pvc_name_for_backup() { | ||
| local backup_name="$1" |
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.
[shfmt] reported by reviewdog 🐶
| local backup_name="$1" | |
| local backup_name="$1" |
| fi | ||
| local pvc_name="${destination#pvc/}" | ||
|
|
||
| echo "$pvc_name" |
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.
[shfmt] reported by reviewdog 🐶
| echo "$pvc_name" | |
| echo "$pvc_name" |
|
|
||
| echo "$pvc_name" | ||
| } | ||
|
|
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.
[shfmt] reported by reviewdog 🐶
| local destination=$(kubectl_bin get pxc-backup "$backup_name" -o jsonpath='{.status.destination}') | ||
| if [[ -z "$destination" ]]; then | ||
| echo "No destination found in backup $backup_name" | ||
| return 1 | ||
| fi | ||
| local pvc_name="${destination#pvc/}" |
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.
[shfmt] reported by reviewdog 🐶
| local destination=$(kubectl_bin get pxc-backup "$backup_name" -o jsonpath='{.status.destination}') | |
| if [[ -z "$destination" ]]; then | |
| echo "No destination found in backup $backup_name" | |
| return 1 | |
| fi | |
| local pvc_name="${destination#pvc/}" | |
| local destination=$(kubectl_bin get pxc-backup "$backup_name" -o jsonpath='{.status.destination}') | |
| if [[ -z $destination ]]; then | |
| echo "No destination found in backup $backup_name" | |
| return 1 | |
| fi | |
| local pvc_name="${destination#pvc/}" |
| cat "$file" \ | ||
| | $sed -E "s#(claimName: xb-on-demand-backup-pvc)(-[0-9]{14}-[a-f0-9]{8})?#claimName: $pvc_name#" \ | ||
| > "${file}.patched" | ||
| mv "${file}.patched" "$file" |
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.
[shfmt] reported by reviewdog 🐶
| cat "$file" \ | |
| | $sed -E "s#(claimName: xb-on-demand-backup-pvc)(-[0-9]{14}-[a-f0-9]{8})?#claimName: $pvc_name#" \ | |
| > "${file}.patched" | |
| mv "${file}.patched" "$file" | |
| cat "$file" \ | |
| | $sed -E "s#(claimName: xb-on-demand-backup-pvc)(-[0-9]{14}-[a-f0-9]{8})?#claimName: $pvc_name#" \ | |
| >"${file}.patched" | |
| mv "${file}.patched" "$file" |
commit: b6dbce1 |
CHANGE DESCRIPTION
Problem:
Short explanation of the problem.
Cause:
Short explanation of the root cause of the issue if applicable.
Solution:
Short explanation of the solution we are providing with this PR.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability