Consider file system resizing condition to determine whether a PVC is resizing

This commit is contained in:
Martin Montes
2024-02-24 16:30:14 +01:00
parent 4b9832082e
commit 3b6e3fdb3f
2 changed files with 21 additions and 2 deletions

View File

@ -113,7 +113,7 @@ func (r *MariaDBReconciler) waitForStorageResize(ctx context.Context, mdb *maria
return ctrl.Result{}, err
}
for _, p := range pvcs {
if pvc.IsResizing(p) {
if pvc.IsResizing(&p) {
logger.V(1).Info("Waiting for PVC resize", "pvc", p.Name)
return ctrl.Result{RequeueAfter: 1 * time.Second}, nil
}

View File

@ -2,7 +2,26 @@ package pvc
import corev1 "k8s.io/api/core/v1"
func IsResizing(pvc corev1.PersistentVolumeClaim) bool {
// IsResizing returns true if the PVC is resizing
func IsResizing(pvc *corev1.PersistentVolumeClaim) bool {
return IsPersistentVolumeClaimFileSystemResizePending(pvc) || IsPersistentVolumeClaimResizing(pvc)
}
// IsPersistentVolumeClaimFileSystemResizePending returns true if the PVC has FileSystemResizePending condition set to true
func IsPersistentVolumeClaimFileSystemResizePending(pvc *corev1.PersistentVolumeClaim) bool {
for _, c := range pvc.Status.Conditions {
if c.Status != corev1.ConditionTrue {
continue
}
if c.Type == corev1.PersistentVolumeClaimFileSystemResizePending {
return true
}
}
return false
}
// IsPersistentVolumeClaimResizing returns true if the PVC has Resizing condition set to true
func IsPersistentVolumeClaimResizing(pvc *corev1.PersistentVolumeClaim) bool {
for _, condition := range pvc.Status.Conditions {
if condition.Status != corev1.ConditionTrue {
continue