Skip to content

Conversation

@nmarukovich
Copy link
Contributor

@nmarukovich nmarukovich commented Nov 6, 2025

K8SPXC-1431 Powered by Pull Request Badge

CHANGE DESCRIPTION

Problem:
Short explanation of the problem.
Previously, the behavior was the following: when we created a backup using fs-pvc storage and then deleted that backup, the PVC was also deleted. Because of that, the finalizer never actually worked.

This PR fixes that issue.

Cause:
pvc had ownerReference and was deleted with backup object.

Solution:

  • delete owner reference, finalizer works as expected now
  • to avoid reusing the same pvc for demand backup unintentionally, now we create unique pvc name for backup
    xb-backup1-20251125210833-f12d3deb instead of xb-backup1
  • in backup status the part about pvc settings was added.
status:
    completed: "2025-11-25T21:09:47Z"
    destination: pvc/xb-backup1-20251125210833-f12d3deb
    image: perconalab/percona-xtradb-cluster-operator:main-pxc8.0-backup
    pvc:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 1Gi
      storageClassName: standard-rwo
      volumeMode: Filesystem
      volumeName: pvc-48ffa1c3-4319-4b41-a17c-7cf7ed483497

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PXC version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size bot added the size/L 100-499 lines label Nov 6, 2025
Comment on lines +11 to +12
local backup_name="$1"
local finalizer_flag="off"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
local backup_name="$1"
local finalizer_flag="off"
local backup_name="$1"
local finalizer_flag="off"

Comment on lines +14 to +18
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
echo "Finalizer is $finalizer_flag"
echo "Finalizer is $finalizer_flag"

Comment on lines +22 to +23
echo "Looking for PVCs containing '$backup_name'"
pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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")

Comment on lines +30 to +31
echo "Deleting backup $backup_name ..."
kubectl delete pxc-backup "$backup_name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
echo "Deleting backup $backup_name ..."
kubectl delete pxc-backup "$backup_name"
echo "Deleting backup $backup_name ..."
kubectl delete pxc-backup "$backup_name"

echo "Deleting backup $backup_name ..."
kubectl delete pxc-backup "$backup_name"

sleep 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
sleep 5
sleep 5

Comment on lines +52 to +55
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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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"

