Skip to content

Commit

Permalink
expose driver capabilities to volume_hook
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed May 20, 2020
1 parent 5c5a0c4 commit da53f64
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions client/allocrunner/taskrunner/volume_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ 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)
}
switch caps.Volumes {
case drivers.VolumeSupportNone, drivers.VolumeSupportCSIOnly:
return nil, fmt.Errorf("task driver does not support host volumes")
default:
}
}

return hostVolumeMounts, nil
}

Expand Down Expand Up @@ -167,6 +179,18 @@ 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)
}
switch caps.Volumes {
case drivers.VolumeSupportNone, drivers.VolumeSupportHostOnly:
return nil, fmt.Errorf("task driver does not support CSI")
default:
}
}

return mounts, nil
}

Expand Down

0 comments on commit da53f64

Please sign in to comment.