Skip to content

Commit 0449319

Browse files
committed
Improve deadline exceeded detection.
See also: golang/go#21880
1 parent 873a321 commit 0449319

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/batches/docker/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (image *image) Ensure(ctx context.Context) error {
9090
out, err := exec.CommandContext(dctx, "docker", args...).CombinedOutput()
9191
id := string(bytes.TrimSpace(out))
9292

93-
if errors.Is(err, context.DeadlineExceeded) {
93+
if errors.IsDeadlineExceeded(err) || errors.IsDeadlineExceeded(dctx.Err()) {
9494
return "", newFastCommandTimeoutError(dctx, args...)
9595
} else if err != nil {
9696
return "", err

internal/batches/docker/info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func NCPU(ctx context.Context) (int, error) {
2323

2424
args := []string{"info", "--format", "{{ .NCPU }}"}
2525
out, err := exec.CommandContext(dctx, "docker", args...).CombinedOutput()
26-
if errors.Is(errors.Cause(err), context.DeadlineExceeded) {
26+
if errors.IsDeadlineExceeded(err) || errors.IsDeadlineExceeded(dctx.Err()) {
2727
return ncpu, newFastCommandTimeoutError(dctx, args...)
2828
} else if err != nil {
2929
return ncpu, err

0 commit comments

Comments
 (0)