Call SetVolumeOwnership from volume plugins
This commit is contained in:
		| @@ -291,6 +291,10 @@ func (b *awsElasticBlockStoreBuilder) SetUpAt(dir string, fsGroup *int64) error | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !b.readOnly { | ||||||
|  | 		volume.SetVolumeOwnership(b, fsGroup) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -284,6 +284,10 @@ func (b *cinderVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !b.readOnly { | ||||||
|  | 		volume.SetVolumeOwnership(b, fsGroup) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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) | 	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 | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -190,6 +190,8 @@ func (ed *emptyDir) SetUpAt(dir string, fsGroup *int64) error { | |||||||
| 		err = fmt.Errorf("unknown storage medium %q", ed.medium) | 		err = fmt.Errorf("unknown storage medium %q", ed.medium) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	volume.SetVolumeOwnership(ed, fsGroup) | ||||||
|  |  | ||||||
| 	if err == nil { | 	if err == nil { | ||||||
| 		volumeutil.SetReady(ed.getMetaDir()) | 		volumeutil.SetReady(ed.getMetaDir()) | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ import ( | |||||||
|  |  | ||||||
| 	"github.com/golang/glog" | 	"github.com/golang/glog" | ||||||
| 	"k8s.io/kubernetes/pkg/util/mount" | 	"k8s.io/kubernetes/pkg/util/mount" | ||||||
|  | 	"k8s.io/kubernetes/pkg/volume" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Abstract interface to disk operations. | // Abstract interface to disk operations. | ||||||
| @@ -33,7 +34,7 @@ type diskManager interface { | |||||||
| } | } | ||||||
|  |  | ||||||
| // utility to mount a disk based filesystem | // 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) | 	globalPDPath := manager.MakeGlobalPDName(*b.fcDisk) | ||||||
| 	// TODO: handle failed mounts here. | 	// TODO: handle failed mounts here. | ||||||
| 	noMnt, err := mounter.IsLikelyNotMountPoint(volPath) | 	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) | 		glog.Errorf("failed to bind mount:%s", globalPDPath) | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !b.readOnly { | ||||||
|  | 		volume.SetVolumeOwnership(&b, fsGroup) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -182,7 +182,7 @@ func (b *fcDiskBuilder) SetUp(fsGroup *int64) error { | |||||||
|  |  | ||||||
| func (b *fcDiskBuilder) SetUpAt(dir string, fsGroup *int64) error { | func (b *fcDiskBuilder) SetUpAt(dir string, fsGroup *int64) error { | ||||||
| 	// diskSetUp checks mountpoints and prevent repeated calls | 	// 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 { | 	if err != nil { | ||||||
| 		glog.Errorf("fc: failed to setup") | 		glog.Errorf("fc: failed to setup") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -280,6 +280,10 @@ func (b *gcePersistentDiskBuilder) SetUpAt(dir string, fsGroup *int64) error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !b.readOnly { | ||||||
|  | 		volume.SetVolumeOwnership(b, fsGroup) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,6 +21,7 @@ import ( | |||||||
|  |  | ||||||
| 	"github.com/golang/glog" | 	"github.com/golang/glog" | ||||||
| 	"k8s.io/kubernetes/pkg/util/mount" | 	"k8s.io/kubernetes/pkg/util/mount" | ||||||
|  | 	"k8s.io/kubernetes/pkg/volume" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Abstract interface to disk operations. | // Abstract interface to disk operations. | ||||||
| @@ -33,7 +34,7 @@ type diskManager interface { | |||||||
| } | } | ||||||
|  |  | ||||||
| // utility to mount a disk based filesystem | // 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) | 	globalPDPath := manager.MakeGlobalPDName(*b.iscsiDisk) | ||||||
| 	// TODO: handle failed mounts here. | 	// TODO: handle failed mounts here. | ||||||
| 	notMnt, err := mounter.IsLikelyNotMountPoint(volPath) | 	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) | 		glog.Errorf("failed to bind mount:%s", globalPDPath) | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !b.readOnly { | ||||||
|  | 		volume.SetVolumeOwnership(&b, fsGroup) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -181,7 +181,7 @@ func (b *iscsiDiskBuilder) SetUp(fsGroup *int64) error { | |||||||
|  |  | ||||||
| func (b *iscsiDiskBuilder) SetUpAt(dir string, fsGroup *int64) error { | func (b *iscsiDiskBuilder) SetUpAt(dir string, fsGroup *int64) error { | ||||||
| 	// diskSetUp checks mountpoints and prevent repeated calls | 	// 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 { | 	if err != nil { | ||||||
| 		glog.Errorf("iscsi: failed to setup") | 		glog.Errorf("iscsi: failed to setup") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -27,6 +27,7 @@ import ( | |||||||
|  |  | ||||||
| 	"github.com/golang/glog" | 	"github.com/golang/glog" | ||||||
| 	"k8s.io/kubernetes/pkg/util/mount" | 	"k8s.io/kubernetes/pkg/util/mount" | ||||||
|  | 	"k8s.io/kubernetes/pkg/volume" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // Abstract interface to disk operations. | // Abstract interface to disk operations. | ||||||
| @@ -39,7 +40,7 @@ type diskManager interface { | |||||||
| } | } | ||||||
|  |  | ||||||
| // utility to mount a disk based filesystem | // 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) | 	globalPDPath := manager.MakeGlobalPDName(*b.rbd) | ||||||
| 	// TODO: handle failed mounts here. | 	// TODO: handle failed mounts here. | ||||||
| 	notMnt, err := mounter.IsLikelyNotMountPoint(volPath) | 	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) | 		glog.Errorf("failed to bind mount:%s", globalPDPath) | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if !b.ReadOnly { | ||||||
|  | 		volume.SetVolumeOwnership(&b, fsGroup) | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -209,7 +209,7 @@ func (b *rbdBuilder) SetUp(fsGroup *int64) error { | |||||||
|  |  | ||||||
| func (b *rbdBuilder) SetUpAt(dir string, fsGroup *int64) error { | func (b *rbdBuilder) SetUpAt(dir string, fsGroup *int64) error { | ||||||
| 	// diskSetUp checks mountpoints and prevent repeated calls | 	// 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 { | 	if err != nil { | ||||||
| 		glog.Errorf("rbd: failed to setup") | 		glog.Errorf("rbd: failed to setup") | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -173,6 +173,8 @@ func (b *secretVolumeBuilder) SetUpAt(dir string, fsGroup *int64) error { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	volume.SetVolumeOwnership(b, fsGroup) | ||||||
|  |  | ||||||
| 	volumeutil.SetReady(b.getMetaDir()) | 	volumeutil.SetReady(b.getMetaDir()) | ||||||
|  |  | ||||||
| 	return nil | 	return nil | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sami Wagiaalla
					Sami Wagiaalla