Skip to content
Draft
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 @@ -28953,6 +28953,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/pgv2.percona.com_perconapgclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29648,6 +29648,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30951,6 +30951,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down
8 changes: 8 additions & 0 deletions deploy/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29945,6 +29945,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down Expand Up @@ -69021,6 +69025,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down
8 changes: 8 additions & 0 deletions deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29945,6 +29945,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down Expand Up @@ -69021,6 +69025,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down
8 changes: 8 additions & 0 deletions deploy/cw-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29945,6 +29945,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down Expand Up @@ -69021,6 +69025,10 @@ spec:
description: Whether or not the pgBackRest repository PersistentVolumeClaim
is bound to a volume
type: boolean
desiredRepoVolume:
description: Desired size of the PersistentVolumeClaim containing
the repository.
type: string
name:
description: The name of the pgBackRest repository
type: string
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/run-pr.csv
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ ldap-tls
monitoring
monitoring-pmm3
one-pod
repo-host-autogrow
operator-self-healing
pitr
scaling
Expand Down
1 change: 1 addition & 0 deletions e2e-tests/run-release.csv
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ldap-tls
monitoring
monitoring-pmm3
one-pod
repo-host-autogrow
operator-self-healing
pitr
scaling
Expand Down
7 changes: 7 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/00-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
metadata:
name: check-operator-deploy-status
timeout: 120
commands:
- script: kubectl assert exist-enhanced deployment percona-postgresql-operator -n ${OPERATOR_NS:-$NAMESPACE} --field-selector status.readyReplicas=1
12 changes: 12 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/00-deploy-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
timeout: 10
commands:
- script: |-
set -o errexit
set -o xtrace

source ../../functions
init_temp_dir

PGO_FEATURE_GATES="AutoGrowVolumes=true" deploy_operator
17 changes: 17 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 420
---
apiVersion: pgv2.percona.com/v2
kind: PerconaPGCluster
metadata:
name: repo-host-autogrow
status:
state: ready
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: repo-host-autogrow-repo-host
status:
readyReplicas: 1
17 changes: 17 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/01-create-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
timeout: 10
commands:
- script: |-
set -o errexit
set -o xtrace

source ../../functions

get_cr \
| yq eval '
.spec.instances[0].replicas = 1 |
.spec.proxy.pgBouncer.replicas = 1 |
.spec.backups.pgbackrest.repos[0].volume.volumeClaimSpec.resources.requests.storage = "256Mi" |
.spec.backups.pgbackrest.repos[0].volume.volumeClaimSpec.resources.limits.storage = "300Mi"' - \
| kubectl -n "${NAMESPACE}" apply -f -
42 changes: 42 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 300
commands:
- script: |-
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

cluster=repo-host-autogrow
selector="postgres-operator.crunchydata.com/cluster=${cluster},postgres-operator.crunchydata.com/pgbackrest-dedicated"

repo_pod=$(kubectl -n "${NAMESPACE}" get pods -l "${selector}" -o jsonpath='{.items[0].metadata.name}')

suggested_size=
for _ in $(seq 1 60); do
suggested_size=$(kubectl -n "${NAMESPACE}" get pod "${repo_pod}" \
-o jsonpath='{.metadata.annotations.suggested-pgbackrest-repo1-pvc-size}')
if [[ -n "${suggested_size}" ]]; then
break
fi
sleep 5
done

if [[ -z "${suggested_size}" ]]; then
echo "Expected repo1 PVC size suggestion"
exit 1
fi
if [[ "${suggested_size}" != *Mi ]]; then
echo "Expected repo1 PVC size suggestion in Mi, got ${suggested_size}"
exit 1
fi

suggested_mebibytes=${suggested_size%Mi}
if ((suggested_mebibytes <= 300)); then
echo "Expected repo1 PVC size suggestion greater than 300Mi, got ${suggested_size}"
exit 1
fi

