CSI: capability check ListVolumes at RPC for nicer error messages

The plugin stub object does not include fine-grained capability checks, which
means `nomad volume status -verbose` will return ugly and verbose error
"Unimplemented" messages from the plugin if it does not support the CSI
`ListVolumes` RPC. Return a nicer error message from our RPC handler instead.
This commit is contained in:
Tim Gross 2021-04-07 10:34:29 -04:00 committed by Tim Gross
parent 69363705a8
commit d2e479505c
2 changed files with 4 additions and 0 deletions

View file

@ -1027,6 +1027,9 @@ func (v *CSIVolume) ListExternal(args *structs.CSIVolumeExternalListRequest, rep
if plugin == nil {
return fmt.Errorf("no such plugin")
}
if !plugin.HasControllerCapability(structs.CSIControllerSupportsListVolumes) {
return fmt.Errorf("unimplemented for this plugin")
}
method := "ClientCSI.ControllerListVolumes"
cReq := &cstructs.ClientCSIControllerListVolumesRequest{

View file

@ -964,6 +964,7 @@ func TestCSIVolumeEndpoint_ListExternal(t *testing.T) {
Healthy: true,
ControllerInfo: &structs.CSIControllerInfo{
SupportsAttachDetach: true,
SupportsListVolumes: true,
},
RequiresControllerPlugin: true,
},