Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
5b97b286
Commit
5b97b286
authored
Nov 19, 2018
by
Robert Krawitz
Committed by
Robert Krawitz
May 29, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change fsGroup to mounterArgs in volume.SetUp() to allow for future extension.
parent
472b9011
Hide whitespace changes
Inline
Side-by-side
Showing
61 changed files
with
221 additions
and
189 deletions
+221
-189
kubelet_volumes_test.go
pkg/kubelet/kubelet_volumes_test.go
+2
-2
aws_ebs.go
pkg/volume/awsebs/aws_ebs.go
+4
-4
aws_ebs_test.go
pkg/volume/awsebs/aws_ebs_test.go
+2
-2
azure_mounter.go
pkg/volume/azure_dd/azure_mounter.go
+4
-4
azure_file.go
pkg/volume/azure_file/azure_file.go
+4
-4
azure_file_test.go
pkg/volume/azure_file/azure_file_test.go
+1
-1
cephfs.go
pkg/volume/cephfs/cephfs.go
+3
-3
cephfs_test.go
pkg/volume/cephfs/cephfs_test.go
+1
-1
cinder.go
pkg/volume/cinder/cinder.go
+4
-4
cinder_test.go
pkg/volume/cinder/cinder_test.go
+1
-1
configmap.go
pkg/volume/configmap/configmap.go
+6
-6
configmap_test.go
pkg/volume/configmap/configmap_test.go
+20
-10
csi_mounter.go
pkg/volume/csi/csi_mounter.go
+4
-4
csi_mounter_test.go
pkg/volume/csi/csi_mounter_test.go
+8
-4
csi_test.go
pkg/volume/csi/csi_test.go
+3
-1
downwardapi.go
pkg/volume/downwardapi/downwardapi.go
+6
-6
downwardapi_test.go
pkg/volume/downwardapi/downwardapi_test.go
+2
-2
empty_dir.go
pkg/volume/emptydir/empty_dir.go
+4
-4
empty_dir_test.go
pkg/volume/emptydir/empty_dir_test.go
+1
-1
fc.go
pkg/volume/fc/fc.go
+4
-4
fc_test.go
pkg/volume/fc/fc_test.go
+1
-1
driver-call.go
pkg/volume/flexvolume/driver-call.go
+1
-1
mounter-defaults.go
pkg/volume/flexvolume/mounter-defaults.go
+1
-1
mounter.go
pkg/volume/flexvolume/mounter.go
+7
-7
mounter_test.go
pkg/volume/flexvolume/mounter_test.go
+8
-5
flocker.go
pkg/volume/flocker/flocker.go
+4
-4
gce_pd.go
pkg/volume/gcepd/gce_pd.go
+4
-4
gce_pd_test.go
pkg/volume/gcepd/gce_pd_test.go
+2
-2
git_repo.go
pkg/volume/git_repo/git_repo.go
+5
-5
git_repo_test.go
pkg/volume/git_repo/git_repo_test.go
+1
-1
glusterfs.go
pkg/volume/glusterfs/glusterfs.go
+3
-3
glusterfs_test.go
pkg/volume/glusterfs/glusterfs_test.go
+1
-1
host_path.go
pkg/volume/hostpath/host_path.go
+2
-2
host_path_test.go
pkg/volume/hostpath/host_path_test.go
+2
-2
iscsi.go
pkg/volume/iscsi/iscsi.go
+4
-4
iscsi_test.go
pkg/volume/iscsi/iscsi_test.go
+1
-1
local.go
pkg/volume/local/local.go
+6
-6
local_test.go
pkg/volume/local/local_test.go
+6
-4
nfs.go
pkg/volume/nfs/nfs.go
+3
-3
nfs_test.go
pkg/volume/nfs/nfs_test.go
+1
-1
photon_pd.go
pkg/volume/photon_pd/photon_pd.go
+3
-3
photon_pd_test.go
pkg/volume/photon_pd/photon_pd_test.go
+1
-1
portworx.go
pkg/volume/portworx/portworx.go
+4
-4
portworx_test.go
pkg/volume/portworx/portworx_test.go
+1
-1
projected.go
pkg/volume/projected/projected.go
+6
-6
projected_test.go
pkg/volume/projected/projected_test.go
+6
-5
quobyte.go
pkg/volume/quobyte/quobyte.go
+3
-3
quobyte_test.go
pkg/volume/quobyte/quobyte_test.go
+1
-1
rbd.go
pkg/volume/rbd/rbd.go
+4
-4
rbd_test.go
pkg/volume/rbd/rbd_test.go
+1
-1
sio_volume.go
pkg/volume/scaleio/sio_volume.go
+5
-5
sio_volume_test.go
pkg/volume/scaleio/sio_volume_test.go
+2
-2
secret.go
pkg/volume/secret/secret.go
+6
-6
secret_test.go
pkg/volume/secret/secret_test.go
+6
-5
storageos.go
pkg/volume/storageos/storageos.go
+4
-4
storageos_test.go
pkg/volume/storageos/storageos_test.go
+1
-1
testing.go
pkg/volume/testing/testing.go
+3
-3
operation_generator.go
pkg/volume/util/operationexecutor/operation_generator.go
+4
-1
volume.go
pkg/volume/volume.go
+8
-2
vsphere_volume.go
pkg/volume/vsphere_volume/vsphere_volume.go
+4
-4
vsphere_volume_test.go
pkg/volume/vsphere_volume/vsphere_volume_test.go
+1
-1
No files found.
pkg/kubelet/kubelet_volumes_test.go
View file @
5b97b286
...
...
@@ -439,11 +439,11 @@ func (f *stubVolume) CanMount() error {
return
nil
}
func
(
f
*
stubVolume
)
SetUp
(
fsGroup
*
int64
)
error
{
func
(
f
*
stubVolume
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
nil
}
func
(
f
*
stubVolume
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
f
*
stubVolume
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
return
nil
}
...
...
pkg/volume/awsebs/aws_ebs.go
View file @
5b97b286
...
...
@@ -382,12 +382,12 @@ func (b *awsElasticBlockStoreMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
awsElasticBlockStoreMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
awsElasticBlockStoreMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUpAt attaches the disk and bind mounts to the volume path.
func
(
b
*
awsElasticBlockStoreMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
awsElasticBlockStoreMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// TODO: handle failed mounts here.
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
V
(
4
)
.
Infof
(
"PersistentDisk set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
...
...
@@ -440,7 +440,7 @@ func (b *awsElasticBlockStoreMounter) SetUpAt(dir string, fsGroup *int64) error
}
if
!
b
.
readOnly
{
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
4
)
.
Infof
(
"Successfully mounted %s"
,
dir
)
...
...
pkg/volume/awsebs/aws_ebs_test.go
View file @
5b97b286
...
...
@@ -136,7 +136,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
@@ -367,7 +367,7 @@ func TestMountOptions(t *testing.T) {
t
.
Errorf
(
"Got a nil Mounter"
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
mountOptions
:=
fakeMounter
.
MountPoints
[
0
]
.
Opts
...
...
pkg/volume/azure_dd/azure_mounter.go
View file @
5b97b286
...
...
@@ -62,15 +62,15 @@ func (m *azureDiskMounter) CanMount() error {
return
nil
}
func
(
m
*
azureDiskMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
m
.
SetUpAt
(
m
.
GetPath
(),
fsGroup
)
func
(
m
*
azureDiskMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
m
.
SetUpAt
(
m
.
GetPath
(),
mounterArgs
)
}
func
(
m
*
azureDiskMounter
)
GetPath
()
string
{
return
getPath
(
m
.
dataDisk
.
podUID
,
m
.
dataDisk
.
volumeName
,
m
.
plugin
.
host
)
}
func
(
m
*
azureDiskMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
m
*
azureDiskMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
mounter
:=
m
.
plugin
.
host
.
GetMounter
(
m
.
plugin
.
GetPluginName
())
volumeSource
,
_
,
err
:=
getVolumeSource
(
m
.
spec
)
...
...
@@ -161,7 +161,7 @@ func (m *azureDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
}
if
volumeSource
.
ReadOnly
==
nil
||
!*
volumeSource
.
ReadOnly
{
volume
.
SetVolumeOwnership
(
m
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
m
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
2
)
.
Infof
(
"azureDisk - successfully mounted disk %s on %s"
,
diskName
,
dir
)
...
...
pkg/volume/azure_file/azure_file.go
View file @
5b97b286
...
...
@@ -236,11 +236,11 @@ func (b *azureFileMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
azureFileMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
azureFileMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
azureFileMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
azureFileMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
V
(
4
)
.
Infof
(
"AzureFile mount set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
...
@@ -283,7 +283,7 @@ func (b *azureFileMounter) SetUpAt(dir string, fsGroup *int64) error {
options
=
append
(
options
,
"ro"
)
}
mountOptions
=
volutil
.
JoinMountOptions
(
b
.
mountOptions
,
options
)
mountOptions
=
appendDefaultMountOptions
(
mountOptions
,
f
sGroup
)
mountOptions
=
appendDefaultMountOptions
(
mountOptions
,
mounterArgs
.
F
sGroup
)
}
err
=
b
.
mounter
.
Mount
(
source
,
dir
,
"cifs"
,
mountOptions
)
...
...
pkg/volume/azure_file/azure_file_test.go
View file @
5b97b286
...
...
@@ -155,7 +155,7 @@ func testPlugin(t *testing.T, tmpDir string, volumeHost volume.VolumeHost) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/cephfs/cephfs.go
View file @
5b97b286
...
...
@@ -222,12 +222,12 @@ func (cephfsVolume *cephfsMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
cephfsVolume
*
cephfsMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
cephfsVolume
.
SetUpAt
(
cephfsVolume
.
GetPath
(),
fsGroup
)
func
(
cephfsVolume
*
cephfsMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
cephfsVolume
.
SetUpAt
(
cephfsVolume
.
GetPath
(),
mounterArgs
)
}
// SetUpAt attaches the disk and bind mounts to the volume path.
func
(
cephfsVolume
*
cephfsMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
cephfsVolume
*
cephfsMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
notMnt
,
err
:=
cephfsVolume
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
V
(
4
)
.
Infof
(
"CephFS mount set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
...
pkg/volume/cephfs/cephfs_test.go
View file @
5b97b286
...
...
@@ -87,7 +87,7 @@ func TestPlugin(t *testing.T) {
if
volumePath
!=
volpath
{
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
volumePath
);
err
!=
nil
{
...
...
pkg/volume/cinder/cinder.go
View file @
5b97b286
...
...
@@ -377,12 +377,12 @@ func (b *cinderVolumeMounter) CanMount() error {
return
nil
}
func
(
b
*
cinderVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
cinderVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUp bind mounts to the volume path.
func
(
b
*
cinderVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
cinderVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
5
)
.
Infof
(
"Cinder SetUp %s to %s"
,
b
.
pdName
,
dir
)
b
.
plugin
.
volumeLocks
.
LockKey
(
b
.
pdName
)
...
...
@@ -442,7 +442,7 @@ func (b *cinderVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
if
!
b
.
readOnly
{
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
3
)
.
Infof
(
"Cinder volume %s mounted to %s"
,
b
.
pdName
,
dir
)
...
...
pkg/volume/cinder/cinder_test.go
View file @
5b97b286
...
...
@@ -166,7 +166,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/configmap/configmap.go
View file @
5b97b286
...
...
@@ -183,11 +183,11 @@ func (b *configMapVolumeMounter) CanMount() error {
return
nil
}
func
(
b
*
configMapVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
configMapVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
configMapVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
configMapVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
b
.
volName
,
b
.
pod
.
UID
,
dir
)
// Wrap EmptyDir, let it do the setup.
...
...
@@ -224,7 +224,7 @@ func (b *configMapVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
setupSuccess
:=
false
if
err
:=
wrapped
.
SetUpAt
(
dir
,
fsGroup
);
err
!=
nil
{
if
err
:=
wrapped
.
SetUpAt
(
dir
,
mounterArgs
);
err
!=
nil
{
return
err
}
if
err
:=
volumeutil
.
MakeNestedMountpoints
(
b
.
volName
,
dir
,
b
.
pod
);
err
!=
nil
{
...
...
@@ -259,9 +259,9 @@ func (b *configMapVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
err
=
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
err
=
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
f
sGroup
)
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
mounterArgs
.
F
sGroup
)
return
err
}
setupSuccess
=
true
...
...
pkg/volume/configmap/configmap_test.go
View file @
5b97b286
...
...
@@ -365,8 +365,10 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
fsGroup
:=
int64
(
1001
)
err
=
mounter
.
SetUp
(
&
fsGroup
)
var
mounterArgs
volume
.
MounterArgs
group
:=
int64
(
1001
)
mounterArgs
.
FsGroup
=
&
group
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -423,8 +425,10 @@ func TestPluginReboot(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
fsGroup
:=
int64
(
1001
)
err
=
mounter
.
SetUp
(
&
fsGroup
)
var
mounterArgs
volume
.
MounterArgs
group
:=
int64
(
1001
)
mounterArgs
.
FsGroup
=
&
group
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -485,8 +489,10 @@ func TestPluginOptional(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
fsGroup
:=
int64
(
1001
)
err
=
mounter
.
SetUp
(
&
fsGroup
)
var
mounterArgs
volume
.
MounterArgs
group
:=
int64
(
1001
)
mounterArgs
.
FsGroup
=
&
group
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -582,8 +588,10 @@ func TestPluginKeysOptional(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
fsGroup
:=
int64
(
1001
)
err
=
mounter
.
SetUp
(
&
fsGroup
)
var
mounterArgs
volume
.
MounterArgs
group
:=
int64
(
1001
)
mounterArgs
.
FsGroup
=
&
group
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -660,8 +668,10 @@ func TestInvalidConfigMapSetup(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
fsGroup
:=
int64
(
1001
)
err
=
mounter
.
SetUp
(
&
fsGroup
)
var
mounterArgs
volume
.
MounterArgs
group
:=
int64
(
1001
)
mounterArgs
.
FsGroup
=
&
group
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
==
nil
{
t
.
Errorf
(
"Expected setup to fail"
)
}
...
...
pkg/volume/csi/csi_mounter.go
View file @
5b97b286
...
...
@@ -93,11 +93,11 @@ func (c *csiMountMgr) CanMount() error {
return
nil
}
func
(
c
*
csiMountMgr
)
SetUp
(
fsGroup
*
int64
)
error
{
return
c
.
SetUpAt
(
c
.
GetPath
(),
fsGroup
)
func
(
c
*
csiMountMgr
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
c
.
SetUpAt
(
c
.
GetPath
(),
mounterArgs
)
}
func
(
c
*
csiMountMgr
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
c
*
csiMountMgr
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
4
)
.
Infof
(
log
(
"Mounter.SetUpAt(%s)"
,
dir
))
mounted
,
err
:=
isDirMounted
(
c
.
plugin
,
dir
)
...
...
@@ -268,7 +268,7 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {
// if fstype is "", then skip fsgroup (could be indication of non-block filesystem)
// if fstype is provided and pv.AccessMode == ReadWriteOnly, then apply fsgroup
err
=
c
.
applyFSGroup
(
fsType
,
f
sGroup
)
err
=
c
.
applyFSGroup
(
fsType
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
// attempt to rollback mount.
fsGrpErr
:=
fmt
.
Errorf
(
"applyFSGroup failed for vol %s: %v"
,
c
.
volumeID
,
err
)
...
...
pkg/volume/csi/csi_mounter_test.go
View file @
5b97b286
...
...
@@ -203,8 +203,10 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) {
}
// Mounter.SetUp()
var
mounterArgs
volume
.
MounterArgs
fsGroup
:=
int64
(
2000
)
if
err
:=
csiMounter
.
SetUp
(
&
fsGroup
);
err
!=
nil
{
mounterArgs
.
FsGroup
=
&
fsGroup
if
err
:=
csiMounter
.
SetUp
(
mounterArgs
);
err
!=
nil
{
t
.
Fatalf
(
"mounter.Setup failed: %v"
,
err
)
}
...
...
@@ -344,7 +346,7 @@ func TestMounterSetUpSimple(t *testing.T) {
}
// Mounter.SetUp()
if
err
:=
csiMounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
csiMounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Fatalf
(
"mounter.Setup failed: %v"
,
err
)
}
...
...
@@ -475,7 +477,7 @@ func TestMounterSetUpWithInline(t *testing.T) {
}
// Mounter.SetUp()
if
err
:=
csiMounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
csiMounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Fatalf
(
"mounter.Setup failed: %v"
,
err
)
}
...
...
@@ -621,12 +623,14 @@ func TestMounterSetUpWithFSGroup(t *testing.T) {
}
// Mounter.SetUp()
var
mounterArgs
volume
.
MounterArgs
var
fsGroupPtr
*
int64
if
tc
.
setFsGroup
{
fsGroup
:=
tc
.
fsGroup
fsGroupPtr
=
&
fsGroup
}
if
err
:=
csiMounter
.
SetUp
(
fsGroupPtr
);
err
!=
nil
{
mounterArgs
.
FsGroup
=
fsGroupPtr
if
err
:=
csiMounter
.
SetUp
(
mounterArgs
);
err
!=
nil
{
t
.
Fatalf
(
"mounter.Setup failed: %v"
,
err
)
}
...
...
pkg/volume/csi/csi_test.go
View file @
5b97b286
...
...
@@ -268,7 +268,9 @@ func TestCSI_VolumeAll(t *testing.T) {
csiMounter
:=
mounter
.
(
*
csiMountMgr
)
csiMounter
.
csiClient
=
csiClient
if
err
:=
csiMounter
.
SetUp
(
fsGroup
);
err
!=
nil
{
var
mounterArgs
volume
.
MounterArgs
mounterArgs
.
FsGroup
=
fsGroup
if
err
:=
csiMounter
.
SetUp
(
mounterArgs
);
err
!=
nil
{
t
.
Fatalf
(
"csiTest.VolumeAll mounter.Setup(fsGroup) failed: %s"
,
err
)
}
t
.
Log
(
"csiTest.VolumeAll mounter.Setup(fsGroup) done OK"
)
...
...
pkg/volume/downwardapi/downwardapi.go
View file @
5b97b286
...
...
@@ -174,11 +174,11 @@ func (b *downwardAPIVolumeMounter) CanMount() error {
// 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
*
downwardAPIVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
downwardAPIVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
downwardAPIVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
downwardAPIVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
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
.
NewWrapperMounter
(
b
.
volName
,
wrappedVolumeSpec
(),
b
.
pod
,
*
b
.
opts
)
...
...
@@ -194,7 +194,7 @@ func (b *downwardAPIVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
setupSuccess
:=
false
if
err
:=
wrapped
.
SetUpAt
(
dir
,
fsGroup
);
err
!=
nil
{
if
err
:=
wrapped
.
SetUpAt
(
dir
,
mounterArgs
);
err
!=
nil
{
klog
.
Errorf
(
"Unable to setup downwardAPI volume %v for pod %v/%v: %s"
,
b
.
volName
,
b
.
pod
.
Namespace
,
b
.
pod
.
Name
,
err
.
Error
())
return
err
}
...
...
@@ -231,9 +231,9 @@ func (b *downwardAPIVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
err
=
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
err
=
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
f
sGroup
)
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
mounterArgs
.
F
sGroup
)
return
err
}
...
...
pkg/volume/downwardapi/downwardapi_test.go
View file @
5b97b286
...
...
@@ -253,7 +253,7 @@ func newDownwardAPITest(t *testing.T, name string, volumeFiles, podLabels, podAn
volumePath
:=
mounter
.
GetPath
()
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -380,7 +380,7 @@ func (step reSetUp) run(test *downwardAPITest) {
}
// now re-run Setup
if
err
=
test
.
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
=
test
.
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
test
.
t
.
Errorf
(
"Failed to re-setup volume: %v"
,
err
)
}
...
...
pkg/volume/emptydir/empty_dir.go
View file @
5b97b286
...
...
@@ -193,12 +193,12 @@ func (ed *emptyDir) CanMount() error {
}
// SetUp creates new directory.
func
(
ed
*
emptyDir
)
SetUp
(
fsGroup
*
int64
)
error
{
return
ed
.
SetUpAt
(
ed
.
GetPath
(),
fsGroup
)
func
(
ed
*
emptyDir
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
ed
.
SetUpAt
(
ed
.
GetPath
(),
mounterArgs
)
}
// SetUpAt creates new directory.
func
(
ed
*
emptyDir
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
ed
*
emptyDir
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
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.
...
...
@@ -229,7 +229,7 @@ func (ed *emptyDir) SetUpAt(dir string, fsGroup *int64) error {
err
=
fmt
.
Errorf
(
"unknown storage medium %q"
,
ed
.
medium
)
}
volume
.
SetVolumeOwnership
(
ed
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
ed
,
mounterArgs
.
F
sGroup
)
if
err
==
nil
{
volumeutil
.
SetReady
(
ed
.
getMetaDir
())
...
...
pkg/volume/emptydir/empty_dir_test.go
View file @
5b97b286
...
...
@@ -163,7 +163,7 @@ func doTestPlugin(t *testing.T, config pluginTestConfig) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volPath
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
...
...
pkg/volume/fc/fc.go
View file @
5b97b286
...
...
@@ -371,13 +371,13 @@ func (b *fcDiskMounter) CanMount() error {
return
nil
}
func
(
b
*
fcDiskMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
fcDiskMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
fcDiskMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
fcDiskMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// diskSetUp checks mountpoints and prevent repeated calls
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
f
sGroup
)
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"fc: failed to setup"
)
}
...
...
pkg/volume/fc/fc_test.go
View file @
5b97b286
...
...
@@ -179,7 +179,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
t
.
Errorf
(
"Unexpected path, expected %q, got: %q"
,
expectedPath
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/flexvolume/driver-call.go
View file @
5b97b286
...
...
@@ -51,7 +51,7 @@ const (
optionFSType
=
"kubernetes.io/fsType"
optionReadWrite
=
"kubernetes.io/readwrite"
optionKeySecret
=
"kubernetes.io/secret"
optionFSGroup
=
"kubernetes.io/
f
sGroup"
optionFSGroup
=
"kubernetes.io/
mounterArgs.F
sGroup"
optionMountsDir
=
"kubernetes.io/mountsDir"
optionPVorVolumeName
=
"kubernetes.io/pvOrVolumeName"
...
...
pkg/volume/flexvolume/mounter-defaults.go
View file @
5b97b286
...
...
@@ -26,7 +26,7 @@ type mounterDefaults flexVolumeMounter
// SetUpAt is part of the volume.Mounter interface.
// This implementation relies on the attacher's device mount path and does a bind mount to dir.
func
(
f
*
mounterDefaults
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
f
*
mounterDefaults
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
Warning
(
logPrefix
(
f
.
plugin
),
"using default SetUpAt to "
,
dir
)
src
,
err
:=
f
.
plugin
.
getDeviceMountPath
(
f
.
spec
)
...
...
pkg/volume/flexvolume/mounter.go
View file @
5b97b286
...
...
@@ -39,12 +39,12 @@ var _ volume.Mounter = &flexVolumeMounter{}
// Mounter interface
// SetUp creates new directory.
func
(
f
*
flexVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
f
.
SetUpAt
(
f
.
GetPath
(),
fsGroup
)
func
(
f
*
flexVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
f
.
SetUpAt
(
f
.
GetPath
(),
mounterArgs
)
}
// SetUpAt creates new directory.
func
(
f
*
flexVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
f
*
flexVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// Mount only once.
alreadyMounted
,
err
:=
prepareForMount
(
f
.
mounter
,
dir
)
if
err
!=
nil
{
...
...
@@ -75,15 +75,15 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
// Implicit parameters
if
f
sGroup
!=
nil
{
extraOptions
[
optionFSGroup
]
=
strconv
.
FormatInt
(
int64
(
*
f
sGroup
),
10
)
if
mounterArgs
.
F
sGroup
!=
nil
{
extraOptions
[
optionFSGroup
]
=
strconv
.
FormatInt
(
int64
(
*
mounterArgs
.
F
sGroup
),
10
)
}
call
.
AppendSpec
(
f
.
spec
,
f
.
plugin
.
host
,
extraOptions
)
_
,
err
=
call
.
Run
()
if
isCmdNotSupportedErr
(
err
)
{
err
=
(
*
mounterDefaults
)(
f
)
.
SetUpAt
(
dir
,
fsGroup
)
err
=
(
*
mounterDefaults
)(
f
)
.
SetUpAt
(
dir
,
mounterArgs
)
}
if
err
!=
nil
{
...
...
@@ -93,7 +93,7 @@ func (f *flexVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
if
!
f
.
readOnly
{
if
f
.
plugin
.
capabilities
.
FSGroup
{
volume
.
SetVolumeOwnership
(
f
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
f
,
mounterArgs
.
F
sGroup
)
}
}
...
...
pkg/volume/flexvolume/mounter_test.go
View file @
5b97b286
...
...
@@ -23,6 +23,7 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
"k8s.io/kubernetes/test/utils/harness"
)
...
...
@@ -46,7 +47,7 @@ func TestSetUpAt(tt *testing.T) {
plugin
,
rootDir
:=
testPlugin
(
t
)
plugin
.
unsupportedCommands
=
[]
string
{
"unsupportedCmd"
}
plugin
.
runner
=
fakeRunner
(
// first call without
f
sGroup
// first call without
mounterArgs.F
sGroup
assertDriverCall
(
t
,
successOutput
(),
mountCmd
,
rootDir
+
"/mount-dir"
,
specJSON
(
plugin
,
spec
,
map
[
string
]
string
{
optionKeyPodName
:
"my-pod"
,
...
...
@@ -55,7 +56,7 @@ func TestSetUpAt(tt *testing.T) {
optionKeyServiceAccountName
:
"my-sa"
,
})),
// second test has
f
sGroup
// second test has
mounterArgs.F
sGroup
assertDriverCall
(
t
,
notSupportedOutput
(),
mountCmd
,
rootDir
+
"/mount-dir"
,
specJSON
(
plugin
,
spec
,
map
[
string
]
string
{
optionFSGroup
:
"42"
,
...
...
@@ -69,8 +70,10 @@ func TestSetUpAt(tt *testing.T) {
)
m
,
_
:=
plugin
.
newMounterInternal
(
spec
,
pod
,
mounter
,
plugin
.
runner
)
m
.
SetUpAt
(
rootDir
+
"/mount-dir"
,
nil
)
var
mounterArgs
volume
.
MounterArgs
m
.
SetUpAt
(
rootDir
+
"/mount-dir"
,
mounterArgs
)
fsGroup
:=
int64
(
42
)
m
.
SetUpAt
(
rootDir
+
"/mount-dir"
,
&
fsGroup
)
group
:=
int64
(
42
)
mounterArgs
.
FsGroup
=
&
group
m
.
SetUpAt
(
rootDir
+
"/mount-dir"
,
mounterArgs
)
}
pkg/volume/flocker/flocker.go
View file @
5b97b286
...
...
@@ -235,8 +235,8 @@ func (b *flockerVolumeMounter) GetPath() string {
}
// SetUp bind mounts the disk global mount to the volume path.
func
(
b
*
flockerVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
flockerVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// newFlockerClient uses environment variables and pod attributes to return a
...
...
@@ -277,7 +277,7 @@ control service:
need to update the Primary UUID for this volume.
5. Wait until the Primary UUID was updated or timeout.
*/
func
(
b
*
flockerVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
flockerVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
var
err
error
if
b
.
flockerClient
==
nil
{
b
.
flockerClient
,
err
=
b
.
newFlockerClient
()
...
...
@@ -365,7 +365,7 @@ func (b *flockerVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
if
!
b
.
readOnly
{
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
4
)
.
Infof
(
"successfully mounted %s"
,
dir
)
...
...
pkg/volume/gcepd/gce_pd.go
View file @
5b97b286
...
...
@@ -354,12 +354,12 @@ func (b *gcePersistentDiskMounter) CanMount() error {
}
// SetUp bind mounts the disk global mount to the volume path.
func
(
b
*
gcePersistentDiskMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
gcePersistentDiskMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUp bind mounts the disk global mount to the give volume path.
func
(
b
*
gcePersistentDiskMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
gcePersistentDiskMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// TODO: handle failed mounts here.
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
V
(
4
)
.
Infof
(
"GCE PersistentDisk set up: Dir (%s) PD name (%q) Mounted (%t) Error (%v), ReadOnly (%t)"
,
dir
,
b
.
pdName
,
!
notMnt
,
err
,
b
.
readOnly
)
...
...
@@ -419,7 +419,7 @@ func (b *gcePersistentDiskMounter) SetUpAt(dir string, fsGroup *int64) error {
}
if
!
b
.
readOnly
{
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
4
)
.
Infof
(
"Successfully mounted %s"
,
dir
)
...
...
pkg/volume/gcepd/gce_pd_test.go
View file @
5b97b286
...
...
@@ -141,7 +141,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
@@ -279,7 +279,7 @@ func TestMountOptions(t *testing.T) {
t
.
Errorf
(
"Got a nil Mounter"
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
mountOptions
:=
fakeMounter
.
MountPoints
[
0
]
.
Opts
...
...
pkg/volume/git_repo/git_repo.go
View file @
5b97b286
...
...
@@ -179,12 +179,12 @@ func (b *gitRepoVolumeMounter) CanMount() error {
}
// SetUp creates new directory and clones a git repo.
func
(
b
*
gitRepoVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
gitRepoVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUpAt creates new directory and clones a git repo.
func
(
b
*
gitRepoVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
gitRepoVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
if
volumeutil
.
IsReady
(
b
.
getMetaDir
())
{
return
nil
}
...
...
@@ -194,7 +194,7 @@ func (b *gitRepoVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
if
err
!=
nil
{
return
err
}
if
err
:=
wrapped
.
SetUpAt
(
dir
,
fsGroup
);
err
!=
nil
{
if
err
:=
wrapped
.
SetUpAt
(
dir
,
mounterArgs
);
err
!=
nil
{
return
err
}
...
...
@@ -240,7 +240,7 @@ func (b *gitRepoVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
fmt
.
Errorf
(
"failed to exec 'git reset --hard': %s: %v"
,
output
,
err
)
}
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
volumeutil
.
SetReady
(
b
.
getMetaDir
())
return
nil
...
...
pkg/volume/git_repo/git_repo_test.go
View file @
5b97b286
...
...
@@ -422,7 +422,7 @@ func doTestSetUp(scenario struct {
g
:=
mounter
.
(
*
gitRepoVolumeMounter
)
g
.
exec
=
&
fake
g
.
SetUp
(
nil
)
g
.
SetUp
(
volume
.
MounterArgs
{}
)
if
fake
.
CommandCalls
!=
len
(
expecteds
)
{
allErrs
=
append
(
allErrs
,
...
...
pkg/volume/glusterfs/glusterfs.go
View file @
5b97b286
...
...
@@ -275,11 +275,11 @@ func (b *glusterfsMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
glusterfsMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
glusterfsMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
glusterfsMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
glusterfsMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
V
(
4
)
.
Infof
(
"mount setup: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
...
pkg/volume/glusterfs/glusterfs_test.go
View file @
5b97b286
...
...
@@ -118,7 +118,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if
volumePath
!=
expectedPath
{
t
.
Errorf
(
"Unexpected path, expected %q, got: %q"
,
expectedPath
,
volumePath
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
volumePath
);
err
!=
nil
{
...
...
pkg/volume/hostpath/host_path.go
View file @
5b97b286
...
...
@@ -222,7 +222,7 @@ func (b *hostPathMounter) CanMount() error {
}
// SetUp does nothing.
func
(
b
*
hostPathMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
func
(
b
*
hostPathMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
err
:=
validation
.
ValidatePathNoBacksteps
(
b
.
GetPath
())
if
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid HostPath `%s`: %v"
,
b
.
GetPath
(),
err
)
...
...
@@ -235,7 +235,7 @@ func (b *hostPathMounter) SetUp(fsGroup *int64) error {
}
// SetUpAt does not make sense for host paths - probably programmer error.
func
(
b
*
hostPathMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
hostPathMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
return
fmt
.
Errorf
(
"SetUpAt() does not make sense for host paths"
)
}
...
...
pkg/volume/hostpath/host_path_test.go
View file @
5b97b286
...
...
@@ -217,7 +217,7 @@ func TestInvalidHostPath(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
expectedMsg
:=
"invalid HostPath `/no/backsteps/allowed/..`: must not contain '..'"
if
err
.
Error
()
!=
expectedMsg
{
t
.
Fatalf
(
"expected error `%s` but got `%s`"
,
expectedMsg
,
err
)
...
...
@@ -253,7 +253,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
...
...
pkg/volume/iscsi/iscsi.go
View file @
5b97b286
...
...
@@ -330,13 +330,13 @@ func (b *iscsiDiskMounter) CanMount() error {
return
nil
}
func
(
b
*
iscsiDiskMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
iscsiDiskMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
iscsiDiskMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
iscsiDiskMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// diskSetUp checks mountpoints and prevent repeated calls
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
f
sGroup
)
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"iscsi: failed to setup"
)
}
...
...
pkg/volume/iscsi/iscsi_test.go
View file @
5b97b286
...
...
@@ -175,7 +175,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
t
.
Errorf
(
"Unexpected path, expected %q, got: %q"
,
expectedPath
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/local/local.go
View file @
5b97b286
...
...
@@ -423,12 +423,12 @@ func (m *localVolumeMounter) CanMount() error {
}
// SetUp bind mounts the directory to the volume path
func
(
m
*
localVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
m
.
SetUpAt
(
m
.
GetPath
(),
fsGroup
)
func
(
m
*
localVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
m
.
SetUpAt
(
m
.
GetPath
(),
mounterArgs
)
}
// SetUpAt bind mounts the directory to the volume path and sets up volume ownership
func
(
m
*
localVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
m
*
localVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
m
.
plugin
.
volumeLocks
.
LockKey
(
m
.
globalPath
)
defer
m
.
plugin
.
volumeLocks
.
UnlockKey
(
m
.
globalPath
)
...
...
@@ -452,7 +452,7 @@ func (m *localVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
nil
}
refs
,
err
:=
m
.
mounter
.
GetMountRefs
(
m
.
globalPath
)
if
f
sGroup
!=
nil
{
if
mounterArgs
.
F
sGroup
!=
nil
{
if
err
!=
nil
{
klog
.
Errorf
(
"cannot collect mounting information: %s %v"
,
m
.
globalPath
,
err
)
return
err
...
...
@@ -461,7 +461,7 @@ func (m *localVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
// Only count mounts from other pods
refs
=
m
.
filterPodMounts
(
refs
)
if
len
(
refs
)
>
0
{
fsGroupNew
:=
int64
(
*
f
sGroup
)
fsGroupNew
:=
int64
(
*
mounterArgs
.
F
sGroup
)
fsGroupOld
,
err
:=
m
.
mounter
.
GetFSGroup
(
m
.
globalPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to check fsGroup for %s (%v)"
,
m
.
globalPath
,
err
)
...
...
@@ -519,7 +519,7 @@ func (m *localVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
if
!
m
.
readOnly
{
// Volume owner will be written only once on the first volume mount
if
len
(
refs
)
==
0
{
return
volume
.
SetVolumeOwnership
(
m
,
f
sGroup
)
return
volume
.
SetVolumeOwnership
(
m
,
mounterArgs
.
F
sGroup
)
}
}
return
nil
...
...
pkg/volume/local/local_test.go
View file @
5b97b286
...
...
@@ -200,7 +200,7 @@ func TestInvalidLocalPath(t *testing.T) {
t
.
Fatal
(
err
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
expectedMsg
:=
"invalid path: /no/backsteps/allowed/.. must not contain '..'"
if
err
.
Error
()
!=
expectedMsg
{
t
.
Fatalf
(
"expected error `%s` but got `%s`"
,
expectedMsg
,
err
)
...
...
@@ -307,7 +307,7 @@ func TestMountUnmount(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
...
...
@@ -412,7 +412,9 @@ func testFSGroupMount(plug volume.VolumePlugin, pod *v1.Pod, tmpDir string, fsGr
return
fmt
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
&
fsGroup
);
err
!=
nil
{
var
mounterArgs
volume
.
MounterArgs
mounterArgs
.
FsGroup
=
&
fsGroup
if
err
:=
mounter
.
SetUp
(
mounterArgs
);
err
!=
nil
{
return
err
}
return
nil
...
...
@@ -517,7 +519,7 @@ func TestMountOptions(t *testing.T) {
fakeMounter
:=
&
mount
.
FakeMounter
{}
mounter
.
(
*
localVolumeMounter
)
.
mounter
=
fakeMounter
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
mountOptions
:=
fakeMounter
.
MountPoints
[
0
]
.
Opts
...
...
pkg/volume/nfs/nfs.go
View file @
5b97b286
...
...
@@ -233,11 +233,11 @@ func (nfsMounter *nfsMounter) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
nfsMounter
*
nfsMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
nfsMounter
.
SetUpAt
(
nfsMounter
.
GetPath
(),
fsGroup
)
func
(
nfsMounter
*
nfsMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
nfsMounter
.
SetUpAt
(
nfsMounter
.
GetPath
(),
mounterArgs
)
}
func
(
nfsMounter
*
nfsMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
nfsMounter
*
nfsMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
notMnt
,
err
:=
mount
.
IsNotMountPoint
(
nfsMounter
.
mounter
,
dir
)
klog
.
V
(
4
)
.
Infof
(
"NFS mount set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
...
pkg/volume/nfs/nfs_test.go
View file @
5b97b286
...
...
@@ -122,7 +122,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if
volumePath
!=
expectedPath
{
t
.
Errorf
(
"Unexpected path, expected %q, got: %q"
,
expectedPath
,
volumePath
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
volumePath
);
err
!=
nil
{
...
...
pkg/volume/photon_pd/photon_pd.go
View file @
5b97b286
...
...
@@ -200,12 +200,12 @@ func (b *photonPersistentDiskMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
photonPersistentDiskMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
photonPersistentDiskMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
photonPersistentDiskMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
photonPersistentDiskMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
4
)
.
Infof
(
"Photon Persistent Disk setup %s to %s"
,
b
.
pdID
,
dir
)
// TODO: handle failed mounts here.
...
...
pkg/volume/photon_pd/photon_pd_test.go
View file @
5b97b286
...
...
@@ -128,7 +128,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/portworx/portworx.go
View file @
5b97b286
...
...
@@ -298,12 +298,12 @@ func (b *portworxVolumeMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
portworxVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
portworxVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUpAt attaches the disk and bind mounts to the volume path.
func
(
b
*
portworxVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
portworxVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
Infof
(
"Portworx Volume set up. Dir: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
...
@@ -331,7 +331,7 @@ func (b *portworxVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
if
!
b
.
readOnly
{
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
}
klog
.
Infof
(
"Portworx Volume %s setup at %s"
,
b
.
volumeID
,
dir
)
return
nil
...
...
pkg/volume/portworx/portworx_test.go
View file @
5b97b286
...
...
@@ -163,7 +163,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/projected/projected.go
View file @
5b97b286
...
...
@@ -188,11 +188,11 @@ func (s *projectedVolumeMounter) CanMount() error {
return
nil
}
func
(
s
*
projectedVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
s
.
SetUpAt
(
s
.
GetPath
(),
fsGroup
)
func
(
s
*
projectedVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
s
.
SetUpAt
(
s
.
GetPath
(),
mounterArgs
)
}
func
(
s
*
projectedVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
s
*
projectedVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
s
.
volName
,
s
.
pod
.
UID
,
dir
)
wrapped
,
err
:=
s
.
plugin
.
host
.
NewWrapperMounter
(
s
.
volName
,
wrappedVolumeSpec
(),
s
.
pod
,
*
s
.
opts
)
...
...
@@ -207,7 +207,7 @@ func (s *projectedVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
setupSuccess
:=
false
if
err
:=
wrapped
.
SetUpAt
(
dir
,
fsGroup
);
err
!=
nil
{
if
err
:=
wrapped
.
SetUpAt
(
dir
,
mounterArgs
);
err
!=
nil
{
return
err
}
...
...
@@ -243,9 +243,9 @@ func (s *projectedVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
err
=
volume
.
SetVolumeOwnership
(
s
,
f
sGroup
)
err
=
volume
.
SetVolumeOwnership
(
s
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
f
sGroup
)
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
mounterArgs
.
F
sGroup
)
return
err
}
setupSuccess
=
true
...
...
pkg/volume/projected/projected_test.go
View file @
5b97b286
...
...
@@ -878,7 +878,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -943,7 +943,8 @@ func TestInvalidPathProjected(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
var
mounterArgs
volume
.
MounterArgs
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
==
nil
{
t
.
Errorf
(
"Expected error while setting up secret"
)
}
...
...
@@ -994,7 +995,7 @@ func TestPluginReboot(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -1046,7 +1047,7 @@ func TestPluginOptional(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -1144,7 +1145,7 @@ func TestPluginOptionalKeys(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
pkg/volume/quobyte/quobyte.go
View file @
5b97b286
...
...
@@ -237,12 +237,12 @@ func (mounter *quobyteMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
mounter
*
quobyteMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
func
(
mounter
*
quobyteMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
pluginDir
:=
mounter
.
plugin
.
host
.
GetPluginDir
(
utilstrings
.
EscapeQualifiedName
(
quobytePluginName
))
return
mounter
.
SetUpAt
(
pluginDir
,
fsGroup
)
return
mounter
.
SetUpAt
(
pluginDir
,
mounterArgs
)
}
func
(
mounter
*
quobyteMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
mounter
*
quobyteMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// Check if Quobyte is already mounted on the host in the Plugin Dir
// if so we can use this mountpoint instead of creating a new one
// IsLikelyNotMountPoint wouldn't check the mount type
...
...
pkg/volume/quobyte/quobyte_test.go
View file @
5b97b286
...
...
@@ -101,7 +101,7 @@ func doTestPlugin(t *testing.T, spec *volume.Spec) {
if
volumePath
!=
fmt
.
Sprintf
(
"%s/plugins/kubernetes.io~quobyte/root#root@vol"
,
tmpDir
)
{
t
.
Errorf
(
"Got unexpected path: %s expected: %s"
,
volumePath
,
fmt
.
Sprintf
(
"%s/plugins/kubernetes.io~quobyte/root#root@vol"
,
tmpDir
))
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
unmounter
,
err
:=
plug
.
(
*
quobytePlugin
)
.
newUnmounterInternal
(
"vol"
,
types
.
UID
(
"poduid"
),
&
mount
.
FakeMounter
{})
...
...
pkg/volume/rbd/rbd.go
View file @
5b97b286
...
...
@@ -825,14 +825,14 @@ func (b *rbdMounter) CanMount() error {
return
nil
}
func
(
b
*
rbdMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
rbdMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
rbdMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
rbdMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
// diskSetUp checks mountpoints and prevent repeated calls
klog
.
V
(
4
)
.
Infof
(
"rbd: attempting to setup at %s"
,
dir
)
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
f
sGroup
)
err
:=
diskSetUp
(
b
.
manager
,
*
b
,
dir
,
b
.
mounter
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"rbd: failed to setup at %s %v"
,
dir
,
err
)
}
...
...
pkg/volume/rbd/rbd_test.go
View file @
5b97b286
...
...
@@ -305,7 +305,7 @@ func doTestPlugin(t *testing.T, c *testcase) {
t
.
Errorf
(
"Unexpected path, expected %q, got: %q"
,
c
.
expectedPodMountPath
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
pkg/volume/scaleio/sio_volume.go
View file @
5b97b286
...
...
@@ -77,12 +77,12 @@ func (v *sioVolume) CanMount() error {
return
nil
}
func
(
v
*
sioVolume
)
SetUp
(
fsGroup
*
int64
)
error
{
return
v
.
SetUpAt
(
v
.
GetPath
(),
fsGroup
)
func
(
v
*
sioVolume
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
v
.
SetUpAt
(
v
.
GetPath
(),
mounterArgs
)
}
// SetUp bind mounts the disk global mount to the volume path.
func
(
v
*
sioVolume
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
v
*
sioVolume
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
v
.
plugin
.
volumeMtx
.
LockKey
(
v
.
volSpecName
)
defer
v
.
plugin
.
volumeMtx
.
UnlockKey
(
v
.
volSpecName
)
...
...
@@ -154,9 +154,9 @@ func (v *sioVolume) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
if
!
v
.
readOnly
&&
f
sGroup
!=
nil
{
if
!
v
.
readOnly
&&
mounterArgs
.
F
sGroup
!=
nil
{
klog
.
V
(
4
)
.
Info
(
log
(
"applying value FSGroup ownership"
))
volume
.
SetVolumeOwnership
(
v
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
v
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
4
)
.
Info
(
log
(
"successfully setup PV %s: volume %s mapped as %s mounted at %s"
,
v
.
volSpecName
,
v
.
volName
,
devicePath
,
dir
))
...
...
pkg/volume/scaleio/sio_volume_test.go
View file @
5b97b286
...
...
@@ -191,7 +191,7 @@ func TestVolumeMounterUnmounter(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
sioMounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
sioMounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
path
);
err
!=
nil
{
...
...
@@ -345,7 +345,7 @@ func TestVolumeProvisioner(t *testing.T) {
t
.
Fatalf
(
"failed to create sio mgr: %v"
,
err
)
}
sioVol
.
sioMgr
.
client
=
sio
if
err
:=
sioMounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
sioMounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Fatalf
(
"Expected success, got: %v"
,
err
)
}
...
...
pkg/volume/secret/secret.go
View file @
5b97b286
...
...
@@ -178,11 +178,11 @@ func (b *secretVolumeMounter) CanMount() error {
return
nil
}
func
(
b
*
secretVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
secretVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
func
(
b
*
secretVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
secretVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
3
)
.
Infof
(
"Setting up volume %v for pod %v at %v"
,
b
.
volName
,
b
.
pod
.
UID
,
dir
)
// Wrap EmptyDir, let it do the setup.
...
...
@@ -219,7 +219,7 @@ func (b *secretVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
}
setupSuccess
:=
false
if
err
:=
wrapped
.
SetUpAt
(
dir
,
fsGroup
);
err
!=
nil
{
if
err
:=
wrapped
.
SetUpAt
(
dir
,
mounterArgs
);
err
!=
nil
{
return
err
}
if
err
:=
volumeutil
.
MakeNestedMountpoints
(
b
.
volName
,
dir
,
b
.
pod
);
err
!=
nil
{
...
...
@@ -254,9 +254,9 @@ func (b *secretVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
err
=
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
err
=
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
if
err
!=
nil
{
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
f
sGroup
)
klog
.
Errorf
(
"Error applying volume ownership settings for group: %v"
,
mounterArgs
.
F
sGroup
)
return
err
}
setupSuccess
=
true
...
...
pkg/volume/secret/secret_test.go
View file @
5b97b286
...
...
@@ -327,7 +327,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -401,7 +401,8 @@ func TestInvalidPathSecret(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
var
mounterArgs
volume
.
MounterArgs
err
=
mounter
.
SetUp
(
mounterArgs
)
if
err
==
nil
{
t
.
Errorf
(
"Expected error while setting up secret"
)
}
...
...
@@ -452,7 +453,7 @@ func TestPluginReboot(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -504,7 +505,7 @@ func TestPluginOptional(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
@@ -602,7 +603,7 @@ func TestPluginOptionalKeys(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
volumePath
)
}
err
=
mounter
.
SetUp
(
nil
)
err
=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
)
if
err
!=
nil
{
t
.
Errorf
(
"Failed to setup volume: %v"
,
err
)
}
...
...
pkg/volume/storageos/storageos.go
View file @
5b97b286
...
...
@@ -345,7 +345,7 @@ func (b *storageosMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
storageosMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
func
(
b
*
storageosMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
// Need a namespace to find the volume, try pod's namespace if not set.
if
b
.
volNamespace
==
""
{
klog
.
V
(
2
)
.
Infof
(
"Setting StorageOS volume namespace to pod namespace: %s"
,
b
.
podNamespace
)
...
...
@@ -375,11 +375,11 @@ func (b *storageosMounter) SetUp(fsGroup *int64) error {
klog
.
V
(
4
)
.
Infof
(
"Successfully mounted StorageOS volume %s into global mount directory"
,
b
.
volName
)
// Bind mount the volume into the pod
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// SetUp bind mounts the disk global mount to the give volume path.
func
(
b
*
storageosMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
storageosMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
notMnt
,
err
:=
b
.
mounter
.
IsLikelyNotMountPoint
(
dir
)
klog
.
V
(
4
)
.
Infof
(
"StorageOS volume set up: %s %v %v"
,
dir
,
!
notMnt
,
err
)
if
err
!=
nil
&&
!
os
.
IsNotExist
(
err
)
{
...
...
@@ -433,7 +433,7 @@ func (b *storageosMounter) SetUpAt(dir string, fsGroup *int64) error {
}
if
!
b
.
readOnly
{
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
}
klog
.
V
(
4
)
.
Infof
(
"StorageOS volume setup complete on %s"
,
dir
)
return
nil
...
...
pkg/volume/storageos/storageos_test.go
View file @
5b97b286
...
...
@@ -208,7 +208,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Expected path: '%s' got: '%s'"
,
expectedPath
,
volPath
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
if
_
,
err
:=
os
.
Stat
(
volPath
);
err
!=
nil
{
...
...
pkg/volume/testing/testing.go
View file @
5b97b286
...
...
@@ -765,11 +765,11 @@ func (fv *FakeVolume) CanMount() error {
return
nil
}
func
(
fv
*
FakeVolume
)
SetUp
(
fsGroup
*
int64
)
error
{
func
(
fv
*
FakeVolume
)
SetUp
(
mounterArgs
MounterArgs
)
error
{
fv
.
Lock
()
defer
fv
.
Unlock
()
fv
.
SetUpCallCount
++
return
fv
.
SetUpAt
(
fv
.
getPath
(),
fsGroup
)
return
fv
.
SetUpAt
(
fv
.
getPath
(),
mounterArgs
)
}
func
(
fv
*
FakeVolume
)
GetSetUpCallCount
()
int
{
...
...
@@ -778,7 +778,7 @@ func (fv *FakeVolume) GetSetUpCallCount() int {
return
fv
.
SetUpCallCount
}
func
(
fv
*
FakeVolume
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
fv
*
FakeVolume
)
SetUpAt
(
dir
string
,
mounterArgs
MounterArgs
)
error
{
return
os
.
MkdirAll
(
dir
,
0750
)
}
...
...
pkg/volume/util/operationexecutor/operation_generator.go
View file @
5b97b286
...
...
@@ -701,7 +701,10 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
}
// Execute mount
mountErr
:=
volumeMounter
.
SetUp
(
fsGroup
)
mountErr
:=
volumeMounter
.
SetUp
(
volume
.
MounterArgs
{
FsGroup
:
fsGroup
,
PodUID
:
string
(
volumeToMount
.
Pod
.
UID
),
})
if
mountErr
!=
nil
{
// On failure, return error. Caller will log and retry.
return
volumeToMount
.
GenerateError
(
"MountVolume.SetUp failed"
,
mountErr
)
...
...
pkg/volume/volume.go
View file @
5b97b286
...
...
@@ -101,6 +101,12 @@ type Attributes struct {
SupportsSELinux
bool
}
// MounterArgs provides more easily extensible arguments to Mounter
type
MounterArgs
struct
{
FsGroup
*
int64
PodUID
string
}
// Mounter interface provides methods to set up/mount the volume.
type
Mounter
interface
{
// Uses Interface to provide the path for Docker binds.
...
...
@@ -122,14 +128,14 @@ type Mounter interface {
// 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
(
fsGroup
*
int64
)
error
SetUp
(
mounterArgs
MounterArgs
)
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
,
fsGroup
*
int64
)
error
SetUpAt
(
dir
string
,
mounterArgs
MounterArgs
)
error
// GetAttributes returns the attributes of the mounter.
// This function is called after SetUp()/SetUpAt().
GetAttributes
()
Attributes
...
...
pkg/volume/vsphere_volume/vsphere_volume.go
View file @
5b97b286
...
...
@@ -208,8 +208,8 @@ func (b *vsphereVolumeMounter) GetAttributes() volume.Attributes {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
vsphereVolumeMounter
)
SetUp
(
fsGroup
*
int64
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
fsGroup
)
func
(
b
*
vsphereVolumeMounter
)
SetUp
(
mounterArgs
volume
.
MounterArgs
)
error
{
return
b
.
SetUpAt
(
b
.
GetPath
(),
mounterArgs
)
}
// Checks prior to mount operations to verify that the required components (binaries, etc.)
...
...
@@ -220,7 +220,7 @@ func (b *vsphereVolumeMounter) CanMount() error {
}
// SetUp attaches the disk and bind mounts to the volume path.
func
(
b
*
vsphereVolumeMounter
)
SetUpAt
(
dir
string
,
fsGroup
*
int64
)
error
{
func
(
b
*
vsphereVolumeMounter
)
SetUpAt
(
dir
string
,
mounterArgs
volume
.
MounterArgs
)
error
{
klog
.
V
(
5
)
.
Infof
(
"vSphere volume setup %s to %s"
,
b
.
volPath
,
dir
)
// TODO: handle failed mounts here.
...
...
@@ -269,7 +269,7 @@ func (b *vsphereVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
os
.
Remove
(
dir
)
return
err
}
volume
.
SetVolumeOwnership
(
b
,
f
sGroup
)
volume
.
SetVolumeOwnership
(
b
,
mounterArgs
.
F
sGroup
)
klog
.
V
(
3
)
.
Infof
(
"vSphere volume %s mounted to %s"
,
b
.
volPath
,
dir
)
return
nil
...
...
pkg/volume/vsphere_volume/vsphere_volume_test.go
View file @
5b97b286
...
...
@@ -123,7 +123,7 @@ func TestPlugin(t *testing.T) {
t
.
Errorf
(
"Got unexpected path: %s"
,
path
)
}
if
err
:=
mounter
.
SetUp
(
nil
);
err
!=
nil
{
if
err
:=
mounter
.
SetUp
(
volume
.
MounterArgs
{}
);
err
!=
nil
{
t
.
Errorf
(
"Expected success, got: %v"
,
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment