Revert capabilites to only allow RWO (#12)

This commit is contained in:
Cyrill Troxler 2019-02-28 21:09:56 +01:00 committed by GitHub
parent 83723f4be0
commit 95d7e48328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,17 +153,26 @@ func (cs *controllerServer) ValidateVolumeCapabilities(ctx context.Context, req
return nil, status.Error(codes.NotFound, fmt.Sprintf("Volume with id %s does not exist", req.GetVolumeId())) return nil, status.Error(codes.NotFound, fmt.Sprintf("Volume with id %s does not exist", req.GetVolumeId()))
} }
// TODO: checkout if this code is still needed? // We currently only support RWO
//for _, cap := range req.VolumeCapabilities { supportedAccessMode := &csi.VolumeCapability_AccessMode{
// if cap.GetAccessMode().GetMode() != csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER { Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
// return &csi.ValidateVolumeCapabilitiesResponse{Confirmed: false, Message: ""}, nil }
// }
//} for _, cap := range req.VolumeCapabilities {
return &csi.ValidateVolumeCapabilitiesResponse{Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{ if cap.GetAccessMode().GetMode() != supportedAccessMode.GetMode() {
VolumeContext: req.GetVolumeContext(), return &csi.ValidateVolumeCapabilitiesResponse{Message: "Only single node writer is supported"}, nil
VolumeCapabilities: req.GetVolumeCapabilities(), }
Parameters: req.GetParameters(), }
}, Message: ""}, nil
return &csi.ValidateVolumeCapabilitiesResponse{
Confirmed: &csi.ValidateVolumeCapabilitiesResponse_Confirmed{
VolumeCapabilities: []*csi.VolumeCapability{
{
AccessMode: supportedAccessMode,
},
},
},
}, nil
} }
func sanitizeVolumeID(volumeID string) string { func sanitizeVolumeID(volumeID string) string {