PersistentLocalVolumes validation and tests

Signed-off-by: Serguei Bezverkhi <sbezverk@cisco.com>
This commit is contained in:
Serguei Bezverkhi
2019-01-08 11:00:29 -05:00
parent 1b28775db1
commit 8915e90398
4 changed files with 110 additions and 30 deletions

View File

@@ -28,7 +28,9 @@ func DropDisabledFields(pvSpec *api.PersistentVolumeSpec, oldPVSpec *api.Persist
if !utilfeature.DefaultFeatureGate.Enabled(features.BlockVolume) && !volumeModeInUse(oldPVSpec) {
pvSpec.VolumeMode = nil
}
if !utilfeature.DefaultFeatureGate.Enabled(features.PersistentLocalVolumes) && !persistentLocalVolumesInUse(oldPVSpec) {
pvSpec.PersistentVolumeSource.Local = nil
}
if !utilfeature.DefaultFeatureGate.Enabled(features.CSIPersistentVolume) {
// if this is a new PV, or the old PV didn't already have the CSI field, clear it
if oldPVSpec == nil || oldPVSpec.PersistentVolumeSource.CSI == nil {
@@ -46,3 +48,13 @@ func volumeModeInUse(oldPVSpec *api.PersistentVolumeSpec) bool {
}
return false
}
func persistentLocalVolumesInUse(oldPVSpec *api.PersistentVolumeSpec) bool {
if oldPVSpec == nil {
return false
}
if oldPVSpec.PersistentVolumeSource.Local != nil {
return true
}
return false
}