@nmarukovich nmarukovich marked this pull request as ready for review November 13, 2025 08:17
case naming.FinalizerDeleteBackup:
if (cr.Status.S3 == nil && cr.Status.Azure == nil) || cr.Status.Destination == "" {
storageType := cr.Status.GetStorageType(nil)
if (cr.Status.S3 == nil && cr.Status.Azure == nil && storageType != api.BackupStorageFilesystem) || cr.Status.Destination == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't we agree on adding cr.Status.Filesystem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we didn't. I was confused what variables should we put in this structure. Let's decide here and I will fix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. what confused you? what needs to be decided?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for example for azure and aws in this structure we have

type BackupStorageAzureSpec struct {
	CredentialsSecret string `json:"credentialsSecret"`
	ContainerPath     string `json:"container"`
	Endpoint          string `json:"endpointUrl"`
	StorageClass      string `json:"storageClass"`
	BlockSize         int64  `json:"blockSize"`
	Concurrency       int    `json:"concurrency"`
}

type BackupStorageS3Spec struct {
	Bucket            string `json:"bucket"`
	CredentialsSecret string `json:"credentialsSecret"`
	Region            string `json:"region,omitempty"`
	EndpointURL       string `json:"endpointUrl,omitempty"`
}

So in this case, what would be reasonable to add to the same structure for the fs-pvc?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can put the PVC spec into status. Also the PVC name would be nice to add.

Comment on lines +21 to +31
base := naming.BackupJobName(cr.Name, false)

ts := cr.CreationTimestamp.UTC().Format("20060102150405")

uidSuffix := strings.ToLower(string(cr.UID))
if len(uidSuffix) > 8 {
uidSuffix = uidSuffix[:8]
}

// Final name: xb-<name>-<YYYYMMDDhhmmss>-<uidsfx>
name := fmt.Sprintf("%s-%s-%s", base, ts, uidSuffix)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason behind this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s a good question.

Previously, the behavior was the following: when we created a backup using fs-pvc storage and then deleted that backup, the PVC was also deleted. Because of that, the finalizer never actually worked.

This PR fixes that issue.

Now the finalizer works correctly, and a new situation becomes possible:

The user turns off the finalizer, creates a backup, and later deletes it.

In this case, the backup object is deleted, but the PVC remains.

Later, the user decides to create another backup with the same name.

Since the old PVC still exists, the operator will reuse that same PVC to store the new backup data.

I think in this case it would be better to generate a unique PVC name to avoid reusing storage unintentionally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Since these PVC names are not immediately predictable for users any more, please add PVC name into backup status.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have destinatination in backup status destination: pvc/xb-on-demand-backup-pvc, but the new part with values was also added:

fsPvc:
   accessModes:
   - ReadWriteOnce
   resources:
     requests:
       storage: 1Gi
   storageClassName: standard-rwo
   volumeMode: Filesystem
   volumeName: pvc-d1c2fec7-118f-4608-becc-9dd61c198d26

Copy link
Contributor

@eleo007 eleo007 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add description to this PR.

kubectl delete pxc-backup "$backup_name"

sleep 5

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to update the $pvc after deleting backup. Otherwise its value stays before deletion and the test does not actually check correct state.

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'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extend error output to be more descriptive. Maybe smth like: echo "No PVCs found with substring '$backup_name' before the backup deletion. Smth wrong with backup"?

Comment on lines 37 to 42
if [[ -z "$pvc" && "$finalizer_flag" == "off" ]]; then
echo "Error: No PVCs found with substring '$backup_name'. PVC was deleted even if finalizer is turned off"
exit 1
fi

if [[ -z "$pvc" && "$finalizer_flag" == "on" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be better to use if .. elif .. else in this check not to miss unexpected combinations.

Copy link
Collaborator

@hors hors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmarukovich, please add a description for this PR. We can't review it without all the needed information.

Copy link
Contributor

@egegunes egegunes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmarukovich please add more description to your PR. what was the problem? how did you fix it? are there any side effects of your change? for example we are changing the PVC names for backups but it's not even mentioned in description.

…percona-xtradb-cluster-operator into K8SPXC-1431_pvc_backup_deletion
Comment on lines +25 to +28
if [[ -z "$pvc" ]]; then
echo "No PVCs found with substring '$backup_name' before the backup deletion. Something wrong with backup"
return 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
if [[ -z "$pvc" ]]; then
echo "No PVCs found with substring '$backup_name' before the backup deletion. Something wrong with backup"
return 1
fi
if [[ -z $pvc ]]; then
echo "No PVCs found with substring '$backup_name' before the backup deletion. Something wrong with backup"
return 1
fi


sleep 5

pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name" || true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name" || true)
pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name" || true)


pvc=$(kubectl get pvc --no-headers -o custom-columns=":metadata.name" | grep "$backup_name" || true)

echo "Checking PVC $pvc existence and finalizers"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
echo "Checking PVC $pvc existence and finalizers"
echo "Checking PVC $pvc existence and finalizers"

Comment on lines +39 to +41
if [[ -z "$pvc" && "$finalizer_flag" == "off" ]]; then
echo "Error: No PVCs found with substring '$backup_name'. PVC was deleted even though finalizer is OFF."
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
if [[ -z "$pvc" && "$finalizer_flag" == "off" ]]; then
echo "Error: No PVCs found with substring '$backup_name'. PVC was deleted even though finalizer is OFF."
exit 1
if [[ -z $pvc && $finalizer_flag == "off" ]]; then
echo "Error: No PVCs found with substring '$backup_name'. PVC was deleted even though finalizer is OFF."
exit 1

Comment on lines +43 to +44
elif [[ -z "$pvc" && "$finalizer_flag" == "on" ]]; then
echo "Correct: No PVCs found with substring '$backup_name' because finalizer is ON and PVC was deleted."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
elif [[ -z "$pvc" && "$finalizer_flag" == "on" ]]; then
echo "Correct: No PVCs found with substring '$backup_name' because finalizer is ON and PVC was deleted."
elif [[ -z $pvc && $finalizer_flag == "on" ]]; then
echo "Correct: No PVCs found with substring '$backup_name' because finalizer is ON and PVC was deleted."

Comment on lines +46 to +48
elif [[ -n "$pvc" && "$finalizer_flag" == "on" ]]; then
echo "Error: PVC exists: $pvc (finalizer_flag=$finalizer_flag). Finalizer should delete PVC but did NOT."
exit 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
elif [[ -n "$pvc" && "$finalizer_flag" == "on" ]]; then
echo "Error: PVC exists: $pvc (finalizer_flag=$finalizer_flag). Finalizer should delete PVC but did NOT."
exit 1
elif [[ -n $pvc && $finalizer_flag == "on" ]]; then
echo "Error: PVC exists: $pvc (finalizer_flag=$finalizer_flag). Finalizer should delete PVC but did NOT."
exit 1

Comment on lines +50 to +52
else
echo "PVC exists: $pvc (finalizer_flag=$finalizer_flag)"
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
else
echo "PVC exists: $pvc (finalizer_flag=$finalizer_flag)"
fi
else
echo "PVC exists: $pvc (finalizer_flag=$finalizer_flag)"
fi

check_finalizer_for_fs "on-demand-backup-pvc"

run_backup "$cluster" "on-demand-backup-pvc-with-finalizer"
check_finalizer_for_fs "on-demand-backup-pvc-with-finalizer"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
check_finalizer_for_fs "on-demand-backup-pvc-with-finalizer"
check_finalizer_for_fs "on-demand-backup-pvc-with-finalizer"

Comment on lines +21 to +31
base := naming.BackupJobName(cr.Name, false)

ts := cr.CreationTimestamp.UTC().Format("20060102150405")

uidSuffix := strings.ToLower(string(cr.UID))
if len(uidSuffix) > 8 {
uidSuffix = uidSuffix[:8]
}

// Final name: xb-<name>-<YYYYMMDDhhmmss>-<uidsfx>
name := fmt.Sprintf("%s-%s-%s", base, ts, uidSuffix)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Since these PVC names are not immediately predictable for users any more, please add PVC name into backup status.

@pull-request-size pull-request-size bot added size/XXL 1000+ lines and removed size/L 100-499 lines labels Nov 25, 2025
StorageName string `json:"storageName,omitempty"`
S3 *BackupStorageS3Spec `json:"s3,omitempty"`
Azure *BackupStorageAzureSpec `json:"azure,omitempty"`
FsPvc *corev1.PersistentVolumeClaimSpec `json:"fsPvc,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to name it just pvc

@nmarukovich nmarukovich requested a review from hors November 25, 2025 21:20
@nmarukovich nmarukovich requested a review from egegunes November 25, 2025 21:20
S3 *BackupStorageS3Spec `json:"s3,omitempty"`
Azure *BackupStorageAzureSpec `json:"azure,omitempty"`
FsPvc *corev1.PersistentVolumeClaimSpec `json:"fsPvc,omitempty"`
Pvc *corev1.PersistentVolumeClaimSpec `json:"pvc,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

acronyms should be all upper case

https://go.dev/wiki/CodeReviewComments#initialisms

@nmarukovich nmarukovich requested a review from egegunes November 26, 2025 08:34
Comment on lines +914 to +929
local input_file="$1"
local pvc_name="$2"

cat "$input_file" \
| $sed -e "s#apiVersion: pxc.percona.com/v.*\$#apiVersion: $API#" \
| $sed -e "s#image:.*-pxc\([0-9]*.[0-9]*\)\{0,1\}\$#image: $IMAGE_PXC#" \
| $sed -e "s#image:.*\/percona-xtradb-cluster:.*\$#image: $IMAGE_PXC#" \
| $sed -e "s#image:.*-init\$#image: $IMAGE#" \
| $sed -e "s#image:.*-pmm\$#image: $IMAGE_PMM_CLIENT#" \
| $sed -e "s#image:.*-backup\$#image: $IMAGE_BACKUP#" \
| $sed -e "s#image:.*-proxysql\$#image: $IMAGE_PROXY#" \
| $sed -e "s#image:.*-haproxy\$#image: $IMAGE_HAPROXY#" \
| $sed -e "s#image:.*-logcollector\$#image: $IMAGE_LOGCOLLECTOR#" \
| $sed -e "s~minio-service.#namespace~minio-service.$namespace~" \
| $sed -e "s#apply:.*#apply: Never#" \
| $sed -e "s#claimName:..*-backup-pvc\$#claimName: $pvc_name#" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
local input_file="$1"
local pvc_name="$2"
cat "$input_file" \
| $sed -e "s#apiVersion: pxc.percona.com/v.*\$#apiVersion: $API#" \
| $sed -e "s#image:.*-pxc\([0-9]*.[0-9]*\)\{0,1\}\$#image: $IMAGE_PXC#" \
| $sed -e "s#image:.*\/percona-xtradb-cluster:.*\$#image: $IMAGE_PXC#" \
| $sed -e "s#image:.*-init\$#image: $IMAGE#" \
| $sed -e "s#image:.*-pmm\$#image: $IMAGE_PMM_CLIENT#" \
| $sed -e "s#image:.*-backup\$#image: $IMAGE_BACKUP#" \
| $sed -e "s#image:.*-proxysql\$#image: $IMAGE_PROXY#" \
| $sed -e "s#image:.*-haproxy\$#image: $IMAGE_HAPROXY#" \
| $sed -e "s#image:.*-logcollector\$#image: $IMAGE_LOGCOLLECTOR#" \
| $sed -e "s~minio-service.#namespace~minio-service.$namespace~" \
| $sed -e "s#apply:.*#apply: Never#" \
| $sed -e "s#claimName:..*-backup-pvc\$#claimName: $pvc_name#" \
local input_file="$1"
local pvc_name="$2"
cat "$input_file" \
| $sed -e "s#apiVersion: pxc.percona.com/v.*\$#apiVersion: $API#" \
| $sed -e "s#image:.*-pxc\([0-9]*.[0-9]*\)\{0,1\}\$#image: $IMAGE_PXC#" \
| $sed -e "s#image:.*\/percona-xtradb-cluster:.*\$#image: $IMAGE_PXC#" \
| $sed -e "s#image:.*-init\$#image: $IMAGE#" \
| $sed -e "s#image:.*-pmm\$#image: $IMAGE_PMM_CLIENT#" \
| $sed -e "s#image:.*-backup\$#image: $IMAGE_BACKUP#" \
| $sed -e "s#image:.*-proxysql\$#image: $IMAGE_PROXY#" \
| $sed -e "s#image:.*-haproxy\$#image: $IMAGE_HAPROXY#" \
| $sed -e "s#image:.*-logcollector\$#image: $IMAGE_LOGCOLLECTOR#" \
| $sed -e "s~minio-service.#namespace~minio-service.$namespace~" \
| $sed -e "s#apply:.*#apply: Never#" \
| $sed -e "s#claimName:..*-backup-pvc\$#claimName: $pvc_name#"

Comment on lines +946 to +947
local config_file="$1"
local pvc_name="${2:-}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
local config_file="$1"
local pvc_name="${2:-}"
local config_file="$1"
local pvc_name="${2:-}"

| kubectl_bin apply -f -
else
cat_config "$1" \
cat_config "$config_file" "$pvc_name"\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
cat_config "$config_file" "$pvc_name"\
cat_config "$config_file" "$pvc_name" \

apply_config "$pxcClientFile"
if [[ $IMAGE_PXC =~ 5\.7 ]] && [[ $cluster == 'demand-backup' || $cluster == 'demand-backup-cloud' ]]; then
cat_config "$config" \
cat_config "$config"\
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
cat_config "$config"\
cat_config "$config" \

}

check_pvc_md5() {
local backup_name="$1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
local backup_name="$1"
local backup_name="$1"

}

get_pvc_name_for_backup() {
local backup_name="$1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
local backup_name="$1"
local backup_name="$1"

Comment on lines +2036 to +2041
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/}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
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/}"

