Skip to content

Commit

Permalink
fix: do not check watchers if staging rbd on node read only
Browse files Browse the repository at this point in the history
  • Loading branch information
Hou Junjie committed Jul 23, 2021
1 parent 937ac8c commit 8cb10eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions internal/rbd/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1123,3 +1123,18 @@ func (cs *ControllerServer) ControllerExpandVolume(ctx context.Context, req *csi
NodeExpansionRequired: nodeExpansion,
}, nil
}

// ControllerPublishVolume collects information useful for NodeStageVolume to tell if the volume is expected to be mounted readonly
func (cs *ControllerServer) ControllerPublishVolume(ctx context.Context, req *csi.ControllerPublishVolumeRequest) (*csi.ControllerPublishVolumeResponse, error) {
ro := "false"
if req.GetReadonly() {
ro = "true"
}
// todo: check rwo and rox constains
return &csi.ControllerPublishVolumeResponse{PublishContext: map[string]string{"readonly": ro}}, nil
}

// ControllerUnpublishVolume does nothing
func (cs *ControllerServer) ControllerUnpublishVolume(ctx context.Context, req *csi.ControllerUnpublishVolumeRequest) (*csi.ControllerUnpublishVolumeResponse, error) {
return &csi.ControllerUnpublishVolumeResponse{}, nil
}
2 changes: 2 additions & 0 deletions internal/rbd/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ func (r *Driver) Run(conf *util.Config) {
csi.ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT,
csi.ControllerServiceCapability_RPC_CLONE_VOLUME,
csi.ControllerServiceCapability_RPC_EXPAND_VOLUME,
csi.ControllerServiceCapability_RPC_PUBLISH_READONLY,
csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME,
})
// We only support the multi-writer option when using block, but it's a supported capability for the plugin in general
// In addition, we want to add the remaining modes like MULTI_NODE_READER_ONLY,
Expand Down
5 changes: 4 additions & 1 deletion internal/rbd/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
return nil, err
}

readonly := req.GetPublishContext()["readonly"] == "true"

isBlock := req.GetVolumeCapability().GetBlock() != nil
disableInUseChecks := false
// MULTI_NODE_MULTI_WRITER is supported by default for Block access type volumes
Expand All @@ -126,7 +128,8 @@ func (ns *NodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStageVol
return nil, status.Error(codes.InvalidArgument, "rbd: RWX access mode request is only valid for volumes with access type `block`")
}

disableInUseChecks = true
// todo: if some of the watchers is r/w, we can not tell the differences
disableInUseChecks = readonly
}

volID := req.GetVolumeId()
Expand Down

0 comments on commit 8cb10eb

Please sign in to comment.