Merge pull request #647 from tonistiigi/cancel-error
runcexecutor: make sure to return canceleddocker-18.09
commit
7142c1371e
|
@ -167,7 +167,13 @@ func (w containerdExecutor) Exec(ctx context.Context, meta executor.Meta, root c
|
|||
cancel()
|
||||
}
|
||||
if status.ExitCode() != 0 {
|
||||
return errors.Errorf("process returned non-zero exit code: %d", status.ExitCode())
|
||||
err := errors.Errorf("process returned non-zero exit code: %d", status.ExitCode())
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
err = errors.Wrap(ctx.Err(), err.Error())
|
||||
default:
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -263,7 +263,13 @@ func (w *runcExecutor) Exec(ctx context.Context, meta executor.Meta, root cache.
|
|||
}
|
||||
|
||||
if status != 0 {
|
||||
return errors.Errorf("exit code: %d", status)
|
||||
err := errors.Errorf("exit code: %d", status)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return errors.Wrapf(ctx.Err(), err.Error())
|
||||
default:
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
@ -3,6 +3,7 @@ package solver
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -560,15 +561,14 @@ func (s *sharedOp) CalcSlowCache(ctx context.Context, index Index, f ResultBased
|
|||
key, err := f(ctx, res)
|
||||
complete := true
|
||||
if err != nil {
|
||||
canceled := false
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
canceled = true
|
||||
if strings.Contains(err.Error(), context.Canceled.Error()) {
|
||||
complete = false
|
||||
err = errors.Wrap(ctx.Err(), err.Error())
|
||||
}
|
||||
default:
|
||||
}
|
||||
if canceled && errors.Cause(err) == context.Canceled {
|
||||
complete = false
|
||||
}
|
||||
}
|
||||
s.slowMu.Lock()
|
||||
defer s.slowMu.Unlock()
|
||||
|
@ -615,15 +615,14 @@ func (s *sharedOp) CacheMap(ctx context.Context, index int) (*cacheMapResp, erro
|
|||
res, done, err := op.CacheMap(ctx, len(s.cacheRes))
|
||||
complete := true
|
||||
if err != nil {
|
||||
canceled := false
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
canceled = true
|
||||
if strings.Contains(err.Error(), context.Canceled.Error()) {
|
||||
complete = false
|
||||
err = errors.Wrap(ctx.Err(), err.Error())
|
||||
}
|
||||
default:
|
||||
}
|
||||
if canceled && errors.Cause(err) == context.Canceled {
|
||||
complete = false
|
||||
}
|
||||
}
|
||||
if complete {
|
||||
if err == nil {
|
||||
|
@ -669,15 +668,14 @@ func (s *sharedOp) Exec(ctx context.Context, inputs []Result) (outputs []Result,
|
|||
res, err := op.Exec(ctx, inputs)
|
||||
complete := true
|
||||
if err != nil {
|
||||
canceled := false
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
canceled = true
|
||||
if strings.Contains(err.Error(), context.Canceled.Error()) {
|
||||
complete = false
|
||||
err = errors.Wrap(ctx.Err(), err.Error())
|
||||
}
|
||||
default:
|
||||
}
|
||||
if canceled && errors.Cause(err) == context.Canceled {
|
||||
complete = false
|
||||
}
|
||||
}
|
||||
if complete {
|
||||
if res != nil {
|
||||
|
|
Loading…
Reference in New Issue