Skip to content

Commit 05cad62

Browse files
author
Hou Junjie
committed
fix: do not check watchers if staging rbd on node read only
1 parent 937ac8c commit 05cad62

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

internal/rbd/controllerserver.go

+15
Original file line numberDiff line numberDiff line change
@@ -1123,3 +1123,18 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
11231123
NodeExpansionRequired: nodeExpansion,
11241124
}, nil
11251125
}
1126+
1127+
// ControllerPublishVolume collects information useful for NodeStageVolume to tell if the volume is expected to be mounted readonly
1128+
func (cs *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) {
1129+
ro := "false"
1130+
if req.GetReadonly() {
1131+
ro = "true"
1132+
}
1133+
// todo: check rwo and rox constains
1134+
return &csi.ControllerPublishVolumeResponse{PublishContext: map[string]string{"readonly": ro}}, nil
1135+
}
1136+
1137+
// ControllerUnpublishVolume does nothing
1138+
func (cs *ControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) {
1139+
return &csi.ControllerUnpublishVolumeResponse{}, nil
1140+
}

internal/rbd/driver.go

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ func (r *Driver) Run(conf *util.Config) {
133133
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
134134
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
135135
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
136+
csi.ControllerServiceCapability_RPC_PUBLISH_READONLY,
137+
csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
136138
})
137139
// We only support the multi-writer option when using block, but it's a supported capability for the plugin in general
138140
// In addition, we want to add the remaining modes like MULTI_NODE_READER_ONLY,

internal/rbd/nodeserver.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,13 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
117117
return nil, err
118118
}
119119

120+
disableInUseChecks := req.GetPublishContext()["readonly"] == "true"
120121
isBlock := req.GetVolumeCapability().GetBlock() != nil
121-
disableInUseChecks := false
122122
// MULTI_NODE_MULTI_WRITER is supported by default for Block access type volumes
123123
if req.VolumeCapability.AccessMode.Mode == csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER {
124-
if !isBlock {
125-
util.WarningLog(ctx, "MULTI_NODE_MULTI_WRITER currently only supported with volumes of access type `block`, invalid AccessMode for volume: %v", req.GetVolumeId())
126-
return nil, status.Error(codes.InvalidArgument, "rbd: RWX access mode request is only valid for volumes with access type `block`")
124+
if isBlock {
125+
disableInUseChecks = true
127126
}
128-
129-
disableInUseChecks = true
130127
}
131128

132129
volID := req.GetVolumeId()

0 commit comments

Comments
 (0)