Merge pull request #647 from tonistiigi/cancel-error

runcexecutor: make sure to return canceled
docker-18.09
Tibor Vass 2018-09-27 14:01:50 -07:00 committed by GitHub
commit 7142c1371e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 17 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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 {