Skip to content
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

K8SPXC-1366: Backup improvements #1946

Merged
merged 3 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ spec:
type: object
pxcCluster:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storageName:
type: string
type: object
Expand Down Expand Up @@ -203,6 +206,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -275,6 +277,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ spec:
type: array
serviceAccountName:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storages:
additionalProperties:
properties:
Expand Down
1 change: 1 addition & 0 deletions deploy/backup/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ spec:
pxcCluster: cluster1
storageName: fs-pvc
# activeDeadlineSeconds: 3600
# startingDeadlineSeconds: 300
# containerOptions:
# env:
# - name: VERIFY_TLS
Expand Down
12 changes: 12 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ spec:
type: object
pxcCluster:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storageName:
type: string
type: object
Expand Down Expand Up @@ -202,6 +205,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -344,6 +349,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -518,6 +525,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -1048,6 +1057,9 @@ spec:
type: array
serviceAccountName:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storages:
additionalProperties:
properties:
Expand Down
1 change: 1 addition & 0 deletions deploy/cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ spec:
image: perconalab/percona-xtradb-cluster-operator:main-pxc8.0-backup
# backoffLimit: 6
# activeDeadlineSeconds: 3600
# startingDeadlineSeconds: 300
# serviceAccountName: percona-xtradb-cluster-operator
# imagePullSecrets:
# - name: private-registry-credentials
Expand Down
12 changes: 12 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ spec:
type: object
pxcCluster:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storageName:
type: string
type: object
Expand Down Expand Up @@ -202,6 +205,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -344,6 +349,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -518,6 +525,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -1048,6 +1057,9 @@ spec:
type: array
serviceAccountName:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storages:
additionalProperties:
properties:
Expand Down
12 changes: 12 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ spec:
type: object
pxcCluster:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storageName:
type: string
type: object
Expand Down Expand Up @@ -202,6 +205,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -344,6 +349,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -518,6 +525,8 @@ spec:
type: array
destination:
type: string
error:
type: string
image:
type: string
lastscheduled:
Expand Down Expand Up @@ -1048,6 +1057,9 @@ spec:
type: array
serviceAccountName:
type: string
startingDeadlineSeconds:
format: int64
type: integer
storages:
additionalProperties:
properties:
Expand Down
7 changes: 7 additions & 0 deletions e2e-tests/demand-backup-parallel/conf/backup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBClusterBackup
metadata:
name:
spec:
pxcCluster: demand-backup-parallel
storageName: minio
88 changes: 88 additions & 0 deletions e2e-tests/demand-backup-parallel/conf/cr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBCluster
metadata:
name: demand-backup-parallel
finalizers:
- percona.com/delete-pxc-pods-in-order
# annotations:
# percona.com/issue-vault-token: "true"
spec:
tls:
SANs:
- "minio-service.#namespace"
secretsName: my-cluster-secrets
vaultSecretName: some-name-vault
pause: false
pxc:
size: 3
image: -pxc
configuration: |
[mysqld]
wsrep_log_conflicts
log_error_verbosity=3
wsrep_debug=1
[sst]
xbstream-opts=--decompress
[xtrabackup]
compress=lz4
resources:
requests:
memory: 0.1G
cpu: 100m
limits:
memory: "2G"
cpu: "1"
volumeSpec:
persistentVolumeClaim:
resources:
requests:
storage: 2Gi
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
haproxy:
enabled: true
size: 2
image: -haproxy
resources:
requests:
memory: 0.1G
cpu: 100m
limits:
memory: 1G
cpu: 700m
affinity:
antiAffinityTopologyKey: "kubernetes.io/hostname"
pmm:
enabled: false
image: perconalab/pmm-client:1.17.1
serverHost: monitoring-service
serverUser: pmm
backup:
activeDeadlineSeconds: 3600
allowParallel: false
backoffLimit: 3
image: -backup
storages:
pvc:
type: filesystem
volume:
persistentVolumeClaim:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
minio:
type: s3
resources:
requests:
memory: 0.5G
cpu: 500m
limits:
memory: "2G"
cpu: "1"
s3:
credentialsSecret: minio-secret
region: us-east-1
bucket: operator-testing/prefix/subfolder
endpointUrl: http://minio-service.#namespace:9000/
verifyTLS: false
64 changes: 64 additions & 0 deletions e2e-tests/demand-backup-parallel/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/bash

# This test checks if spec.backup.allowParallel=false works as expected.

set -o errexit

test_dir=$(realpath $(dirname $0))
. ${test_dir}/../functions

set_debug

function run_backup() {
local name=$1
yq eval ".metadata.name = \"${name}\"" ${test_dir}/conf/backup.yml \
| kubectl_bin apply -f -
}

function check_active_backup_count() {
active_backup_count=$(kubectl_bin get pxc-backup | grep -E 'Starting|Running' | wc -l)
if [[ ${active_backup_count} -gt 1 ]]; then
log "There are ${active_backup_count} active backups. 'allowParallel: false' doesn't work properly"
exit 1
fi
}

create_infra ${namespace}

start_minio

log "creating PXC client"
kubectl_bin apply -f ${conf_dir}/client.yml

log "creating cluster secrets"
kubectl_bin apply -f ${conf_dir}/secrets.yml

cluster="demand-backup-parallel"
log "create PXC cluster: ${cluster}"
apply_config ${test_dir}/conf/cr.yml

desc 'creating backups'
run_backup backup1
run_backup backup2
run_backup backup3
run_backup backup4

wait_cluster_consistency ${cluster} 3 2
sleep 5
check_active_backup_count

for i in $(seq 0 3); do
sleep 5
check_active_backup_count
holder=$(kubectl_bin get lease pxc-${cluster}-backup-lock -o jsonpath={.spec.holderIdentity})
log "Backup lock holder: ${holder}"
wait_backup ${holder}
done

# explicitly check all backups to ensure all succeeded
wait_backup backup1
wait_backup backup2
wait_backup backup3
wait_backup backup4

log "test passed"
Loading
Loading