From e92ed1e3c8a9f83e9959e3eccb59d3811ca43285 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Wed, 20 May 2020 15:28:58 -0400 Subject: [PATCH] add MountConfig capability checking to volume_hook --- client/allocrunner/taskrunner/volume_hook.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/client/allocrunner/taskrunner/volume_hook.go b/client/allocrunner/taskrunner/volume_hook.go index 5447c50290f3..7a02d30b7040 100644 --- a/client/allocrunner/taskrunner/volume_hook.go +++ b/client/allocrunner/taskrunner/volume_hook.go @@ -121,6 +121,16 @@ func (h *volumeHook) prepareHostVolumes(req *interfaces.TaskPrestartRequest, vol return nil, err } + if len(hostVolumeMounts) > 0 { + caps, err := h.runner.DriverCapabilities() + if err != nil { + return nil, fmt.Errorf("could not validate task driver capabilities: %v", err) + } + if caps.MountConfigs == drivers.MountConfigSupportNone { + return nil, fmt.Errorf("task driver does not support host volumes") + } + } + return hostVolumeMounts, nil } @@ -167,6 +177,16 @@ func (h *volumeHook) prepareCSIVolumes(req *interfaces.TaskPrestartRequest, volu } } + if len(mounts) > 0 { + caps, err := h.runner.DriverCapabilities() + if err != nil { + return nil, fmt.Errorf("could not validate task driver capabilities: %v", err) + } + if caps.MountConfigs == drivers.MountConfigSupportNone { + return nil, fmt.Errorf("task driver does not support CSI") + } + } + return mounts, nil }