Skip to content

Commit 1c6a821

Browse files
committed
[kaniko] Better error message when upload fails
Fix #3944 Signed-off-by: David Gageot <[email protected]>
1 parent d4ca6e9 commit 1c6a821

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/skaffold/build/cluster/kaniko.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package cluster
1818

1919
import (
20+
"bytes"
2021
"context"
2122
"fmt"
2223
"io"
@@ -95,10 +96,15 @@ func (b *Builder) copyKanikoBuildContext(ctx context.Context, workspace string,
9596
buildCtxWriter.Close()
9697
}()
9798

98-
if err := b.kubectlcli.Run(ctx, buildCtx, nil, "exec", "-i", podName, "-c", initContainer, "-n", b.Namespace, "--", "tar", "-xf", "-", "-C", constants.DefaultKanikoEmptyDirMountPath); err != nil {
99-
return fmt.Errorf("uploading build context: %w", err)
99+
var out bytes.Buffer
100+
if err := b.kubectlcli.Run(ctx, buildCtx, &out, "exec", "-i", podName, "-c", initContainer, "-n", b.Namespace, "--", "tar", "-xf", "-", "-C", constants.DefaultKanikoEmptyDirMountPath); err != nil {
101+
return fmt.Errorf("uploading build context: %s", out.String())
100102
}
101103

102104
// Generate a file to successfully terminate the init container
103-
return b.kubectlcli.Run(ctx, nil, nil, "exec", podName, "-c", initContainer, "-n", b.Namespace, "--", "touch", "/tmp/complete")
105+
if out, err := b.kubectlcli.RunOut(ctx, "exec", podName, "-c", initContainer, "-n", b.Namespace, "--", "touch", "/tmp/complete"); err != nil {
106+
return fmt.Errorf("finishing upload of the build context: %s", out)
107+
}
108+
109+
return nil
104110
}

0 commit comments

Comments
 (0)