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:
parent
69363705a8
commit
d2e479505c
|
@ -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{
|
||||
|
|
|
@ -964,6 +964,7 @@ func TestCSIVolumeEndpoint_ListExternal(t *testing.T) {
|
|||
Healthy: true,
|
||||
ControllerInfo: &structs.CSIControllerInfo{
|
||||
SupportsAttachDetach: true,
|
||||
SupportsListVolumes: true,
|
||||
},
|
||||
RequiresControllerPlugin: true,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue