From 35fa143b29c94f03adc3e90bfa9e8f6a74a72af7 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 6 Feb 2015 10:09:00 -0800 Subject: [PATCH 1/2] Revert "Revert "Start using GCE safe format and mount for mounting disks."" This reverts commit 858a85e8fec177d2a0b69a25315503a5ee474d6f. --- pkg/kubelet/volume/gce_pd/gce_pd.go | 3 ++- pkg/kubelet/volume/gce_pd/gce_util.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/volume/gce_pd/gce_pd.go b/pkg/kubelet/volume/gce_pd/gce_pd.go index 294662b185b..c7de64caffd 100644 --- a/pkg/kubelet/volume/gce_pd/gce_pd.go +++ b/pkg/kubelet/volume/gce_pd/gce_pd.go @@ -25,6 +25,7 @@ import ( "github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume" "github.com/GoogleCloudPlatform/kubernetes/pkg/types" + "github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount" "github.com/golang/glog" ) @@ -71,7 +72,7 @@ func (plugin *gcePersistentDiskPlugin) CanSupport(spec *api.Volume) bool { func (plugin *gcePersistentDiskPlugin) NewBuilder(spec *api.Volume, podUID types.UID) (volume.Builder, error) { // Inject real implementations here, test through the internal function. - return plugin.newBuilderInternal(spec, podUID, &GCEDiskUtil{}, mount.New()) + return plugin.newBuilderInternal(spec, podUID, &GCEDiskUtil{}, &gceSafeFormatAndMount{mount.New(), exec.New()}) } func (plugin *gcePersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podUID types.UID, manager pdManager, mounter mount.Interface) (volume.Builder, error) { diff --git a/pkg/kubelet/volume/gce_pd/gce_util.go b/pkg/kubelet/volume/gce_pd/gce_util.go index 45a6996fdca..b9c4c56a7d1 100644 --- a/pkg/kubelet/volume/gce_pd/gce_util.go +++ b/pkg/kubelet/volume/gce_pd/gce_util.go @@ -147,7 +147,7 @@ func (util *GCEDiskUtil) DetachDisk(pd *gcePersistentDisk, devicePath string) er // This eliminates the necesisty to format a PD before it is used with a Pod on GCE. // TODO: port this script into Go and use it for all Linux platforms type gceSafeFormatAndMount struct { - mount.Mounter + mount.Interface runner exec.Interface } From 3d6c9fc9e8326cf027cde2f2b2f78c46f619f0a3 Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 6 Feb 2015 12:41:21 -0800 Subject: [PATCH 2/2] Fix gce_pd to only use safe_format_and_mount when mounting block devices. --- pkg/kubelet/volume/gce_pd/gce_pd.go | 46 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/pkg/kubelet/volume/gce_pd/gce_pd.go b/pkg/kubelet/volume/gce_pd/gce_pd.go index c7de64caffd..3466878d0c5 100644 --- a/pkg/kubelet/volume/gce_pd/gce_pd.go +++ b/pkg/kubelet/volume/gce_pd/gce_pd.go @@ -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) { // 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) { @@ -90,16 +90,17 @@ func (plugin *gcePersistentDiskPlugin) newBuilderInternal(spec *api.Volume, podU readOnly := spec.Source.GCEPersistentDisk.ReadOnly return &gcePersistentDisk{ - podUID: podUID, - volName: spec.Name, - pdName: pdName, - fsType: fsType, - partition: partition, - readOnly: readOnly, - manager: manager, - mounter: mounter, - plugin: plugin, - legacyMode: false, + podUID: podUID, + volName: spec.Name, + pdName: pdName, + fsType: fsType, + partition: partition, + readOnly: readOnly, + manager: manager, + mounter: mounter, + diskMounter: &gceSafeFormatAndMount{mounter, exec.New()}, + plugin: plugin, + legacyMode: false, }, nil } @@ -114,12 +115,13 @@ func (plugin *gcePersistentDiskPlugin) newCleanerInternal(volName string, podUID legacy = true } return &gcePersistentDisk{ - podUID: podUID, - volName: volName, - manager: manager, - mounter: mounter, - plugin: plugin, - legacyMode: legacy, + podUID: podUID, + volName: volName, + manager: manager, + mounter: mounter, + diskMounter: &gceSafeFormatAndMount{mounter, exec.New()}, + plugin: plugin, + legacyMode: legacy, }, nil } @@ -146,10 +148,12 @@ type gcePersistentDisk struct { readOnly bool // Utility interface that provides API calls to the provider to attach/detach disks. manager pdManager - // Mounter interface that provides system calls to mount the disks. - mounter mount.Interface - plugin *gcePersistentDiskPlugin - legacyMode bool + // Mounter interface that provides system calls to mount the global path to the pod local path. + mounter mount.Interface + // diskMounter provides the interface that is used to mount the actual block device. + diskMounter mount.Interface + plugin *gcePersistentDiskPlugin + legacyMode bool } func detachDiskLogError(pd *gcePersistentDisk) {