From 80edb57a6f8e5a89fc2cf384d5edcc531845f173 Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Fri, 17 Jun 2016 14:58:53 -0700 Subject: [PATCH] Guard against bad restore --- client/alloc_runner.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/alloc_runner.go b/client/alloc_runner.go index dc649f57c..c5f68c2dc 100644 --- a/client/alloc_runner.go +++ b/client/alloc_runner.go @@ -116,6 +116,17 @@ func (r *AllocRunner) RestoreState() error { r.allocClientDescription = snap.AllocClientDescription r.taskStates = snap.TaskStates + var snapshotErrors multierror.Error + if r.alloc == nil { + snapshotErrors.Errors = append(snapshotErrors.Errors, fmt.Errorf("alloc_runner snapshot includes a nil allocation")) + } + if r.ctx == nil { + snapshotErrors.Errors = append(snapshotErrors.Errors, fmt.Errorf("alloc_runner snapshot includes a nil context")) + } + if e := snapshotErrors.ErrorOrNil(); e != nil { + return e + } + // Restore the task runners var mErr multierror.Error for name, state := range r.taskStates {