cloud-provider-openstack icon indicating copy to clipboard operation
cloud-provider-openstack copied to clipboard

[Feature Request] [cinder-csi-plugin] support for SeLinuxMount

Open BdeHeij opened this issue 2 months ago • 1 comments

/kind feature

What happened: seLinuxMount is a property of CSIDriver added in Kubernetes 1.25. It declares the driver's ability to mount its volumes separately with different SELinux labels. The reason this matters is because workloads storing many small files on PVs will suffer from very slow startup otherwise.

What you expected to happen: The CSIDriver to support passing the -o context= option to mount and declare seLinuxMount: true. This would prevent needless relabeling.

How to reproduce it: Create a PVC with a huge amount of files. When restarting the Pod the container will be in ContainerCreating for quite some time, depending on underlying storage IO

Anything else we need to know?: For relevant context see:

  • https://kubernetes.io/blog/2023/04/18/kubernetes-1-27-efficient-selinux-relabeling-beta/
  • https://github.com/kubernetes/enhancements/tree/master/keps/sig-storage/1710-selinux-relabeling

Environment:

  • openstack-cloud-controller-manager(or other related binary) version:
  • OpenStack version:
  • Others:

BdeHeij avatar Sep 24 '26 09:09 BdeHeij

I looked at what this would take for cinder-csi-plugin:

  • Neither manifests/cinder-csi-plugin/csi-cinder-driver.yaml nor the chart's templates/cinder-csi-driver.yaml sets seLinuxMount today. So kubelet never passes the context= mount option and falls back to recursive relabeling.
  • The node side already looks ready. NodeStageVolume appends the volume capability's mount flags to the staging mount options (collectMountOptions in pkg/csi/cinder/nodeserver.go), and that is where kubelet puts -o context=... once the driver opts in.

So the change may be mostly declarative: add seLinuxMount: true to the CSIDriver (probably behind a chart value so it can be turned off), then test on an SELinux-enforcing node with both ext4 and xfs. In that test, it's worth checking that the bind mount in NodePublishVolume still works when kubelet passes the context option there too.

adityamukesh avatar Nov 05 '26 11:11 adityamukesh