sched/feasible: Validate CSIVolume's correctly

Previously we were looking up plugins based on the Alias Name for a CSI
Volume within the context of its task group.

Here we first look up a volume based on its identifier and then validate
the existence of the plugin based on its `PluginID`.
This commit is contained in:
Danielle Lancashire 2020-02-07 15:38:02 +01:00 committed by Tim Gross
parent 22e8317a53
commit a2e01c4369
2 changed files with 8 additions and 9 deletions

View File

@ -230,20 +230,19 @@ func (c *CSIVolumeChecker) hasPlugins(n *structs.Node) bool {
ws := memdb.NewWatchSet()
for _, req := range c.volumes {
// Check that this node has a healthy running plugin with the right PluginID
plugin, ok := n.CSINodePlugins[req.Name]
if !(ok && plugin.Healthy) {
return false
}
// Get the volume to check that it's healthy (there's a healthy controller
// and the volume hasn't encountered an error or been marked for GC
vol, err := c.ctx.State().CSIVolumeByID(ws, req.Source)
if err != nil || vol == nil {
return false
}
// Check that this node has a healthy running plugin with the right PluginID
plugin, ok := n.CSINodePlugins[vol.PluginID]
if !(ok && plugin.Healthy) {
return false
}
if (req.ReadOnly && !vol.CanReadOnly()) ||
!vol.CanWrite() {
return false

View File

@ -293,9 +293,9 @@ func TestCSIVolumeChecker(t *testing.T) {
noVolumes := map[string]*structs.VolumeRequest{}
volumes := map[string]*structs.VolumeRequest{
"foo": {
"baz": {
Type: "csi",
Name: "foo",
Name: "baz",
Source: "volume-id",
},
"nonsense": {