Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,15 @@ func (cs *ControllerServer) ControllerPublishVolume(ctx context.Context, req *cs
ro = "true"
}

return &csi.ControllerPublishVolumeResponse{PublishContext: map[string]string{readonlyAttachmentKey: ro}}, nil
volctx := req.GetVolumeContext()
var block string

if _, ok := volctx["writeBlock"]; ok {

block = volctx["writeBlock"]
}

return &csi.ControllerPublishVolumeResponse{PublishContext: map[string]string{readonlyAttachmentKey: ro, "writeBlock": block}}, nil
Comment thread
EnvyusKennys marked this conversation as resolved.
Outdated
}

// ControllerUnpublishVolume does nothing.
Expand Down
8 changes: 8 additions & 0 deletions internal/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
return nil, err
}

if req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER {
if req.GetPublishContext()[readonlyAttachmentKey] == "true" {
return nil, status.Error(codes.InvalidArgument, "vol has already been mount as ReadWrite on another node")
}
}

disableInUseChecks := req.GetPublishContext()[readonlyAttachmentKey] == "true"
isBlock := req.GetVolumeCapability().GetBlock() != nil
// disableInUseChecks := false
Expand Down Expand Up @@ -459,7 +465,9 @@ func (ns *NodeServer) mountVolumeToStagePath(ctx context.Context, req *csi.NodeS
}
}
if csicommon.MountOptionContains(opt, rOnly) {
// readOnly mount with noload option
readOnly = true
opt = append(opt, "noload")
}

if fsType == "xfs" {
Expand Down