kubectl -n "${NAMESPACE}" exec "${repo_pod}" -c pgbackrest-config -- \
rm -f /pgbackrest/repo1/autogrow-e2e.fill
33 changes: 33 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/02-grow-repo-volume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
timeout: 300
commands:
- script: |-
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

cluster=repo-host-autogrow
selector="postgres-operator.crunchydata.com/cluster=${cluster},postgres-operator.crunchydata.com/pgbackrest-dedicated"
pvc_selector="postgres-operator.crunchydata.com/cluster=${cluster},postgres-operator.crunchydata.com/pgbackrest-volume,postgres-operator.crunchydata.com/pgbackrest-repo=repo1"

repo_pod=$(kubectl -n "${NAMESPACE}" get pods -l "${selector}" -o jsonpath='{.items[0].metadata.name}')
repo_pvc=$(kubectl -n "${NAMESPACE}" get pvc -l "${pvc_selector}" -o jsonpath='{.items[0].metadata.name}')
storage=$(kubectl -n "${NAMESPACE}" get pvc "${repo_pvc}" -o jsonpath='{.spec.resources.requests.storage}')

if [[ "${storage}" != "256Mi" ]]; then
echo "Expected repo1 PVC storage request to be 256Mi, got ${storage}"
exit 1
fi

read -r size used <<<"$(
kubectl -n "${NAMESPACE}" exec "${repo_pod}" -c pgbackrest-config -- \
df -Pm /pgbackrest/repo1 | awk 'FNR == 2 {print $2, $3}'
)"
fill_mebibytes=$(((size * 80 + 99) / 100 - used))
if ((fill_mebibytes > 0)); then
kubectl -n "${NAMESPACE}" exec "${repo_pod}" -c pgbackrest-config -- \
dd if=/dev/zero of=/pgbackrest/repo1/autogrow-e2e.fill \
bs=1M count="${fill_mebibytes}" conv=fsync status=none
fi
49 changes: 49 additions & 0 deletions e2e-tests/tests/repo-host-autogrow/03-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 300
commands:
- script: |-
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace

cluster=repo-host-autogrow
selector="postgres-operator.crunchydata.com/cluster=${cluster},postgres-operator.crunchydata.com/pgbackrest-dedicated"

repo_pod=$(kubectl -n "${NAMESPACE}" get pods -l "${selector}" -o jsonpath='{.items[0].metadata.name}')
suggested_size=$(kubectl -n "${NAMESPACE}" get pod "${repo_pod}" \
-o jsonpath='{.metadata.annotations.suggested-pgbackrest-repo1-pvc-size}')

if [[ -z "${suggested_size}" ]]; then
echo "Expected repo1 PVC size suggestion"
exit 1
fi

status_size=
for _ in $(seq 1 60); do
status_size=$(kubectl -n "${NAMESPACE}" get \
postgrescluster.upstream.pgv2.percona.com/"${cluster}" \
-o jsonpath='{.status.pgbackrest.repos[?(@.name=="repo1")].desiredRepoVolume}')
if [[ "${status_size}" == "${suggested_size}" ]]; then
break
fi
sleep 5
done

if [[ "${status_size}" != "${suggested_size}" ]]; then
echo "Expected desired repo volume ${suggested_size}, got ${status_size}"
exit 1
fi
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
postgres-operator.crunchydata.com/cluster: repo-host-autogrow
postgres-operator.crunchydata.com/pgbackrest-repo: repo1
postgres-operator.crunchydata.com/pgbackrest-volume: ""
spec:
resources:
requests:
storage: 300Mi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: pgv2.percona.com/v2
kind: PerconaPGCluster
metadata:
name: repo-host-autogrow
- apiVersion: upstream.pgv2.percona.com/v1beta1
kind: PostgresCluster
metadata:
name: repo-host-autogrow
commands:
- script: |-
set -o errexit
set -o xtrace

source ../../functions

remove_all_finalizers
check_operator_panic
destroy_operator
timeout: 60
Loading
Loading