Merge pull request #4221 from brendandburns/pd_fix

Make gce_safe_format_and_mount actually work correctly.
This commit is contained in:
Zach Loafman 2015-02-06 14:50:20 -08:00
commit b77abb5945
2 changed files with 26 additions and 21 deletions

View File

@ -25,6 +25,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api" "github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume" "github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume"
"github.com/GoogleCloudPlatform/kubernetes/pkg/types" "github.com/GoogleCloudPlatform/kubernetes/pkg/types"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/exec"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount" "github.com/GoogleCloudPlatform/kubernetes/pkg/util/mount"
"github.com/golang/glog" "github.com/golang/glog"
) )
@ -89,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
} }
@ -113,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
} }
@ -145,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) {

View File

@ -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. // 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 // TODO: port this script into Go and use it for all Linux platforms
type gceSafeFormatAndMount struct { type gceSafeFormatAndMount struct {
mount.Mounter mount.Interface
runner exec.Interface runner exec.Interface
} }