Skip to content

Commit

Permalink
add MountConfig capability checking to volume_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed May 20, 2020
1 parent 6a252f3 commit e92ed1e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/allocrunner/taskrunner/volume_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e92ed1e

Please sign in to comment.