Do not resize file system on a read-only mount

This commit is contained in:
Hemant Kumar 2017-11-29 11:56:30 -05:00
parent c0353ca20c
commit c82d412993

View File

@ -544,6 +544,7 @@ func (og *operationGenerator) resizeFileSystem(volumeToMount VolumeToMount, devi
glog.V(6).Infof("Resizing is not enabled for this volume %s", volumeToMount.VolumeName) glog.V(6).Infof("Resizing is not enabled for this volume %s", volumeToMount.VolumeName)
return nil return nil
} }
mounter := og.volumePluginMgr.Host.GetMounter(pluginName) mounter := og.volumePluginMgr.Host.GetMounter(pluginName)
// Get expander, if possible // Get expander, if possible
expandableVolumePlugin, _ := expandableVolumePlugin, _ :=
@ -565,6 +566,13 @@ func (og *operationGenerator) resizeFileSystem(volumeToMount VolumeToMount, devi
// File system resize was requested, proceed // File system resize was requested, proceed
glog.V(4).Infof(volumeToMount.GenerateMsgDetailed("MountVolume.resizeFileSystem entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath))) glog.V(4).Infof(volumeToMount.GenerateMsgDetailed("MountVolume.resizeFileSystem entering", fmt.Sprintf("DevicePath %q", volumeToMount.DevicePath)))
if volumeToMount.VolumeSpec.ReadOnly {
simpleMsg, detailedMsg := volumeToMount.GenerateMsg("MountVolume.resizeFileSystem failed", "requested read-only file system")
glog.Warningf(detailedMsg)
og.recorder.Eventf(volumeToMount.Pod, v1.EventTypeWarning, kevents.FileSystemResizeFailed, simpleMsg)
return nil
}
diskFormatter := &mount.SafeFormatAndMount{ diskFormatter := &mount.SafeFormatAndMount{
Interface: mounter, Interface: mounter,
Exec: og.volumePluginMgr.Host.GetExec(expandableVolumePlugin.GetPluginName()), Exec: og.volumePluginMgr.Host.GetExec(expandableVolumePlugin.GetPluginName()),