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,
pvcUID)
// TODO: remove features.BlockVolume checks / comments after no longer needed
volumeMode, err := util.GetVolumeMode(volumeSpec)
if err != nil {
return nil, nil, "", err
// TODO: replace this with util.GetVolumeMode() when features.BlockVolume is removed.
// The function will return the right value then.
volumeMode := v1.PersistentVolumeFilesystem
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.
// 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.