Skip to content

Commit eb6c7ec

Browse files
committed
Log kaniko errors that happen during the tar phase
1 parent 2e5439d commit eb6c7ec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pkg/skaffold/build/cluster/kaniko.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,14 @@ func (b *Builder) copyKanikoBuildContext(ctx context.Context, workspace string,
102102
return fmt.Errorf("waiting for pod to initialize: %w", err)
103103
}
104104

105+
errs := make(chan error, 1)
105106
buildCtx, buildCtxWriter := io.Pipe()
106107
go func() {
107108
err := docker.CreateDockerTarContext(ctx, buildCtxWriter, docker.NewBuildConfig(
108109
workspace, artifactName, artifact.DockerfilePath, artifact.BuildArgs), b.cfg)
109110
if err != nil {
110111
buildCtxWriter.CloseWithError(fmt.Errorf("creating docker context: %w", err))
112+
errs <- err
111113
return
112114
}
113115
buildCtxWriter.Close()
@@ -117,7 +119,12 @@ func (b *Builder) copyKanikoBuildContext(ctx context.Context, workspace string,
117119
// In case of an error, print the command's output. (The `err` itself is useless: exit status 1).
118120
var out bytes.Buffer
119121
if err := b.kubectlcli.Run(ctx, buildCtx, &out, "exec", "-i", podName, "-c", initContainer, "-n", b.Namespace, "--", "tar", "-xf", "-", "-C", kaniko.DefaultEmptyDirMountPath); err != nil {
120-
return fmt.Errorf("uploading build context: %s", out.String())
122+
errRun := fmt.Errorf("uploading build context: %s", out.String())
123+
errTar := <-errs
124+
if errTar != nil {
125+
errRun = fmt.Errorf("%v\ntar errors: %w", errRun, errTar)
126+
}
127+
return errRun
121128
}
122129

123130
// Generate a file to successfully terminate the init container.

0 commit comments

Comments
 (0)