Add fsGroup to SetUp and SetUpAt

pull/6/head
Sami Wagiaalla 2015-12-18 10:55:11 -05:00
parent e33e4ae055
commit f650648aae
36 changed files with 99 additions and 94 deletions

View File

@ -515,7 +515,7 @@ func TestGetPodVolumesFromDisk(t *testing.T) {
expectedPaths := []string{}
for i := range volsOnDisk {
fv := volume.FakeVolume{PodUID: volsOnDisk[i].podUID, VolName: volsOnDisk[i].volName, Plugin: plug}
fv.SetUp()
fv.SetUp(nil)
expectedPaths = append(expectedPaths, fv.GetPath())
}
@ -550,11 +550,11 @@ func (f *stubVolume) GetAttributes() volume.Attributes {
return volume.Attributes{}
}
func (f *stubVolume) SetUp() error {
func (f *stubVolume) SetUp(fsGroup *int64) error {
return nil
}
func (f *stubVolume) SetUpAt(dir string) error {
func (f *stubVolume) SetUpAt(dir string, fsGroup *int64) error {
return nil
}

View File

@ -120,10 +120,10 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
for i := range pod.Spec.Volumes {
volSpec := &pod.Spec.Volumes[i]
hasFSGroup := false
var fsGroup int64 = 0
var fsGroup *int64
if pod.Spec.SecurityContext != nil && pod.Spec.SecurityContext.FSGroup != nil {
hasFSGroup = true
fsGroup = *pod.Spec.SecurityContext.FSGroup
fsGroup = pod.Spec.SecurityContext.FSGroup
}
rootContext, err := kl.getRootDirContext()
@ -141,7 +141,7 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
if builder == nil {
return nil, errUnsupportedVolumeType
}
err = builder.SetUp()
err = builder.SetUp(fsGroup)
if err != nil {
return nil, err
}

View File

@ -230,12 +230,12 @@ func (b *awsElasticBlockStoreBuilder) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func (b *awsElasticBlockStoreBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *awsElasticBlockStoreBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
// SetUpAt attaches the disk and bind mounts to the volume path.
func (b *awsElasticBlockStoreBuilder) SetUpAt(dir string) error {
func (b *awsElasticBlockStoreBuilder) SetUpAt(dir string, fsGroup *int64) error {
// TODO: handle failed mounts here.
notMnt, err := b.mounter.IsLikelyNotMountPoint(dir)
glog.V(4).Infof("PersistentDisk set up: %s %v %v", dir, !notMnt, err)

View File

@ -154,7 +154,7 @@ func TestPlugin(t *testing.T) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {

View File

@ -163,12 +163,12 @@ func (cephfsVolume *cephfsBuilder) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func (cephfsVolume *cephfsBuilder) SetUp() error {
return cephfsVolume.SetUpAt(cephfsVolume.GetPath())
func (cephfsVolume *cephfsBuilder) SetUp(fsGroup *int64) error {
return cephfsVolume.SetUpAt(cephfsVolume.GetPath(), fsGroup)
}
// SetUpAt attaches the disk and bind mounts to the volume path.
func (cephfsVolume *cephfsBuilder) SetUpAt(dir string) error {
func (cephfsVolume *cephfsBuilder) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := cephfsVolume.mounter.IsLikelyNotMountPoint(dir)
glog.V(4).Infof("CephFS mount set up: %s %v %v", dir, !notMnt, err)
if err != nil && !os.IsNotExist(err) {

View File

@ -88,7 +88,7 @@ func TestPlugin(t *testing.T) {
if path != volpath {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(volumePath); err != nil {

View File

@ -223,12 +223,12 @@ func (b *cinderVolumeBuilder) GetAttributes() volume.Attributes {
}
}
func (b *cinderVolumeBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *cinderVolumeBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
// SetUp attaches the disk and bind mounts to the volume path.
func (b *cinderVolumeBuilder) SetUpAt(dir string) error {
func (b *cinderVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
// TODO: handle failed mounts here.
notmnt, err := b.mounter.IsLikelyNotMountPoint(dir)
glog.V(4).Infof("PersistentDisk set up: %s %v %v", dir, !notmnt, err)

View File

@ -121,7 +121,7 @@ func TestPlugin(t *testing.T) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {

View File

@ -123,11 +123,11 @@ func (d *downwardAPIVolume) GetAttributes() volume.Attributes {
// This function is not idempotent by design. We want the data to be refreshed periodically.
// The internal sync interval of kubelet will drive the refresh of data.
// TODO: Add volume specific ticker and refresh loop
func (b *downwardAPIVolumeBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *downwardAPIVolumeBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
func (b *downwardAPIVolumeBuilder) SetUpAt(dir string) error {
func (b *downwardAPIVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
glog.V(3).Infof("Setting up a downwardAPI volume %v for pod %v/%v at %v", b.volName, b.pod.Namespace, b.pod.Name, dir)
// Wrap EmptyDir. Here we rely on the idempotency of the wrapped plugin to avoid repeatedly mounting
wrapped, err := b.plugin.host.NewWrapperBuilder(wrappedVolumeSpec, b.pod, *b.opts)
@ -135,7 +135,7 @@ func (b *downwardAPIVolumeBuilder) SetUpAt(dir string) error {
glog.Errorf("Couldn't setup downwardAPI volume %v for pod %v/%v: %s", b.volName, b.pod.Namespace, b.pod.Name, err.Error())
return err
}
if err := wrapped.SetUpAt(dir); err != nil {
if err := wrapped.SetUpAt(dir, fsGroup); err != nil {
glog.Errorf("Unable to setup downwardAPI volume %v for pod %v/%v: %s", b.volName, b.pod.Namespace, b.pod.Name, err.Error())
return err
}

View File

@ -136,7 +136,7 @@ func TestLabels(t *testing.T) {
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -205,7 +205,7 @@ func TestAnnotations(t *testing.T) {
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -270,7 +270,7 @@ func TestName(t *testing.T) {
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -336,7 +336,7 @@ func TestNamespace(t *testing.T) {
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -404,7 +404,7 @@ func TestWriteTwiceNoUpdate(t *testing.T) {
}
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -415,7 +415,7 @@ func TestWriteTwiceNoUpdate(t *testing.T) {
t.Errorf(".current should be a link... %s\n", err.Error())
}
err = builder.SetUp() // now re-run Setup
err = builder.SetUp(nil) // now re-run Setup
if err != nil {
t.Errorf("Failed to re-setup volume: %v", err)
}
@ -493,7 +493,7 @@ func TestWriteTwiceWithUpdate(t *testing.T) {
}
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -520,7 +520,7 @@ func TestWriteTwiceWithUpdate(t *testing.T) {
// Now update the labels
pod.ObjectMeta.Labels = newLabels
err = builder.SetUp() // now re-run Setup
err = builder.SetUp(nil) // now re-run Setup
if err != nil {
t.Errorf("Failed to re-setup volume: %v", err)
}
@ -604,7 +604,7 @@ func TestWriteWithUnixPath(t *testing.T) {
}
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -689,7 +689,7 @@ func TestWriteWithUnixPathBadPath(t *testing.T) {
volumePath := builder.GetPath()
defer CleanEverything(plugin, testVolumeName, volumePath, testPodUID, t)
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Fatalf("Failed to setup volume: %v", err)
}

View File

@ -150,12 +150,12 @@ func (ed *emptyDir) GetAttributes() volume.Attributes {
}
// SetUp creates new directory.
func (ed *emptyDir) SetUp() error {
return ed.SetUpAt(ed.GetPath())
func (ed *emptyDir) SetUp(fsGroup *int64) error {
return ed.SetUpAt(ed.GetPath(), fsGroup)
}
// SetUpAt creates new directory.
func (ed *emptyDir) SetUpAt(dir string) error {
func (ed *emptyDir) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := ed.mounter.IsLikelyNotMountPoint(dir)
// Getting an os.IsNotExist err from is a contingency; the directory
// may not exist yet, in which case, setup should run.

View File

@ -185,7 +185,7 @@ func doTestPlugin(t *testing.T, config pluginTestConfig) {
t.Errorf("Got unexpected path: %s", volPath)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}

View File

@ -176,11 +176,11 @@ func (b *fcDiskBuilder) GetAttributes() volume.Attributes {
SupportsSELinux: true,
}
}
func (b *fcDiskBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *fcDiskBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
func (b *fcDiskBuilder) SetUpAt(dir string) error {
func (b *fcDiskBuilder) SetUpAt(dir string, fsGroup *int64) error {
// diskSetUp checks mountpoints and prevent repeated calls
err := diskSetUp(b.manager, *b, dir, b.mounter)
if err != nil {

View File

@ -121,7 +121,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {

View File

@ -223,8 +223,8 @@ type flexVolumeBuilder struct {
}
// SetUp creates new directory.
func (f *flexVolumeBuilder) SetUp() error {
return f.SetUpAt(f.GetPath())
func (f *flexVolumeBuilder) SetUp(fsGroup *int64) error {
return f.SetUpAt(f.GetPath(), fsGroup)
}
// GetAttributes get the flex volume attributes. The attributes will be queried
@ -251,7 +251,7 @@ type flexVolumeManager interface {
}
// SetUpAt creates new directory.
func (f *flexVolumeBuilder) SetUpAt(dir string) error {
func (f *flexVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
notmnt, err := f.blockDeviceMounter.IsLikelyNotMountPoint(dir)
if err != nil && !os.IsNotExist(err) {

View File

@ -238,7 +238,7 @@ func doTestPluginAttachDetach(t *testing.T, spec *volume.Spec) {
if path != "/tmp/fake/pods/poduid/volumes/kubernetes.io~fakeAttacher/vol1" {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(volumePath); err != nil {
@ -310,7 +310,7 @@ func doTestPluginMountUnmount(t *testing.T, spec *volume.Spec) {
if path != "/tmp/fake/pods/poduid/volumes/kubernetes.io~fakeMounter/vol1" {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(volumePath); err != nil {

View File

@ -127,8 +127,8 @@ func (b flockerBuilder) GetPath() string {
return b.flocker.path
}
func (b flockerBuilder) SetUp() error {
return b.SetUpAt(b.flocker.datasetName)
func (b flockerBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.flocker.datasetName, fsGroup)
}
// newFlockerClient uses environment variables and pod attributes to return a
@ -168,7 +168,7 @@ control service:
need to update the Primary UUID for this volume.
5. Wait until the Primary UUID was updated or timeout.
*/
func (b flockerBuilder) SetUpAt(dir string) error {
func (b flockerBuilder) SetUpAt(dir string, fsGroup *int64) error {
if volumeutil.IsReady(b.getMetaDir()) {
return nil
}

View File

@ -211,6 +211,6 @@ func TestSetUpAtInternal(t *testing.T) {
b := flockerBuilder{flocker: &flocker{pod: pod, plugin: plug.(*flockerPlugin)}}
b.client = newMockFlockerClient("dataset-id", "primary-uid", mockPath)
assert.NoError(b.SetUpAt(dir))
assert.NoError(b.SetUpAt(dir, nil))
assert.Equal(expectedPath, b.flocker.path)
}

View File

@ -219,12 +219,12 @@ func (b *gcePersistentDiskBuilder) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func (b *gcePersistentDiskBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *gcePersistentDiskBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
// SetUpAt attaches the disk and bind mounts to the volume path.
func (b *gcePersistentDiskBuilder) SetUpAt(dir string) error {
func (b *gcePersistentDiskBuilder) SetUpAt(dir string, fsGroup *int64) error {
// TODO: handle failed mounts here.
notMnt, err := b.mounter.IsLikelyNotMountPoint(dir)
glog.V(4).Infof("PersistentDisk set up: %s %v %v", dir, !notMnt, err)

View File

@ -162,7 +162,7 @@ func TestPlugin(t *testing.T) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {

View File

@ -124,8 +124,8 @@ func (b *gitRepoVolumeBuilder) GetAttributes() volume.Attributes {
}
// SetUp creates new directory and clones a git repo.
func (b *gitRepoVolumeBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *gitRepoVolumeBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
// This is the spec for the volume that this plugin wraps.
@ -134,7 +134,7 @@ var wrappedVolumeSpec = &volume.Spec{
}
// SetUpAt creates new directory and clones a git repo.
func (b *gitRepoVolumeBuilder) SetUpAt(dir string) error {
func (b *gitRepoVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
if volumeutil.IsReady(b.getMetaDir()) {
return nil
}
@ -144,7 +144,7 @@ func (b *gitRepoVolumeBuilder) SetUpAt(dir string) error {
if err != nil {
return err
}
if err := wrapped.SetUpAt(dir); err != nil {
if err := wrapped.SetUpAt(dir, fsGroup); err != nil {
return err
}

View File

@ -335,7 +335,7 @@ func doTestSetUp(scenario struct {
g := builder.(*gitRepoVolumeBuilder)
g.exec = &fake
g.SetUp()
g.SetUp(nil)
if fake.CommandCalls != len(expecteds) {
allErrs = append(allErrs,

View File

@ -166,11 +166,11 @@ func (b *glusterfsBuilder) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func (b *glusterfsBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *glusterfsBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
func (b *glusterfsBuilder) SetUpAt(dir string) error {
func (b *glusterfsBuilder) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := b.mounter.IsLikelyNotMountPoint(dir)
glog.V(4).Infof("glusterfs: mount set up: %s %v %v", dir, !notMnt, err)
if err != nil && !os.IsNotExist(err) {

View File

@ -105,7 +105,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if path != "/tmp/fake/pods/poduid/volumes/kubernetes.io~glusterfs/vol1" {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(volumePath); err != nil {

View File

@ -186,12 +186,12 @@ func (b *hostPathBuilder) GetAttributes() volume.Attributes {
}
// SetUp does nothing.
func (b *hostPathBuilder) SetUp() error {
func (b *hostPathBuilder) SetUp(fsGroup *int64) error {
return nil
}
// SetUpAt does not make sense for host paths - probably programmer error.
func (b *hostPathBuilder) SetUpAt(dir string) error {
func (b *hostPathBuilder) SetUpAt(dir string, fsGroup *int64) error {
return fmt.Errorf("SetUpAt() does not make sense for host paths")
}

View File

@ -211,7 +211,7 @@ func TestPlugin(t *testing.T) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}

View File

@ -175,11 +175,11 @@ func (b *iscsiDiskBuilder) GetAttributes() volume.Attributes {
}
}
func (b *iscsiDiskBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *iscsiDiskBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
func (b *iscsiDiskBuilder) SetUpAt(dir string) error {
func (b *iscsiDiskBuilder) SetUpAt(dir string, fsGroup *int64) error {
// diskSetUp checks mountpoints and prevent repeated calls
err := diskSetUp(b.manager, *b, dir, b.mounter)
if err != nil {

View File

@ -121,7 +121,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {

View File

@ -159,11 +159,11 @@ func (b *nfsBuilder) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func (b *nfsBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *nfsBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
func (b *nfsBuilder) SetUpAt(dir string) error {
func (b *nfsBuilder) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := b.mounter.IsLikelyNotMountPoint(dir)
glog.V(4).Infof("NFS mount set up: %s %v %v", dir, !notMnt, err)
if err != nil && !os.IsNotExist(err) {

View File

@ -134,7 +134,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if path != "/tmp/fake/pods/poduid/volumes/kubernetes.io~nfs/vol1" {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(volumePath); err != nil {

View File

@ -203,11 +203,11 @@ func (b *rbd) GetAttributes() volume.Attributes {
}
}
func (b *rbdBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *rbdBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
func (b *rbdBuilder) SetUpAt(dir string) error {
func (b *rbdBuilder) SetUpAt(dir string, fsGroup *int64) error {
// diskSetUp checks mountpoints and prevent repeated calls
err := diskSetUp(b.manager, *b, dir, b.mounter)
if err != nil {

View File

@ -88,7 +88,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
t.Errorf("Got unexpected path: %s", path)
}
if err := builder.SetUp(); err != nil {
if err := builder.SetUp(nil); err != nil {
t.Errorf("Expected success, got: %v", err)
}
if _, err := os.Stat(path); err != nil {

View File

@ -107,8 +107,8 @@ func (sv *secretVolume) GetAttributes() volume.Attributes {
SupportsSELinux: true,
}
}
func (b *secretVolumeBuilder) SetUp() error {
return b.SetUpAt(b.GetPath())
func (b *secretVolumeBuilder) SetUp(fsGroup *int64) error {
return b.SetUpAt(b.GetPath(), fsGroup)
}
// This is the spec for the volume that this plugin wraps.
@ -120,7 +120,7 @@ func (b *secretVolumeBuilder) getMetaDir() string {
return path.Join(b.plugin.host.GetPodPluginDir(b.podUID, util.EscapeQualifiedNameForDisk(secretPluginName)), b.volName)
}
func (b *secretVolumeBuilder) SetUpAt(dir string) error {
func (b *secretVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
notMnt, err := b.mounter.IsLikelyNotMountPoint(dir)
// Getting an os.IsNotExist err from is a contingency; the directory
// may not exist yet, in which case, setup should run.
@ -141,7 +141,7 @@ func (b *secretVolumeBuilder) SetUpAt(dir string) error {
if err != nil {
return err
}
if err := wrapped.SetUpAt(dir); err != nil {
if err := wrapped.SetUpAt(dir, fsGroup); err != nil {
return err
}

View File

@ -98,7 +98,7 @@ func TestPlugin(t *testing.T) {
t.Errorf("Got unexpected path: %s", volumePath)
}
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -156,7 +156,7 @@ func TestPluginIdempotent(t *testing.T) {
}
volumePath := builder.GetPath()
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}
@ -214,7 +214,7 @@ func TestPluginReboot(t *testing.T) {
t.Errorf("Got unexpected path: %s", volumePath)
}
err = builder.SetUp()
err = builder.SetUp(nil)
if err != nil {
t.Errorf("Failed to setup volume: %v", err)
}

View File

@ -183,11 +183,11 @@ func (_ *FakeVolume) GetAttributes() Attributes {
}
}
func (fv *FakeVolume) SetUp() error {
return fv.SetUpAt(fv.GetPath())
func (fv *FakeVolume) SetUp(fsGroup *int64) error {
return fv.SetUpAt(fv.GetPath(), fsGroup)
}
func (fv *FakeVolume) SetUpAt(dir string) error {
func (fv *FakeVolume) SetUpAt(dir string, fsGroup *int64) error {
return os.MkdirAll(dir, 0750)
}

View File

@ -70,14 +70,19 @@ type Attributes struct {
type Builder interface {
// Uses Interface to provide the path for Docker binds.
Volume
// SetUp prepares and mounts/unpacks the volume to a self-determined
// directory path. This may be called more than once, so
// SetUp prepares and mounts/unpacks the volume to a
// self-determined directory path. The mount point and its
// content should be owned by 'fsGroup' so that it can be
// accessed by the pod. This may be called more than once, so
// implementations must be idempotent.
SetUp() error
// SetUpAt prepares and mounts/unpacks the volume to the specified
// directory path, which may or may not exist yet. This may be called
// more than once, so implementations must be idempotent.
SetUpAt(dir string) error
SetUp(fsGroup *int64) error
// SetUpAt prepares and mounts/unpacks the volume to the
// specified directory path, which may or may not exist yet.
// The mount point and its content should be owned by
// 'fsGroup' so that it can be accessed by the pod. This may
// be called more than once, so implementations must be
// idempotent.
SetUpAt(dir string, sGroup *int64) error
// GetAttributes returns the attributes of the builder.
GetAttributes() Attributes
}