Skip to content

Commit 156935f

Browse files
egeguneshors
andauthored
K8SPXC-1476: Disable PVC resize by default (#1846)
* K8SPXC-1476: Disable PVC resize by default * bump k8s version * fix versions in manifests --------- Co-authored-by: Viacheslav Sarzhan <[email protected]>
1 parent f763d7b commit 156935f

File tree

12 files changed

+70
-24
lines changed

12 files changed

+70
-24
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void createCluster(String CLUSTER_SUFFIX) {
1414
gcloud config set project $GCP_PROJECT
1515
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone $region --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $region --quiet || true
1616
17-
gcloud container clusters create --zone $region $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.27 --machine-type=n1-standard-4 --preemptible --disk-size 30 --num-nodes=\$NODES_NUM --network=jenkins-vpc --subnetwork=jenkins-${CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 && \
17+
gcloud container clusters create --zone $region $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.28 --machine-type=n1-standard-4 --preemptible --disk-size 30 --num-nodes=\$NODES_NUM --network=jenkins-vpc --subnetwork=jenkins-${CLUSTER_SUFFIX} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 && \
1818
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT".iam.gserviceaccount.com || ret_val=\$?
1919
if [ \${ret_val} -eq 0 ]; then break; fi
2020
ret_num=\$((ret_num + 1))

config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,8 @@ spec:
10741074
type: string
10751075
enableCRValidationWebhook:
10761076
type: boolean
1077+
enableVolumeExpansion:
1078+
type: boolean
10771079
haproxy:
10781080
properties:
10791081
affinity:

deploy/bundle.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,8 @@ spec:
19741974
type: string
19751975
enableCRValidationWebhook:
19761976
type: boolean
1977+
enableVolumeExpansion:
1978+
type: boolean
19771979
haproxy:
19781980
properties:
19791981
affinity:
@@ -11308,7 +11310,7 @@ spec:
1130811310
value: percona-xtradb-cluster-operator
1130911311
- name: DISABLE_TELEMETRY
1131011312
value: "false"
11311-
image: percona/percona-xtradb-cluster-operator:1.15.0
11313+
image: perconalab/percona-xtradb-cluster-operator:1.15.0
1131211314
imagePullPolicy: Always
1131311315
livenessProbe:
1131411316
failureThreshold: 3

deploy/cr-minimal.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: PerconaXtraDBCluster
33
metadata:
44
name: minimal-cluster
55
spec:
6-
crVersion: 1.15.0
6+
crVersion: 1.15.1
77
secretsName: minimal-cluster-secrets
88
unsafeFlags:
99
tls: true
@@ -28,4 +28,4 @@ spec:
2828
image: percona/haproxy:2.8.5
2929
logcollector:
3030
enabled: true
31-
image: percona/percona-xtradb-cluster-operator:1.15.0-logcollector-fluentbit3.1.4
31+
image: percona/percona-xtradb-cluster-operator:1.15.1-logcollector-fluentbit3.1.4

deploy/cr.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ metadata:
1010
# annotations:
1111
# percona.com/issue-vault-token: "true"
1212
spec:
13-
crVersion: 1.15.0
13+
crVersion: 1.15.1
14+
# enableVolumeExpansion: false
1415
# ignoreAnnotations:
1516
# - iam.amazonaws.com/role
1617
# ignoreLabels:

deploy/crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,8 @@ spec:
19741974
type: string
19751975
enableCRValidationWebhook:
19761976
type: boolean
1977+
enableVolumeExpansion:
1978+
type: boolean
19771979
haproxy:
19781980
properties:
19791981
affinity:

deploy/cw-bundle.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,8 @@ spec:
19741974
type: string
19751975
enableCRValidationWebhook:
19761976
type: boolean
1977+
enableVolumeExpansion:
1978+
type: boolean
19771979
haproxy:
19781980
properties:
19791981
affinity:
@@ -11318,7 +11320,7 @@ spec:
1131811320
value: percona-xtradb-cluster-operator
1131911321
- name: DISABLE_TELEMETRY
1132011322
value: "false"
11321-
image: percona/percona-xtradb-cluster-operator:1.15.0
11323+
image: perconalab/percona-xtradb-cluster-operator:1.15.0
1132211324
imagePullPolicy: Always
1132311325
resources:
1132411326
limits:

deploy/cw-operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ spec:
4242
value: percona-xtradb-cluster-operator
4343
- name: DISABLE_TELEMETRY
4444
value: "false"
45-
image: percona/percona-xtradb-cluster-operator:1.15.0
45+
image: perconalab/percona-xtradb-cluster-operator:1.15.0
4646
imagePullPolicy: Always
4747
resources:
4848
limits:

deploy/operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ spec:
4545
value: percona-xtradb-cluster-operator
4646
- name: DISABLE_TELEMETRY
4747
value: "false"
48-
image: percona/percona-xtradb-cluster-operator:1.15.0
48+
image: perconalab/percona-xtradb-cluster-operator:1.15.0
4949
imagePullPolicy: Always
5050
livenessProbe:
5151
failureThreshold: 3

e2e-tests/pvc-resize/run

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,43 @@ function wait_cluster_status() {
6464
echo "pxc/${cluster} status is ${expected}"
6565
}
6666

67+
function wait_all_pvc_resize() {
68+
local expected_size=$1
69+
local max_retry=${2:-120}
70+
local sleep_time=${3:-5}
71+
72+
for pvc in $(kubectl_bin get pvc -l app.kubernetes.io/component=pxc -o name); do
73+
if ! wait_pvc_resize "$pvc" "$expected_size" "$max_retry" "$sleep_time"; then
74+
return 1
75+
fi
76+
done
77+
return 0
78+
}
79+
80+
function wait_pvc_resize() {
81+
local pvc=$1
82+
local expected_size=$2
83+
local max_retry=${3:-120}
84+
local sleep_time=${4:-5}
85+
86+
local retry=0
87+
echo "Waiting for $pvc to be resized"
88+
until [[ $(kubectl_bin get "$pvc" -o jsonpath='{.status.capacity.storage}') == "$expected_size" ]]; do
89+
if [[ $retry -ge $max_retry ]]; then
90+
echo
91+
echo "$pvc was not resized, max retries exceeded"
92+
return 1
93+
fi
94+
echo -n "."
95+
sleep "$sleep_time"
96+
97+
retry=$((retry + 1))
98+
done
99+
echo
100+
echo "${pvc} was resized"
101+
return 0
102+
}
103+
67104
set_debug
68105

69106
if [ "$EKS" == 1 -o -n "$OPENSHIFT" ]; then
@@ -89,24 +126,17 @@ desc "test scaling"
89126
patch_pvc_request "${cluster}" "3G"
90127
wait_cluster_consistency "$cluster" 3 2
91128

92-
for pvc in $(kubectl_bin get pvc -l app.kubernetes.io/component=pxc -o name); do
93-
retry=0
94-
echo -n "Waiting for ${pvc} to be resized"
95-
until [[ $(kubectl_bin get ${pvc} -o jsonpath={.status.capacity.storage}) == "3Gi" ]]; do
96-
if [[ $retry -ge 60 ]]; then
97-
echo
98-
echo "pvc/${pvc} was not resized, max retries exceeded"
99-
exit 1
100-
fi
129+
if wait_all_pvc_resize "3Gi" 120 1; then
130+
echo "PVC was resized, but resize.expansion is disabled"
131+
exit 1
132+
fi
101133

102-
echo -n "."
103-
sleep 5
134+
echo "Enabling PVC resize"
135+
kubectl_bin patch pxc "${cluster}" --type=json -p='[{"op": "add", "path": "/spec/enableVolumeExpansion", "value":true }]'
136+
sleep 10
104137

105-
retry=$((retry + 1))
106-
done
107-
echo
108-
echo "${pvc} was resized"
109-
done
138+
wait_cluster_consistency "${cluster}" 3 2
139+
wait_all_pvc_resize "3Gi"
110140

111141
if [ "$EKS" == 1 -o -n "$OPENSHIFT" ]; then
112142
# EKS rate limits PVC expansion for the same EBS volume (1 expand operation in every 6 hours),

pkg/apis/pxc/v1/pxc_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type PerconaXtraDBClusterSpec struct {
4747
UpgradeOptions UpgradeOptions `json:"upgradeOptions,omitempty"`
4848
AllowUnsafeConfig bool `json:"allowUnsafeConfigurations,omitempty"`
4949
Unsafe UnsafeFlags `json:"unsafeFlags,omitempty"`
50+
VolumeExpansionEnabled bool `json:"enableVolumeExpansion,omitempty"`
5051

5152
// Deprecated, should be removed in the future. Use InitContainer.Image instead
5253
InitImage string `json:"initImage,omitempty"`

pkg/controller/pxc/volumes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ func (r *ReconcilePerconaXtraDBCluster) reconcilePersistentVolumes(ctx context.C
232232
return nil
233233
}
234234

235+
if !cr.Spec.VolumeExpansionEnabled {
236+
// If expansion is disabled we should keep the old value
237+
cr.Spec.PXC.VolumeSpec.PersistentVolumeClaim.Resources.Requests[corev1.ResourceStorage] = configured
238+
return nil
239+
}
240+
235241
err = k8s.AnnotateObject(ctx, r.client, cr, map[string]string{pxcv1.AnnotationPVCResizeInProgress: metav1.Now().Format(time.RFC3339)})
236242
if err != nil {
237243
return errors.Wrap(err, "annotate pxc")

0 commit comments

Comments
 (0)