diff --git a/scheduler/feasible.go b/scheduler/feasible.go index f2ddc6888..78a5a245f 100644 --- a/scheduler/feasible.go +++ b/scheduler/feasible.go @@ -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 diff --git a/scheduler/feasible_test.go b/scheduler/feasible_test.go index dd2c48279..e5b49745f 100644 --- a/scheduler/feasible_test.go +++ b/scheduler/feasible_test.go @@ -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": {