Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Have prepare have its own context
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed May 14, 2018
1 parent 3c9c6b7 commit f6b33ad
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions executor/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,19 @@ func (r *Runner) startRunner(parentCtx context.Context, setupCh chan error, rp R
// When Create() returns the host may have been modified to create storage and pull the image.
// These steps may or may not have completed depending on if/where a failure occurred.
bindMounts := []string{}

prepareCtx, prepareCancel := context.WithCancel(ctx)
defer prepareCancel()

go func() {
select {
case <-r.killChan:
prepareCancel()
case <-prepareCtx.Done():
}
}()
err = r.runtime.Prepare(ctx, r.container, bindMounts)
prepareCancel()
if err != nil {
r.metrics.Counter("titus.executor.launchTaskFailed", 1, nil)
r.logger.Error("task failed to create container: ", err)
Expand Down

0 comments on commit f6b33ad

Please sign in to comment.