Fix volumeMode retrieval when BlockVolume feature is off

API served does not need to default volumeMode to Filesystem.
This commit is contained in:
Jan Safranek 2019-10-21 09:20:37 +02:00
parent acf129443c
commit c9fc26d85e

View File

@ -505,11 +505,14 @@ func (dswp *desiredStateOfWorldPopulator) createVolumeSpec(
pvcSource.ClaimName, pvcSource.ClaimName,
pvcUID) pvcUID)
// TODO: remove features.BlockVolume checks / comments after no longer needed // TODO: replace this with util.GetVolumeMode() when features.BlockVolume is removed.
volumeMode, err := util.GetVolumeMode(volumeSpec) // The function will return the right value then.
if err != nil { volumeMode := v1.PersistentVolumeFilesystem
return nil, nil, "", err if volumeSpec.PersistentVolume != nil && volumeSpec.PersistentVolume.Spec.VolumeMode != nil {
volumeMode = *volumeSpec.PersistentVolume.Spec.VolumeMode
} }
// TODO: remove features.BlockVolume checks / comments after no longer needed
// Error if a container has volumeMounts but the volumeMode of PVC isn't Filesystem. // Error if a container has volumeMounts but the volumeMode of PVC isn't Filesystem.
// Do not check feature gate here to make sure even when the feature is disabled in kubelet, // Do not check feature gate here to make sure even when the feature is disabled in kubelet,
// because controller-manager / API server can already contain block PVs / PVCs. // because controller-manager / API server can already contain block PVs / PVCs.