Created
September 18, 2017 18:34
-
-
Save gnufied/972e275270f2e2f5843ca96818ffca33 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oldSize := oldPvc.Spec.Resources.Requests[api.ResourceStorage] | |
newSize := pvc.Spec.Resources.Requests[api.ResourceStorage] | |
if newSize.Cmp(oldSize) <= 0 { | |
return nil | |
} | |
if oldPvc.Status.Phase != api.ClaimBound { | |
return admission.NewForbidden(a, fmt.Errorf("Only bound persistent volume claims can be expanded")) | |
} | |
// Growing Persistent volumes is only allowed for PVCs for which their StorageClass | |
// explicitly allows it | |
if !pvcr.allowResize(pvc, oldPvc) { | |
return admission.NewForbidden(a, fmt.Errorf("only dynamically provisioned pvc can be resized and "+ | |
"the storageclass that provisions the pvc must support resize")) | |
} | |
// volume plugin must support resize | |
pv, err := pvcr.pvLister.Get(pvc.Spec.VolumeName) | |
if err != nil { | |
return admission.NewForbidden(a, fmt.Errorf("Error updating persistent volume claim because fetching associated persistent volume failed")) | |
} | |
if !pvcr.checkVolumePlugin(pv) { | |
return admission.NewForbidden(a, fmt.Errorf("volume plugin does not support resize")) | |
} | |
return nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oldSize := oldPvc.Spec.Resources.Requests[api.ResourceStorage] | |
newSize := pvc.Spec.Resources.Requests[api.ResourceStorage] | |
if newSize.Cmp(oldSize) > 0 { | |
if oldPvc.Status.Phase != api.ClaimBound { | |
return admission.NewForbidden(a, fmt.Errorf("Only bound persistent volume claims can be expanded")) | |
} | |
// Growing Persistent volumes is only allowed for PVCs for which their StorageClass | |
// explicitly allows it | |
if !pvcr.allowResize(pvc, oldPvc) { | |
return admission.NewForbidden(a, fmt.Errorf("only dynamically provisioned pvc can be resized and "+ | |
"the storageclass that provisions the pvc must support resize")) | |
} | |
// volume plugin must support resize | |
pv, err := pvcr.pvLister.Get(pvc.Spec.VolumeName) | |
if err != nil { | |
return admission.NewForbidden(a, fmt.Errorf("Error updating persistent volume claim because fetching associated persistent volume failed")) | |
} | |
if !pvcr.checkVolumePlugin(pv) { | |
return admission.NewForbidden(a, fmt.Errorf("volume plugin does not support resize")) | |
} | |
} | |
return nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment