Skip to content

Commit

Permalink
createDriver expects task environment
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed Apr 13, 2016
1 parent 6bf2b21 commit 2b505c6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions client/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ func (r *TaskRunner) RestoreState() error {
r.task = snap.Task
r.artifactsDownloaded = snap.ArtifactDownloaded

if err := r.setTaskEnv(); err != nil {
err := fmt.Errorf("failed to create task environment for task %q in allocation %q: %v",
r.task.Name, r.alloc.ID, err)
r.logger.Printf("[ERR] client: %s", err)
return err
}

// Restore the driver
if snap.HandleID != "" {
driver, err := r.createDriver()
Expand Down Expand Up @@ -204,12 +211,8 @@ func (r *TaskRunner) setTaskEnv() error {
// createDriver makes a driver for the task
func (r *TaskRunner) createDriver() (driver.Driver, error) {
if r.taskEnv == nil {
if err := r.setTaskEnv(); err != nil {
err := fmt.Errorf("failed to create driver '%s' for alloc %s: %v",
r.task.Driver, r.alloc.ID, err)
r.logger.Printf("[ERR] client: %s", err)
return nil, err
}
err := fmt.Errorf("task environment not made for task %q in allocation %q", r.task.Name, r.alloc.ID)
return nil, err
}

driverCtx := driver.NewDriverContext(r.task.Name, r.config, r.config.Node, r.logger, r.taskEnv)
Expand Down

0 comments on commit 2b505c6

Please sign in to comment.