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
e207e0b3
Commit
e207e0b3
authored
Apr 12, 2018
by
Vladimir Vivien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSI - Apply fsGroup volume ownership when pv not readOnly
parent
06c5afe2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
1 deletion
+30
-1
csi_mounter.go
pkg/volume/csi/csi_mounter.go
+28
-0
csi_mounter_test.go
pkg/volume/csi/csi_mounter_test.go
+2
-1
No files found.
pkg/volume/csi/csi_mounter.go
View file @
e207e0b3
...
...
@@ -219,6 +219,34 @@ func (c *csiMountMgr) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
// apply volume ownership
if
!
c
.
readOnly
&&
fsGroup
!=
nil
{
err
:=
volume
.
SetVolumeOwnership
(
c
,
fsGroup
)
if
err
!=
nil
{
// attempt to rollback mount.
glog
.
Error
(
log
(
"mounter.SetupAt failed to set fsgroup volume ownership for [%s]: %v"
,
c
.
volumeID
,
err
))
glog
.
V
(
4
)
.
Info
(
log
(
"mounter.SetupAt attempting to unpublish volume %s due to previous error"
,
c
.
volumeID
))
if
unpubErr
:=
csi
.
NodeUnpublishVolume
(
ctx
,
c
.
volumeID
,
dir
);
unpubErr
!=
nil
{
glog
.
Error
(
log
(
"mounter.SetupAt failed to unpublish volume [%s]: %v (caused by previous NodePublish error: %v)"
,
c
.
volumeID
,
unpubErr
,
err
,
))
return
fmt
.
Errorf
(
"%v (caused by %v)"
,
unpubErr
,
err
)
}
if
unmountErr
:=
removeMountDir
(
c
.
plugin
,
dir
);
unmountErr
!=
nil
{
glog
.
Error
(
log
(
"mounter.SetupAt failed to clean mount dir [%s]: %v (caused by previous NodePublish error: %v)"
,
dir
,
unmountErr
,
err
,
))
return
fmt
.
Errorf
(
"%v (caused by %v)"
,
unmountErr
,
err
)
}
return
err
}
glog
.
V
(
4
)
.
Info
(
log
(
"mounter.SetupAt sets fsGroup to [%d] for %s"
,
*
fsGroup
,
c
.
volumeID
))
}
glog
.
V
(
4
)
.
Infof
(
log
(
"mounter.SetUp successfully requested NodePublish [%s]"
,
dir
))
return
nil
}
...
...
pkg/volume/csi/csi_mounter_test.go
View file @
e207e0b3
...
...
@@ -141,7 +141,8 @@ func TestMounterSetUp(t *testing.T) {
}
// Mounter.SetUp()
if
err
:=
csiMounter
.
SetUp
(
nil
);
err
!=
nil
{
fsGroup
:=
int64
(
2000
)
if
err
:=
csiMounter
.
SetUp
(
&
fsGroup
);
err
!=
nil
{
t
.
Fatalf
(
"mounter.Setup failed: %v"
,
err
)
}
path
:=
csiMounter
.
GetPath
()
...
...
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