mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +00:00
cephfs: Add support for ROX PVC
cephcsi need to add mount the cephfs subvolume as the readonly when the PVC type is ROX to provide only readonly access to the users Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
bb561c5da3
commit
4d11490a2b
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
csicommon "github.com/ceph/ceph-csi/internal/csi-common"
|
csicommon "github.com/ceph/ceph-csi/internal/csi-common"
|
||||||
"github.com/ceph/ceph-csi/internal/util"
|
"github.com/ceph/ceph-csi/internal/util"
|
||||||
@ -150,6 +151,21 @@ func (*NodeServer) mount(ctx context.Context, volOptions *volumeOptions, req *cs
|
|||||||
|
|
||||||
klog.V(4).Infof(util.Log(ctx, "cephfs: mounting volume %s with %s"), volID, m.name())
|
klog.V(4).Infof(util.Log(ctx, "cephfs: mounting volume %s with %s"), volID, m.name())
|
||||||
|
|
||||||
|
if req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY ||
|
||||||
|
req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY {
|
||||||
|
readOnly := "ro"
|
||||||
|
switch m.(type) {
|
||||||
|
case *fuseMounter:
|
||||||
|
if !csicommon.MountOptionContains(strings.Split(volOptions.FuseMountOptions, ","), readOnly) {
|
||||||
|
volOptions.FuseMountOptions = util.MountOptionsAdd(volOptions.FuseMountOptions, readOnly)
|
||||||
|
}
|
||||||
|
case *kernelMounter:
|
||||||
|
if !csicommon.MountOptionContains(strings.Split(volOptions.KernelMountOptions, ","), readOnly) {
|
||||||
|
volOptions.KernelMountOptions = util.MountOptionsAdd(volOptions.KernelMountOptions, readOnly)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if err = m.mount(ctx, stagingTargetPath, cr, volOptions); err != nil {
|
if err = m.mount(ctx, stagingTargetPath, cr, volOptions); err != nil {
|
||||||
klog.Errorf(util.Log(ctx,
|
klog.Errorf(util.Log(ctx,
|
||||||
"failed to mount volume %s: %v Check dmesg logs if required."),
|
"failed to mount volume %s: %v Check dmesg logs if required."),
|
||||||
|
Loading…
Reference in New Issue
Block a user