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

OADP-2144: Resize cloned pvc based on cmp between cloned vs size and source pvc size #251

Merged
18 changes: 18 additions & 0 deletions controllers/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ func (r *VolumeSnapshotBackupReconciler) buildPVCClone(pvcClone *corev1.Persiste
return err
}

// check the size of source pvc with that of the cloned volumesnapshot
// The cloned pvc provisioning will fail if the source pvc spec.resources.requests.sotrage value is less than the volumesnapshot.status.restorSize value
// In order to tackle this problem we compare both the values and use the one that is maximum so that provisioning of cloned pvc does not fail
// currently we are keeping this pvc resizing a default behavior but this can be put behind a datamover feature boolean flag

clonedVSRestoreSize := vsClone.Status.RestoreSize.Size()
sourcePVCRequestSize := sourcePVC.Spec.Resources.Size()

clonedPVCSize := sourcePVCRequestSize
if clonedVSRestoreSize > sourcePVCRequestSize {
clonedPVCSize = clonedVSRestoreSize
}

if pvcClone.CreationTimestamp.IsZero() {
apiGroup := "snapshot.storage.k8s.io"
pvcClone.Spec.DataSource = &corev1.TypedLocalObjectReference{
Expand Down Expand Up @@ -143,6 +156,11 @@ func (r *VolumeSnapshotBackupReconciler) buildPVCClone(pvcClone *corev1.Persiste
}

pvcClone.Spec.Resources = sourcePVC.Spec.Resources

// use the clonedPVCSize that is computed earlier
if clonedPVCSize != sourcePVCRequestSize {

Choose a reason for hiding this comment

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

Why not just always set to clonedSize?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@shawn-hurley will cloned size ever be smaller than source PVC size? This seems safer for "just in case the (almost) impossible happens"

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@sseago @shawn-hurley updated the PR, PTAL, Thanks !

pvcClone.Spec.Resources.Requests.Storage().Set(int64(clonedPVCSize))
}
}

return nil
Expand Down