add nil check around task resources in device hook

Looking at NewTaskRunner I'm unsure whether TaskRunner.TaskResources
(from which req.TaskResources is set) is intended to be nil at times or
if the TODO in NewTaskRunner is intended to ensure it is always non-nil.
This commit is contained in:
Michael Schurter
2018-11-27 16:50:42 -08:00
parent c7b4ee1546
commit b959d9831c

View File

@@ -30,7 +30,9 @@ func (*deviceHook) Name() string {
}
func (h *deviceHook) Prestart(ctx context.Context, req *interfaces.TaskPrestartRequest, resp *interfaces.TaskPrestartResponse) error {
if len(req.TaskResources.Devices) == 0 {
//TODO Can the nil check be removed once the TODO in NewTaskRunner
// where this is set is addressed?
if req.TaskResources == nil || len(req.TaskResources.Devices) == 0 {
resp.Done = true
return nil
}