-
Notifications
You must be signed in to change notification settings - Fork 245
Description
Describe the bug
CSI Snapshot Size is not calculated correctly when backend contains snapshotReserve parameter
Environment
(Lab on Demand Kubernetes v4.0)
- Trident version: 21.07.0
- Trident installation flags used: standard with Helm
- Container runtime: Docker 18.09.1
- Kubernetes version: 1.18.6
- Kubernetes orchestrator: Kubernetes
- OS: RHEL 7.5
- NetApp backend types: ONTAP 9.7
To Reproduce
Create a Backend with snapshotReserve parameter set
example:
apiVersion: trident.netapp.io/v1
kind: TridentBackendConfig
metadata:
name: backend-tbc-ontap-nas-snap-reserve
spec:
version: 1
backendName: nas-snap-reserve
storageDriverName: ontap-nas
managementLIF: 192.168.0.135
storagePrefix: sr_
defaults:
snapshotDir: 'true'
snapshotPolicy: default
snapshotReserve: '40'
credentials:
name: ontap-nfs-svm-secret-username
Then create a PVC (10GB), a CSI Snapshot (no size) & a PVC based on the CSI Snapshot (10GB)
Notice the new PVC's creation will fail.
[root@rhel3 1_Busybox]# kg pvc,volumesnapshot -n busybox
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
persistentvolumeclaim/mydata Bound pvc-6f3caa6d-491e-4a63-a54d-ecfb94b1d521 10Gi RWX storage-class-nas-snap-reserve 116m
persistentvolumeclaim/mydata-from-snap Pending storage-class-nas-snap-reserve 8m5s
NAME READYTOUSE SOURCEPVC SOURCESNAPSHOTCONTENT RESTORESIZE SNAPSHOTCLASS SNAPSHOTCONTENT CREATIONTIME AGE
volumesnapshot.snapshot.storage.k8s.io/mydata-snapshot true mydata 17476268Ki csi-snap-class snapcontent-912985d7-8a8c-443a-9de3-bea1165ae26f 16m 16m
Notice the Snapshot size: 17476268Ki
PVC mydata-from-snap logs:
Warning ProvisioningFailed 4m5s (x13 over 9m13s) csi.trident.netapp.io_trident-csi-55cb9d695f-4h586_ac3e5337-ed2a-49ae-8eab-cd3379464de4 failed to provision volume with StorageClass "storage-class-nas-snap-reserve": error getting handle for DataSource Type VolumeSnapshot by Name mydata-snapshot: requested volume size 10737418240 is less than the size 17895698432 for the source snapshot mydata-snapshot
from ONTAP:
cluster1::> vol show -vserver nfs_svm -volume sr_pvc_* -fields size,available,percent-snapshot-space
vserver volume size available percent-snapshot-space
------- ------------------------------------------- ------- --------- ----------------------
nfs_svm sr_pvc_6f3caa6d_491e_4a63_a54d_ecfb94b1d521 16.67GB 10.00GB 40%
=> looks like the CSI Snapshot Size uses the total size of the ONTAP volume (PVC + Snapshot reserve), instead of the PVC size
SnapshotReserve: 40%
PVC: 10GB
ONTAP Volume Size: 10 / (1-0,4) = 16,67GB = 17476268 Ki
Expected behavior
Snapshot size to use the correct value
Additional context
not setting the snapshotReserve will lead to using the default ONTAP value of 5%.
This will also lead to a fail when creating a PVC from a snapshot