Merge pull request #1314 from hashicorp/f-protect-alloc-nil

Guard against bad restore in alloc runner
This commit is contained in:
Alex Dadgar 2016-06-17 15:17:20 -07:00 committed by GitHub
commit 0d7fecc984
1 changed files with 11 additions and 0 deletions

View File

@ -116,6 +116,17 @@ func (r *AllocRunner) RestoreState() error {
r.allocClientDescription = snap.AllocClientDescription r.allocClientDescription = snap.AllocClientDescription
r.taskStates = snap.TaskStates 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 // Restore the task runners
var mErr multierror.Error var mErr multierror.Error
for name, state := range r.taskStates { for name, state := range r.taskStates {