Skip to content

Commit

Permalink
Attempting alternative where target is chowned to the correct group
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Jun 25, 2022
1 parent d3ea66d commit 4df9240
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions pkg/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,6 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
mountOptions = append(mountOptions, "ro")
}

fsGroup := volCap.GetMount().VolumeMountGroup
if fsGroup != "" {
klog.V(5).Infof("Adding fsGroup parameter of %s to mount call", fsGroup)
mountOptions = append(mountOptions, fmt.Sprintf("gid=%s", fsGroup))
}

if m := volCap.GetMount(); m != nil {
for _, f := range m.MountFlags {
// Special-case check for access point
Expand Down Expand Up @@ -188,6 +182,13 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
}
klog.V(5).Infof("NodePublishVolume: %s was mounted", target)

fsGroup := volCap.GetMount().VolumeMountGroup
if fsGroup != "" {
fsGroupParsed, _ := strconv.ParseInt(fsGroup, 10, 64)
klog.V(5).Infof("NodePublishVolume: changing GID of %s to %s", target, fsGroup)
os.Chown(target, -1, int(fsGroupParsed))
}

//Increment volume Id counter
if d.volMetricsOptIn {
if value, ok := volumeIdCounter[req.GetVolumeId()]; ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/driver/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ func TestNodePublishVolume(t *testing.T) {
TargetPath: targetPath,
},
expectMakeDir: true,
mountArgs: []interface{}{volumeId + ":/", targetPath, "efs", []string{"tls", "gid=1000"}},
mountSuccess: true,
mountArgs: []interface{}{volumeId + ":/", targetPath, "efs", []string{"tls"}},
},
{
name: "fail: conflicting access point in volume handle and mount options",
Expand Down

0 comments on commit 4df9240

Please sign in to comment.