Skip to content

Commit 30fddf2

Browse files
authored
Merge pull request #594 from andyzhangx/mount-permisssions
feat: add mountPermissions config in driver
2 parents cb1c783 + d302fda commit 30fddf2

File tree

9 files changed

+17
-9
lines changed

9 files changed

+17
-9
lines changed

charts/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ The following table lists the configurable parameters of the latest Azure Blob S
120120
| `node.metricsPort` | metrics port of csi-blob-node | `29635` |
121121
| `node.livenessProbe.healthPort ` | health check port for liveness probe | `29633` |
122122
| `node.logLevel` | node driver log level | `5` |
123+
| `node.mountPermissions` | mounted folder permissions (only applies for NFS) | `0777`
123124
| `node.enableBlobfuseProxy` | enable blobfuse-proxy on agent node | `false` |
124125
| `node.blobfuseProxy.installBlobfuse` | whether install blobfuse on agent node| `true` |
125126
| `node.blobfuseProxy.blobfuseVersion` | installed blobfuse version on agent node| `1.4.2` |
25 Bytes
Binary file not shown.

charts/latest/blob-csi-driver/templates/csi-blob-node.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ spec:
124124
- "--allow-empty-cloud-config={{ .Values.node.allowEmptyCloudConfig }}"
125125
- "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}"
126126
- "--append-timestamp-cache-dir={{ .Values.node.appendTimeStampInCacheDir }}"
127+
- "--mount-permissions={{ .Values.node.mountPermissions }}"
127128
ports:
128129
- containerPort: {{ .Values.node.livenessProbe.healthPort }}
129130
name: healthz

charts/latest/blob-csi-driver/values.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ node:
119119
disableUpdateDB: true
120120
blobfuseCachePath: /mnt
121121
appendTimeStampInCacheDir: false
122+
mountPermissions: 0777
122123
resources:
123124
livenessProbe:
124125
limits:

pkg/blob/blob.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ type DriverOptions struct {
121121
AllowEmptyCloudConfig bool
122122
EnableGetVolumeStats bool
123123
AppendTimeStampInCacheDir bool
124+
MountPermissions uint64
124125
}
125126

126127
// Driver implements all interfaces of CSI drivers
@@ -146,6 +147,7 @@ type Driver struct {
146147
enableGetVolumeStats bool
147148
appendTimeStampInCacheDir bool
148149
blobfuseProxyConnTimout int
150+
mountPermissions uint64
149151
mounter *mount.SafeFormatAndMount
150152
volLockMap *util.LockMap
151153
// A map storing all volumes with ongoing operations so that additional operations
@@ -176,6 +178,7 @@ func NewDriver(options *DriverOptions) *Driver {
176178
enableBlobMockMount: options.EnableBlobMockMount,
177179
allowEmptyCloudConfig: options.AllowEmptyCloudConfig,
178180
enableGetVolumeStats: options.EnableGetVolumeStats,
181+
mountPermissions: options.MountPermissions,
179182
}
180183
d.Name = options.DriverName
181184
d.Version = driverVersion

pkg/blob/nodeserver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (d *Driver) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolu
107107
klog.V(2).Infof("NodePublishVolume: volume %s mounting %s at %s with mountOptions: %v", volumeID, source, target, mountOptions)
108108
if d.enableBlobMockMount {
109109
klog.Warningf("NodePublishVolume: mock mount on volumeID(%s), this is only for TESTING!!!", volumeID)
110-
if err := volumehelper.MakeDir(target); err != nil {
110+
if err := volumehelper.MakeDir(target, os.FileMode(d.mountPermissions)); err != nil {
111111
klog.Errorf("MakeDir failed on target: %s (%v)", target, err)
112112
return nil, err
113113
}
@@ -260,11 +260,11 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
260260
return nil, status.Error(codes.Internal, fmt.Sprintf("volume(%s) mount %q on %q failed with %v", volumeID, source, targetPath, err))
261261
}
262262

263-
// set 0777 for NFSv3 root folder
264-
if err := os.Chmod(targetPath, 0777); err != nil {
263+
// set permisssions for NFSv3 root folder
264+
if err := os.Chmod(targetPath, os.FileMode(d.mountPermissions)); err != nil {
265265
return nil, status.Error(codes.Internal, fmt.Sprintf("Chmod(%s) failed with %v", targetPath, err))
266266
}
267-
klog.V(2).Infof("volume(%s) mount %q on %q succeeded", volumeID, source, targetPath)
267+
klog.V(2).Infof("volume(%s) mount %q on %q with 0%o succeeded", volumeID, source, targetPath, d.mountPermissions)
268268

269269
return &csi.NodeStageVolumeResponse{}, nil
270270
}
@@ -294,7 +294,7 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
294294
authEnv = append(authEnv, "AZURE_STORAGE_ACCOUNT="+accountName, "AZURE_STORAGE_BLOB_ENDPOINT="+serverAddress)
295295
if d.enableBlobMockMount {
296296
klog.Warningf("NodeStageVolume: mock mount on volumeID(%s), this is only for TESTING!!!", volumeID)
297-
if err := volumehelper.MakeDir(targetPath); err != nil {
297+
if err := volumehelper.MakeDir(targetPath, os.FileMode(d.mountPermissions)); err != nil {
298298
klog.Errorf("MakeDir failed on target: %s (%v)", targetPath, err)
299299
return nil, err
300300
}
@@ -475,7 +475,7 @@ func (d *Driver) ensureMountPoint(target string) (bool, error) {
475475
notMnt = true
476476
return !notMnt, err
477477
}
478-
if err := volumehelper.MakeDir(target); err != nil {
478+
if err := volumehelper.MakeDir(target, os.FileMode(d.mountPermissions)); err != nil {
479479
klog.Errorf("MakeDir failed on target: %s (%v)", target, err)
480480
return !notMnt, err
481481
}

pkg/blobplugin/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var (
5353
allowEmptyCloudConfig = flag.Bool("allow-empty-cloud-config", true, "allow running driver without cloud config")
5454
enableGetVolumeStats = flag.Bool("enable-get-volume-stats", false, "allow GET_VOLUME_STATS on agent node")
5555
appendTimeStampInCacheDir = flag.Bool("append-timestamp-cache-dir", false, "append timestamp into cache directory on agent node")
56+
mountPermissions = flag.Uint64("mount-permissions", 0777, "mounted folder permissions")
5657
)
5758

5859
func main() {
@@ -87,6 +88,7 @@ func handle() {
8788
AllowEmptyCloudConfig: *allowEmptyCloudConfig,
8889
EnableGetVolumeStats: *enableGetVolumeStats,
8990
AppendTimeStampInCacheDir: *appendTimeStampInCacheDir,
91+
MountPermissions: *mountPermissions,
9092
}
9193
driver := blob.NewDriver(&driverOptions)
9294
if driver == nil {

pkg/util/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func GetMountOptions(options []string) string {
7777
return str
7878
}
7979

80-
func MakeDir(pathname string) error {
81-
err := os.MkdirAll(pathname, os.FileMode(0755))
80+
func MakeDir(pathname string, perm os.FileMode) error {
81+
err := os.MkdirAll(pathname, perm)
8282
if err != nil {
8383
if !os.IsExist(err) {
8484
return err

pkg/util/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func TestGetMountOptions(t *testing.T) {
159159
func TestMakeDir(t *testing.T) {
160160
//Successfully create directory
161161
targetTest := "./target_test"
162-
err := MakeDir(targetTest)
162+
err := MakeDir(targetTest, 0777)
163163
assert.NoError(t, err)
164164

165165
// Remove the directory created

0 commit comments

Comments
 (0)