fix: check mount dir mode before chmod
fix
This commit is contained in:
parent
5a59082977
commit
770d104c4a
@ -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)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user