Skip to content

Commit

Permalink
fix: distinguish docker build errors from streaming errors (#6910)
Browse files Browse the repository at this point in the history
Co-authored-by: Tejal Desai <tejal29@gmail.com>
  • Loading branch information
briandealwis and tejal29 authored Dec 10, 2021
1 parent 0d05992 commit 5933db1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions integration/build_dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ func TestBuildDependenciesOrder(t *testing.T) {
{
description: "build failure with concurrency=1",
args: []string{"-p", "failed-dependency"},
failure: `unable to stream build output: The command '/bin/sh -c [ "${FAIL}" == "0" ] || false' returned a non-zero code: 1`,
failure: `docker build failure: The command '/bin/sh -c [ "${FAIL}" == "0" ] || false' returned a non-zero code: 1`,
},
{
description: "build failure with concurrency=0",
args: []string{"-p", "failed-dependency", "-p", "concurrency-0"},
failure: `unable to stream build output: The command '/bin/sh -c [ "${FAIL}" == "0" ] || false' returned a non-zero code: 1`,
failure: `docker build failure: The command '/bin/sh -c [ "${FAIL}" == "0" ] || false' returned a non-zero code: 1`,
},
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/skaffold/docker/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bufio"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -364,6 +365,10 @@ func (l *localDaemon) Build(ctx context.Context, out io.Writer, workspace string
}

if err := streamDockerMessages(out, resp.Body, auxCallback); err != nil {
var jm *jsonmessage.JSONError
if errors.As(err, &jm) {
return "", fmt.Errorf("docker build failure: %w", err)
}
return "", fmt.Errorf("unable to stream build output: %w", err)
}

Expand Down

0 comments on commit 5933db1

Please sign in to comment.