Call SetVolumeOwnership from volume plugins

pull/6/head
Sami Wagiaalla 2015-12-18 13:57:25 -05:00
parent 125295ba40
commit 4ac151321a
12 changed files with 43 additions and 6 deletions

View File

@ -291,6 +291,10 @@ func (b *awsElasticBlockStoreBuilder) SetUpAt(dir string, fsGroup *int64) error
return err
}
if !b.readOnly {
volume.SetVolumeOwnership(b, fsGroup)
}
return nil
}

View File

@ -284,6 +284,10 @@ func (b *cinderVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
return err
}
if !b.readOnly {
volume.SetVolumeOwnership(b, fsGroup)
}
return nil
}

View File

@ -157,6 +157,9 @@ func (b *downwardAPIVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
}
glog.V(3).Infof("Data dumped for downwardAPI volume %v for pod %v/%v", b.volName, b.pod.Namespace, b.pod.Name)
volume.SetVolumeOwnership(b, fsGroup)
return nil
}

View File

@ -190,6 +190,8 @@ func (ed *emptyDir) SetUpAt(dir string, fsGroup *int64) error {
err = fmt.Errorf("unknown storage medium %q", ed.medium)
}
volume.SetVolumeOwnership(ed, fsGroup)
if err == nil {
volumeutil.SetReady(ed.getMetaDir())
}

View File

@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
)
// Abstract interface to disk operations.
@ -33,7 +34,7 @@ type diskManager interface {
}
// utility to mount a disk based filesystem
func diskSetUp(manager diskManager, b fcDiskBuilder, volPath string, mounter mount.Interface) error {
func diskSetUp(manager diskManager, b fcDiskBuilder, volPath string, mounter mount.Interface, fsGroup *int64) error {
globalPDPath := manager.MakeGlobalPDName(*b.fcDisk)
// TODO: handle failed mounts here.
noMnt, err := mounter.IsLikelyNotMountPoint(volPath)
@ -64,6 +65,11 @@ func diskSetUp(manager diskManager, b fcDiskBuilder, volPath string, mounter mou
glog.Errorf("failed to bind mount:%s", globalPDPath)
return err
}
if !b.readOnly {
volume.SetVolumeOwnership(&b, fsGroup)
}
return nil
}

View File

@ -182,7 +182,7 @@ func (b *fcDiskBuilder) SetUp(fsGroup *int64) 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)
err := diskSetUp(b.manager, *b, dir, b.mounter, fsGroup)
if err != nil {
glog.Errorf("fc: failed to setup")
}

View File

@ -280,6 +280,10 @@ func (b *gcePersistentDiskBuilder) SetUpAt(dir string, fsGroup *int64) error {
return err
}
if !b.readOnly {
volume.SetVolumeOwnership(b, fsGroup)
}
return nil
}

View File

@ -21,6 +21,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
)
// Abstract interface to disk operations.
@ -33,7 +34,7 @@ type diskManager interface {
}
// utility to mount a disk based filesystem
func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter mount.Interface) error {
func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter mount.Interface, fsGroup *int64) error {
globalPDPath := manager.MakeGlobalPDName(*b.iscsiDisk)
// TODO: handle failed mounts here.
notMnt, err := mounter.IsLikelyNotMountPoint(volPath)
@ -64,6 +65,11 @@ func diskSetUp(manager diskManager, b iscsiDiskBuilder, volPath string, mounter
glog.Errorf("failed to bind mount:%s", globalPDPath)
return err
}
if !b.readOnly {
volume.SetVolumeOwnership(&b, fsGroup)
}
return nil
}

View File

@ -181,7 +181,7 @@ func (b *iscsiDiskBuilder) SetUp(fsGroup *int64) 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)
err := diskSetUp(b.manager, *b, dir, b.mounter, fsGroup)
if err != nil {
glog.Errorf("iscsi: failed to setup")
}

View File

@ -27,6 +27,7 @@ import (
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
)
// Abstract interface to disk operations.
@ -39,7 +40,7 @@ type diskManager interface {
}
// utility to mount a disk based filesystem
func diskSetUp(manager diskManager, b rbdBuilder, volPath string, mounter mount.Interface) error {
func diskSetUp(manager diskManager, b rbdBuilder, volPath string, mounter mount.Interface, fsGroup *int64) error {
globalPDPath := manager.MakeGlobalPDName(*b.rbd)
// TODO: handle failed mounts here.
notMnt, err := mounter.IsLikelyNotMountPoint(volPath)
@ -70,6 +71,11 @@ func diskSetUp(manager diskManager, b rbdBuilder, volPath string, mounter mount.
glog.Errorf("failed to bind mount:%s", globalPDPath)
return err
}
if !b.ReadOnly {
volume.SetVolumeOwnership(&b, fsGroup)
}
return nil
}

View File

@ -209,7 +209,7 @@ func (b *rbdBuilder) SetUp(fsGroup *int64) 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)
err := diskSetUp(b.manager, *b, dir, b.mounter, fsGroup)
if err != nil {
glog.Errorf("rbd: failed to setup")
}

View File

@ -173,6 +173,8 @@ func (b *secretVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error {
}
}
volume.SetVolumeOwnership(b, fsGroup)
volumeutil.SetReady(b.getMetaDir())
return nil