Fix gce_pd to only use safe_format_and_mount when mounting block devices.

This commit is contained in:
Brendan Burns 2015-02-06 12:41:21 -08:00
parent 35fa143b29
commit 3d6c9fc9e8

View File

@ -72,7 +72,7 @@ func (plugin *gcePersistentDiskPlugin) CanSupport(spec *api.Volume) bool {
func (plugin *gcePersistentDiskPlugin) NewBuilder(spec *api.Volume, podUID types.UID) (volume.Builder, error) { func (plugin *gcePersistentDiskPlugin) NewBuilder(spec *api.Volume, podUID types.UID) (volume.Builder, error) {
// Inject real implementations here, test through the internal function. // Inject real implementations here, test through the internal function.
return plugin.newBuilderInternal(spec, podUID, &GCEDiskUtil{}, &gceSafeFormatAndMount{mount.New(), exec.New()}) return plugin.newBuilderInternal(spec, podUID, &GCEDiskUtil{}, mount.New())
} }
func (plugin *gcePersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Builder, error) { func (plugin *gcePersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Builder, error) {
@ -90,16 +90,17 @@ func (plugin *gcePersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podU
readOnly := spec.Source.GCEPersistentDisk.ReadOnly readOnly := spec.Source.GCEPersistentDisk.ReadOnly
return &gcePersistentDisk{ return &gcePersistentDisk{
podUID: podUID, podUID: podUID,
volName: spec.Name, volName: spec.Name,
pdName: pdName, pdName: pdName,
fsType: fsType, fsType: fsType,
partition: partition, partition: partition,
readOnly: readOnly, readOnly: readOnly,
manager: manager, manager: manager,
mounter: mounter, mounter: mounter,
plugin: plugin, diskMounter: &gceSafeFormatAndMount{mounter, exec.New()},
legacyMode: false, plugin: plugin,
legacyMode: false,
}, nil }, nil
} }
@ -114,12 +115,13 @@ func (plugin *gcePersistentDiskPlugin) newCleanerInternal(volName string, podUID
legacy = true legacy = true
} }
return &gcePersistentDisk{ return &gcePersistentDisk{
podUID: podUID, podUID: podUID,
volName: volName, volName: volName,
manager: manager, manager: manager,
mounter: mounter, mounter: mounter,
plugin: plugin, diskMounter: &gceSafeFormatAndMount{mounter, exec.New()},
legacyMode: legacy, plugin: plugin,
legacyMode: legacy,
}, nil }, nil
} }
@ -146,10 +148,12 @@ type gcePersistentDisk struct {
readOnly bool readOnly bool
// Utility interface that provides API calls to the provider to attach/detach disks. // Utility interface that provides API calls to the provider to attach/detach disks.
manager pdManager manager pdManager
// Mounter interface that provides system calls to mount the disks. // Mounter interface that provides system calls to mount the global path to the pod local path.
mounter mount.Interface mounter mount.Interface
plugin *gcePersistentDiskPlugin // diskMounter provides the interface that is used to mount the actual block device.
legacyMode bool diskMounter mount.Interface
plugin *gcePersistentDiskPlugin
legacyMode bool
} }
func detachDiskLogError(pd *gcePersistentDisk) { func detachDiskLogError(pd *gcePersistentDisk) {