Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bypass chmod if mounting point permissions are correct #340

Merged
merged 1 commit into from May 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/nfs/nodeserver.go
Expand Up @@ -121,10 +121,19 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}

if performChmodOp {
klog.V(2).Infof("volumeID(%v): chmod targetPath(%s) with permissions(0%o)", volumeID, targetPath, mountPermissions)
if err := os.Chmod(targetPath, os.FileMode(mountPermissions)); err != nil {
info, err := os.Lstat(targetPath)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
perm := info.Mode() & os.ModePerm
if perm != os.FileMode(mountPermissions) {
klog.V(2).Infof("volumeID(%v): chmod targetPath(%s, mode:0%o) with permissions(0%o)", volumeID, targetPath, info.Mode(), mountPermissions)
if err := os.Chmod(targetPath, os.FileMode(mountPermissions)); err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
} else {
klog.V(2).Infof("skip chmod on targetPath(%s) since mode is already 0%o)", targetPath, info.Mode())
}
} else {
klog.V(2).Infof("skip chmod on targetPath(%s) since mountPermissions is set as 0", targetPath)
}
Expand Down