kubernetes-csi / csi-driver-smb

This driver allows Kubernetes to access SMB Server on both Linux and Windows nodes.
Apache License 2.0
480 stars 130 forks source link

MountOptions declared in storageClass don't seem to work (they work if declared in a manually created PV) #800

Open igor-msk opened 1 month ago

igor-msk commented 1 month ago

MountOptions declared in StorageClass don't seem to apply

apiVersion: storage.k8s.io/v1
kind: StorageClass
...
mountOptions:
  - noperm
  - noserverino

What happened: the PVC got created but remained in Pending state with the following error - Warning ProvisioningFailed 1s (x2 over 2s) smb.csi.k8s.io_dev-kuber-node-pool-cpu-3l215_8522d1a0-224f-4c17-9bf7-07ed1b0e8161 failed to provision volume with StorageClass "smb-sbf-it-cam-dockerwebservice": rpc error: code = Internal desc = failed to mount smb server: rpc error: code = Internal desc = MkdirAll /tmp/pvc-6a28c399-6f67-4d2d-a7d5-c07d423b954e failed with error: mkdir /tmp/pvc-6a28c399-6f67-4d2d-a7d5-c07d423b954e: read-only file system

What you expected to happen: SMB successfully mounted. I got it to work only by manually creating a PV and declaring the MountOptions in the PV nstread of declaring them in the StorageClass, but I need many PVs in subdirs with PVC names, so providing PVs with montOptions manually is not an option.

How to reproduce it: Try Option 1 - use a SatefullSet with a StorageClass without manually creating PVs

Environment:

SMB folders are on Windows host

andyzhangx commented 1 month ago

could you provide the csi driver logs on that node? The mountOptions should be contained in mount_flags in the /NodeStageVolume logs https://github.com/kubernetes-csi/csi-driver-smb/blob/master/docs/csi-debug.md#case2-volume-mountunmount-failed

andyzhangx commented 1 month ago

here are example logs, the mountOptions are in the mount_flags in e2e tests:

https://[storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/kubernetes-csi_csi-driver-smb/799/pull-csi-driver-smb-e2e/1811227271713787904/build-log.txt](https://storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/kubernetes-csi_csi-driver-smb/799/pull-csi-driver-smb-e2e/1811227271713787904/build-log.txt)

[pod/csi-smb-node-c5hcp/smb] I0711 03:17:31.508163       1 utils.go:76] GRPC call: /csi.v1.Node/NodeStageVolume
[pod/csi-smb-node-c5hcp/smb] I0711 03:17:31.508183       1 utils.go:77] GRPC request: {"secrets":"***stripped***","staging_target_path":"/var/lib/kubelet/plugins/kubernetes.io/csi/pv/pvc-a97eeda9-acb9-4ba9-959b-5f27d0742570/globalmount","volume_capability":{"AccessType":{"Mount":{"mount_flags":["dir_mode=0777","file_mode=0777"]}},"access_mode":{"mode":1}},"volume_context":{"csi.storage.k8s.io/pv/name":"pvc-a97eeda9-acb9-4ba9-959b-5f27d0742570","csi.storage.k8s.io/pvc/name":"pvc-grsdz","csi.storage.k8s.io/pvc/namespace":"smb-6174","source":"//smb-server.default.svc.cluster.local/share","storage.kubernetes.io/csiProvisionerIdentity":"1720667723125-4346-smb.csi.k8s.io","subdir":"pvc-a97eeda9-acb9-4ba9-959b-5f27d0742570"},"volume_id":"smb-server.default.svc.cluster.local/share#pvc-a97eeda9-acb9-4ba9-959b-5f27d0742570##"}