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
dda8703d
Unverified
Commit
dda8703d
authored
Aug 07, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Aug 07, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #80328 from davidz627/automated-cherry-pick-of-#80191-upstream-release-1.15
Automated cherry pick of #80191: Add passthrough for MountOptions for NodeStageVolume for
parents
54fe9e13
b8bec436
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
51 additions
and
12 deletions
+51
-12
csi_attacher.go
pkg/volume/csi/csi_attacher.go
+7
-1
csi_attacher_test.go
pkg/volume/csi/csi_attacher_test.go
+12
-0
csi_block.go
pkg/volume/csi/csi_block.go
+2
-1
csi_client.go
pkg/volume/csi/csi_client.go
+10
-4
csi_client_test.go
pkg/volume/csi/csi_client_test.go
+6
-2
csi_util_test.go
pkg/volume/csi/csi_util_test.go
+6
-0
fake_client.go
pkg/volume/csi/fake/fake_client.go
+7
-4
csi.go
test/e2e/storage/drivers/csi.go
+1
-0
No files found.
pkg/volume/csi/csi_attacher.go
View file @
dda8703d
...
...
@@ -383,6 +383,11 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo
accessMode
=
spec
.
PersistentVolume
.
Spec
.
AccessModes
[
0
]
}
var
mountOptions
[]
string
if
spec
.
PersistentVolume
!=
nil
&&
spec
.
PersistentVolume
.
Spec
.
MountOptions
!=
nil
{
mountOptions
=
spec
.
PersistentVolume
.
Spec
.
MountOptions
}
fsType
:=
csiSource
.
FSType
err
=
csi
.
NodeStageVolume
(
ctx
,
csiSource
.
VolumeHandle
,
...
...
@@ -391,7 +396,8 @@ func (c *csiAttacher) MountDevice(spec *volume.Spec, devicePath string, deviceMo
fsType
,
accessMode
,
nodeStageSecrets
,
csiSource
.
VolumeAttributes
)
csiSource
.
VolumeAttributes
,
mountOptions
)
if
err
!=
nil
{
return
err
...
...
pkg/volume/csi/csi_attacher_test.go
View file @
dda8703d
...
...
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
"sync"
"testing"
"time"
...
...
@@ -1033,6 +1034,14 @@ func TestAttacherMountDevice(t *testing.T) {
spec
:
volume
.
NewSpecFromPersistentVolume
(
makeTestPV
(
pvName
,
10
,
testDriver
,
"test-vol1"
),
false
),
},
{
testName
:
"normal PV with mount options"
,
volName
:
"test-vol1"
,
devicePath
:
"path1"
,
deviceMountPath
:
"path2"
,
stageUnstageSet
:
true
,
spec
:
volume
.
NewSpecFromPersistentVolume
(
makeTestPVWithMountOptions
(
pvName
,
10
,
testDriver
,
"test-vol1"
,
[]
string
{
"test-op"
}),
false
),
},
{
testName
:
"no vol name"
,
volName
:
""
,
devicePath
:
"path1"
,
...
...
@@ -1141,6 +1150,9 @@ func TestAttacherMountDevice(t *testing.T) {
if
vol
.
Path
!=
tc
.
deviceMountPath
{
t
.
Errorf
(
"expected mount path: %s. got: %s"
,
tc
.
deviceMountPath
,
vol
.
Path
)
}
if
!
reflect
.
DeepEqual
(
vol
.
MountFlags
,
tc
.
spec
.
PersistentVolume
.
Spec
.
MountOptions
)
{
t
.
Errorf
(
"expected mount options: %v, got: %v"
,
tc
.
spec
.
PersistentVolume
.
Spec
.
MountOptions
,
vol
.
MountFlags
)
}
}
}
}
...
...
pkg/volume/csi/csi_block.go
View file @
dda8703d
...
...
@@ -134,7 +134,8 @@ func (m *csiBlockMapper) stageVolumeForBlock(
fsTypeBlockName
,
accessMode
,
nodeStageSecrets
,
csiSource
.
VolumeAttributes
)
csiSource
.
VolumeAttributes
,
nil
/* MountOptions */
)
if
err
!=
nil
{
klog
.
Error
(
log
(
"blockMapper.stageVolumeForBlock failed: %v"
,
err
))
...
...
pkg/volume/csi/csi_client.go
View file @
dda8703d
...
...
@@ -72,6 +72,7 @@ type csiClient interface {
accessMode
api
.
PersistentVolumeAccessMode
,
secrets
map
[
string
]
string
,
volumeContext
map
[
string
]
string
,
mountOptions
[]
string
,
)
error
NodeGetVolumeStats
(
...
...
@@ -515,6 +516,7 @@ func (c *csiDriverClient) NodeStageVolume(ctx context.Context,
accessMode
api
.
PersistentVolumeAccessMode
,
secrets
map
[
string
]
string
,
volumeContext
map
[
string
]
string
,
mountOptions
[]
string
,
)
error
{
klog
.
V
(
4
)
.
Info
(
log
(
"calling NodeStageVolume rpc [volid=%s,staging_target_path=%s]"
,
volID
,
stagingTargetPath
))
if
volID
==
""
{
...
...
@@ -525,9 +527,9 @@ func (c *csiDriverClient) NodeStageVolume(ctx context.Context,
}
if
c
.
nodeV1ClientCreator
!=
nil
{
return
c
.
nodeStageVolumeV1
(
ctx
,
volID
,
publishContext
,
stagingTargetPath
,
fsType
,
accessMode
,
secrets
,
volumeContext
)
return
c
.
nodeStageVolumeV1
(
ctx
,
volID
,
publishContext
,
stagingTargetPath
,
fsType
,
accessMode
,
secrets
,
volumeContext
,
mountOptions
)
}
else
if
c
.
nodeV0ClientCreator
!=
nil
{
return
c
.
nodeStageVolumeV0
(
ctx
,
volID
,
publishContext
,
stagingTargetPath
,
fsType
,
accessMode
,
secrets
,
volumeContext
)
return
c
.
nodeStageVolumeV0
(
ctx
,
volID
,
publishContext
,
stagingTargetPath
,
fsType
,
accessMode
,
secrets
,
volumeContext
,
mountOptions
)
}
return
fmt
.
Errorf
(
"failed to call NodeStageVolume. Both nodeV1ClientCreator and nodeV0ClientCreator are nil"
)
...
...
@@ -542,6 +544,7 @@ func (c *csiDriverClient) nodeStageVolumeV1(
accessMode
api
.
PersistentVolumeAccessMode
,
secrets
map
[
string
]
string
,
volumeContext
map
[
string
]
string
,
mountOptions
[]
string
,
)
error
{
nodeClient
,
closer
,
err
:=
c
.
nodeV1ClientCreator
(
c
.
addr
)
if
err
!=
nil
{
...
...
@@ -569,7 +572,8 @@ func (c *csiDriverClient) nodeStageVolumeV1(
}
else
{
req
.
VolumeCapability
.
AccessType
=
&
csipbv1
.
VolumeCapability_Mount
{
Mount
:
&
csipbv1
.
VolumeCapability_MountVolume
{
FsType
:
fsType
,
FsType
:
fsType
,
MountFlags
:
mountOptions
,
},
}
}
...
...
@@ -587,6 +591,7 @@ func (c *csiDriverClient) nodeStageVolumeV0(
accessMode
api
.
PersistentVolumeAccessMode
,
secrets
map
[
string
]
string
,
volumeContext
map
[
string
]
string
,
mountOptions
[]
string
,
)
error
{
nodeClient
,
closer
,
err
:=
c
.
nodeV0ClientCreator
(
c
.
addr
)
if
err
!=
nil
{
...
...
@@ -614,7 +619,8 @@ func (c *csiDriverClient) nodeStageVolumeV0(
}
else
{
req
.
VolumeCapability
.
AccessType
=
&
csipbv0
.
VolumeCapability_Mount
{
Mount
:
&
csipbv0
.
VolumeCapability_MountVolume
{
FsType
:
fsType
,
FsType
:
fsType
,
MountFlags
:
mountOptions
,
},
}
}
...
...
pkg/volume/csi/csi_client_test.go
View file @
dda8703d
...
...
@@ -175,6 +175,7 @@ func (c *fakeCsiDriverClient) NodeStageVolume(ctx context.Context,
accessMode
api
.
PersistentVolumeAccessMode
,
secrets
map
[
string
]
string
,
volumeContext
map
[
string
]
string
,
mountOptions
[]
string
,
)
error
{
c
.
t
.
Log
(
"calling fake.NodeStageVolume..."
)
req
:=
&
csipbv1
.
NodeStageVolumeRequest
{
...
...
@@ -187,7 +188,8 @@ func (c *fakeCsiDriverClient) NodeStageVolume(ctx context.Context,
},
AccessType
:
&
csipbv1
.
VolumeCapability_Mount
{
Mount
:
&
csipbv1
.
VolumeCapability_MountVolume
{
FsType
:
fsType
,
FsType
:
fsType
,
MountFlags
:
mountOptions
,
},
},
},
...
...
@@ -448,10 +450,11 @@ func TestClientNodeStageVolume(t *testing.T) {
stagingTargetPath
string
fsType
string
secrets
map
[
string
]
string
mountOptions
[]
string
mustFail
bool
err
error
}{
{
name
:
"test ok"
,
volID
:
"vol-test"
,
stagingTargetPath
:
"/test/path"
,
fsType
:
"ext4"
},
{
name
:
"test ok"
,
volID
:
"vol-test"
,
stagingTargetPath
:
"/test/path"
,
fsType
:
"ext4"
,
mountOptions
:
[]
string
{
"unvalidated"
}
},
{
name
:
"missing volID"
,
stagingTargetPath
:
"/test/path"
,
mustFail
:
true
},
{
name
:
"missing target path"
,
volID
:
"vol-test"
,
mustFail
:
true
},
{
name
:
"bad fs"
,
volID
:
"vol-test"
,
stagingTargetPath
:
"/test/path"
,
fsType
:
"badfs"
,
mustFail
:
true
},
...
...
@@ -479,6 +482,7 @@ func TestClientNodeStageVolume(t *testing.T) {
api
.
ReadWriteOnce
,
tc
.
secrets
,
map
[
string
]
string
{
"attr0"
:
"val0"
},
tc
.
mountOptions
,
)
checkErr
(
t
,
tc
.
mustFail
,
err
)
...
...
pkg/volume/csi/csi_util_test.go
View file @
dda8703d
...
...
@@ -42,6 +42,12 @@ func TestMain(m *testing.M) {
os
.
Exit
(
m
.
Run
())
}
func
makeTestPVWithMountOptions
(
name
string
,
sizeGig
int
,
driverName
,
volID
string
,
mountOptions
[]
string
)
*
api
.
PersistentVolume
{
pv
:=
makeTestPV
(
name
,
sizeGig
,
driverName
,
volID
)
pv
.
Spec
.
MountOptions
=
mountOptions
return
pv
}
func
makeTestPV
(
name
string
,
sizeGig
int
,
driverName
,
volID
string
)
*
api
.
PersistentVolume
{
return
&
api
.
PersistentVolume
{
ObjectMeta
:
meta
.
ObjectMeta
{
...
...
pkg/volume/csi/fake/fake_client.go
View file @
dda8703d
...
...
@@ -189,20 +189,23 @@ func (f *NodeClient) NodeStageVolume(ctx context.Context, req *csipb.NodeStageVo
return
nil
,
errors
.
New
(
"missing staging target path"
)
}
csiVol
:=
CSIVolume
{
Path
:
req
.
GetStagingTargetPath
(),
VolumeContext
:
req
.
GetVolumeContext
(),
}
fsType
:=
""
fsTypes
:=
"block|ext4|xfs|zfs"
mounted
:=
req
.
GetVolumeCapability
()
.
GetMount
()
if
mounted
!=
nil
{
fsType
=
mounted
.
GetFsType
()
csiVol
.
MountFlags
=
mounted
.
GetMountFlags
()
}
if
!
strings
.
Contains
(
fsTypes
,
fsType
)
{
return
nil
,
errors
.
New
(
"invalid fstype"
)
}
f
.
nodeStagedVolumes
[
req
.
GetVolumeId
()]
=
CSIVolume
{
Path
:
req
.
GetStagingTargetPath
(),
VolumeContext
:
req
.
GetVolumeContext
(),
}
f
.
nodeStagedVolumes
[
req
.
GetVolumeId
()]
=
csiVol
return
&
csipb
.
NodeStageVolumeResponse
{},
nil
}
...
...
test/e2e/storage/drivers/csi.go
View file @
dda8703d
...
...
@@ -350,6 +350,7 @@ func InitGcePDCSIDriver() testsuites.TestDriver {
"ext4"
,
"xfs"
,
),
SupportedMountOption
:
sets
.
NewString
(
"debug"
,
"nouid32"
),
Capabilities
:
map
[
testsuites
.
Capability
]
bool
{
testsuites
.
CapPersistence
:
true
,
testsuites
.
CapFsGroup
:
true
,
...
...
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