Skip to content

Commit

Permalink
Log on excessively long build output lines
Browse files Browse the repository at this point in the history
In case of >64KiB, the ordinary maximum Docker build output length, we warn.
This warning is actionable right now, but it will help diagnose build failures.
  • Loading branch information
AaronFriel committed Nov 15, 2023
1 parent 5107b73 commit ddf4c86
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions provider/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,12 @@ func (p *dockerNativeProvider) dockerBuild(ctx context.Context,
// Print push logs to `Info` progress report
scanner := newScanner(pushOutput)
for scanner.Scan() {
info, err := processLogLine(scanner.Text(), func(rm json.RawMessage) (bool, string, error) {
line := scanner.Text()
if len(line) == bufio.MaxScanTokenSize {
_ = p.host.Log(ctx, "warning", urn,
fmt.Sprintf("Docker build output line exceeds %d KiB", bufio.MaxScanTokenSize/1024))
}
info, err := processLogLine(line, func(rm json.RawMessage) (bool, string, error) {
var result types.PushResult
err := json.Unmarshal(rm, &result)
if err != nil {
Expand Down Expand Up @@ -489,7 +494,12 @@ func (p *dockerNativeProvider) runImageBuild(
var imageID string
scanner := newScanner(imgBuildResp.Body)
for scanner.Scan() {
info, err := processLogLine(scanner.Text(), func(rm json.RawMessage) (bool, string, error) {
line := scanner.Text()
if len(line) == bufio.MaxScanTokenSize {
_ = p.host.Log(ctx, "warning", urn,
fmt.Sprintf("Docker build output line exceeds %d KiB", bufio.MaxScanTokenSize/1024))
}
info, err := processLogLine(line, func(rm json.RawMessage) (bool, string, error) {
var result types.BuildResult
err := json.Unmarshal(rm, &result)
if err != nil {
Expand Down Expand Up @@ -573,7 +583,12 @@ func pullDockerImage(ctx context.Context, p *dockerNativeProvider, urn resource.

scanner := newScanner(pullOutput)
for scanner.Scan() {
info, err := processLogLine(scanner.Text(), nil)
line := scanner.Text()
if len(line) == bufio.MaxScanTokenSize {
_ = p.host.Log(ctx, "warning", urn,
fmt.Sprintf("Docker build output line exceeds %d KiB", bufio.MaxScanTokenSize/1024))
}
info, err := processLogLine(line, nil)
if err != nil {
return fmt.Errorf("Error pulling cached image %s: %v", cachedImage, err)
}
Expand Down

0 comments on commit ddf4c86

Please sign in to comment.