fi
local pvc_name="${destination#pvc/}"

echo "$pvc_name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change
echo "$pvc_name"
echo "$pvc_name"


echo "$pvc_name"
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[shfmt] reported by reviewdog 🐶

Suggested change

…percona-xtradb-cluster-operator into K8SPXC-1431_pvc_backup_deletion
egegunes
egegunes previously approved these changes Nov 26, 2025
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we have PVC name in the backup status, maybe it is better to use it to check that the PVC exists/not exists further?

@JNKPercona
Copy link
Collaborator

Test Name Result Time
auto-tuning-8-0 passed 00:19:12
allocator-8-0 passed 00:12:28
backup-storage-tls-8-0 passed 00:23:04
cross-site-8-0 passed 00:34:49
custom-users-8-0 passed 00:12:44
demand-backup-cloud-8-0 passed 00:57:11
demand-backup-encrypted-with-tls-8-0 passed 00:45:11
demand-backup-8-0 passed 00:42:44
demand-backup-flow-control-8-0 passed 00:11:10
demand-backup-parallel-8-0 passed 00:09:08
demand-backup-without-passwords-8-0 passed 00:15:55
haproxy-5-7 passed 00:15:07
haproxy-8-0 passed 00:15:06
init-deploy-5-7 passed 00:16:33
init-deploy-8-0 passed 00:17:00
limits-8-0 passed 00:12:32
monitoring-2-0-8-0 passed 00:23:01
monitoring-pmm3-8-0 passed 00:17:53
one-pod-5-7 passed 00:14:19
one-pod-8-0 passed 00:13:51
pitr-8-0 passed 00:43:46
pitr-gap-errors-8-0 passed 00:56:54
proxy-protocol-8-0 passed 00:09:27
proxy-switch-8-0 passed 00:14:00
proxysql-sidecar-res-limits-8-0 passed 00:08:38
proxysql-scheduler-8-0 passed 00:16:21
pvc-resize-5-7 passed 00:17:16
pvc-resize-8-0 passed 00:17:50
recreate-8-0 passed 00:17:41
restore-to-encrypted-cluster-8-0 passed 00:26:06
scaling-proxysql-8-0 passed 00:08:31
scaling-8-0 passed 00:10:51
scheduled-backup-5-7 passed 01:04:17
scheduled-backup-8-0 passed 01:03:37
security-context-8-0 passed 00:28:05
smart-update1-8-0 passed 00:32:27
smart-update2-8-0 passed 00:38:05
storage-8-0 passed 00:10:42
tls-issue-cert-manager-ref-8-0 passed 00:08:50
tls-issue-cert-manager-8-0 passed 00:10:01
tls-issue-self-8-0 passed 00:13:32
upgrade-consistency-8-0 passed 00:11:14
upgrade-haproxy-5-7 passed 00:24:37
upgrade-haproxy-8-0 passed 00:25:00
upgrade-proxysql-5-7 passed 00:14:43
upgrade-proxysql-8-0 passed 00:14:42
users-5-7 passed 00:24:25
users-8-0 passed 00:25:00
validation-hook-8-0 passed 00:01:59
Summary Value
Tests Run 49/49
Job Duration 03:01:03
Total Test Time 18:07:59

commit: 31b0cef
image: perconalab/percona-xtradb-cluster-operator:PR-2232-31b0cef6

@hors hors merged commit c706225 into main Nov 28, 2025
10 of 12 checks passed
@hors hors deleted the K8SPXC-1431_pvc_backup_deletion branch November 28, 2025 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL 1000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants