@@ -220,6 +220,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
220
220
var serverAddress , storageEndpointSuffix , protocol , ephemeralVolMountOptions string
221
221
var ephemeralVol , isHnsEnabled bool
222
222
mountPermissions := d .mountPermissions
223
+ performChmodOp := (mountPermissions > 0 )
223
224
for k , v := range attrib {
224
225
switch strings .ToLower (k ) {
225
226
case serverNameField :
@@ -237,9 +238,15 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
237
238
case mountPermissionsField :
238
239
if v != "" {
239
240
var err error
240
- if mountPermissions , err = strconv .ParseUint (v , 8 , 32 ); err != nil {
241
+ var perm uint64
242
+ if perm , err = strconv .ParseUint (v , 8 , 32 ); err != nil {
241
243
return nil , status .Errorf (codes .InvalidArgument , fmt .Sprintf ("invalid mountPermissions %s" , v ))
242
244
}
245
+ if perm == 0 {
246
+ performChmodOp = false
247
+ } else {
248
+ mountPermissions = perm
249
+ }
243
250
}
244
251
}
245
252
}
@@ -283,12 +290,17 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
283
290
return nil , status .Error (codes .Internal , fmt .Sprintf ("volume(%s) mount %q on %q failed with %v" , volumeID , source , targetPath , err ))
284
291
}
285
292
286
- // set permissions for NFSv3 root folder
287
- if err := os .Chmod (targetPath , os .FileMode (mountPermissions )); err != nil {
288
- return nil , status .Error (codes .Internal , fmt .Sprintf ("Chmod(%s) failed with %v" , targetPath , err ))
293
+ if performChmodOp {
294
+ klog .V (2 ).Infof ("volumeID(%v): chmod targetPath(%s) with permissions(0%o)" , volumeID , targetPath , mountPermissions )
295
+ // set permissions for NFSv3 root folder
296
+ if err := os .Chmod (targetPath , os .FileMode (mountPermissions )); err != nil {
297
+ return nil , status .Error (codes .Internal , fmt .Sprintf ("Chmod(%s) failed with %v" , targetPath , err ))
298
+ }
299
+ } else {
300
+ klog .V (2 ).Infof ("skip chmod on targetPath(%s) since mountPermissions is set as 0" , targetPath )
289
301
}
290
- klog .V (2 ).Infof ("volume(%s) mount %q on %q with 0%o succeeded" , volumeID , source , targetPath , mountPermissions )
291
302
303
+ klog .V (2 ).Infof ("volume(%s) mount %s on %s succeeded" , volumeID , source , targetPath )
292
304
return & csi.NodeStageVolumeResponse {}, nil
293
305
}
294
306
0 commit comments