Skip to content

Commit c65c298

Browse files
author
Hou Junjie
committed
fix: do not check watchers if staging rbd on node read only
1 parent cb23f71 commit c65c298

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

internal/rbd/controllerserver.go

Lines changed: 15 additions & 0 deletions
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 constrains
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ 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 {
124124
if !isBlock {

internal/util/validate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func CheckReadOnlyManyIsSupported(req *csi.CreateVolumeRequest) error {
9090
writable = true
9191
}
9292
}
93-
if ! writable && req.GetVolumeContentSource() == nil {
93+
if !writable && req.GetVolumeContentSource() == nil {
9494
return status.Error(codes.InvalidArgument, "readOnly accessMode is supported only with content source")
9595
}
9696
return nil

0 commit comments

Comments
 (0)