earthly / earthly

Super simple build framework with fast, repeatable builds and an instantly familiar syntax – like Dockerfile and Makefile had a baby.
https://earthly.dev
Mozilla Public License 2.0
11.31k stars 397 forks source link

Improve error message when using --output in ci environment #1879

Open brumhard opened 2 years ago

brumhard commented 2 years ago

Hi,

I accidentally forgot --ci on a CI system and got the following error:

Error: build target: build main: failed to solve: io: read/write on closed pipe

If I add --no-output everything works so I think the output fails. This also makes sense since it fails in the output stage.

It would be nice if you could improve the error message a bit. It took some time for me to figure out what's actually wrong.

brandonSc commented 2 years ago

HI @brumhard - thanks for raising that. I would agree that a more user-friendly error message could help, since it's kind of an expected error case.

guitcastro commented 2 years ago

I am having the same issue, however my code works on my local machine but fails on CI. For now, I am disable the outputs.

alexcb commented 2 years ago

We had another user report the same issue today:

output | --> exporting outputs
              output | [          ]   0% transferring (via tar) registry.com/long/path/to/my/image:HEAD
              output | WARN: (exporting outputs) failed to copy to tar: rpc error: code = Unknown desc = io: read/write on closed pipe
Share your logs with an Earthly account (experimental)! Register for one at https://ci.earthly.dev/.
Error: build target: build main: failed to solve: io: read/write on closed pipe

with buildkit logs:

 time="2022-09-06T18:28:07Z" level=debug msg="healthcheck completed" actualDuration=1.503634ms timeout=10s
 time="2022-09-06T18:28:08Z" level=debug msg="healthcheck completed" actualDuration=1.557846ms timeout=10s
 time="2022-09-06T18:28:08Z" level=error msg="/moby.buildkit.v1.Control/Solve returned error: rpc error: code = Unknown desc = io: read/write on closed pipe"
 io: read/write on closed pipe
 27  earthly --build-arg http_proxy --build-arg no_proxy --build-arg https_proxy --build-arg GITLAB_SECRET_TOKEN_ID=CI_JOB_TOKEN --build-arg image_tag --secret CI_JOB_TOKEN --build-arg BUILD_PATH=site +publish-image
 github.com/moby/buildkit/session/filesync.writeTargetFile
   /go/pkg/mod/github.com/earthly/buildkit@v0.0.1-0.20220818191106-3b049bfd9c25/session/filesync/diffcopy.go:132
 github.com/moby/buildkit/session/filesync.(*fsSyncTarget).DiffCopy
   /go/pkg/mod/github.com/earthly/buildkit@v0.0.1-0.20220818191106-3b049bfd9c25/session/filesync/filesync.go:303
 github.com/moby/buildkit/session/filesync._FileSend_DiffCopy_Handler
   /go/pkg/mod/github.com/earthly/buildkit@v0.0.1-0.20220818191106-3b049bfd9c25/session/filesync/filesync.pb.go:392
 github.com/moby/buildkit/util/grpcerrors.StreamServerInterceptor
   /go/pkg/mod/github.com/earthly/buildkit@v0.0.1-0.20220818191106-3b049bfd9c25/util/grpcerrors/intercept.go:33
 google.golang.org/grpc.(*Server).processStreamingRPC
   /go/pkg/mod/google.golang.org/grpc@v1.47.0/server.go:1549
 google.golang.org/grpc.(*Server).handleStream
   /go/pkg/mod/google.golang.org/grpc@v1.47.0/server.go:1624
 google.golang.org/grpc.(*Server).serveStreams.func1.2
   /go/pkg/mod/google.golang.org/grpc@v1.47.0/server.go:922
 runtime.goexit
   /usr/local/go/src/runtime/asm_amd64.s:1581

 40 v0.6.22 buildkitd --config=/etc/buildkitd.toml
 github.com/moby/buildkit/session/filesync.(*streamWriterCloser).Write
   /src/session/filesync/diffcopy.go:53
 bufio.(*Writer).Write
   /usr/local/go/src/bufio/bufio.go:668
 archive/tar.(*regFileWriter).Write
   /usr/local/go/src/archive/tar/writer.go:497
 archive/tar.(*Writer).Write
   /usr/local/go/src/archive/tar/writer.go:435
 io.(*multiWriter).Write
   /usr/local/go/src/io/multi.go:60
 io.copyBuffer
   /usr/local/go/src/io/io.go:428
 io.Copy
   /usr/local/go/src/io/io.go:385
 github.com/containerd/containerd/images/archive.blobRecord.func1
   /src/vendor/github.com/containerd/containerd/images/archive/exporter.go:326
 github.com/containerd/containerd/images/archive.writeTar
   /src/vendor/github.com/containerd/containerd/images/archive/exporter.go:489
 github.com/containerd/containerd/images/archive.Export
   /src/vendor/github.com/containerd/containerd/images/archive/exporter.go:268
 github.com/moby/buildkit/exporter/earthlyoutputs.(*imageExporterInstance).Export
   /src/exporter/earthlyoutputs/export.go:567
 github.com/moby/buildkit/solver/llbsolver.(*Solver).Solve.func4
   /src/solver/llbsolver/solver.go:273
 github.com/moby/buildkit/solver/llbsolver.inBuilderContext.func1
   /src/solver/llbsolver/solver.go:457
 github.com/moby/buildkit/solver.(*Job).InContext
   /src/solver/jobs.go:569
 github.com/moby/buildkit/solver/llbsolver.inBuilderContext
   /src/solver/llbsolver/solver.go:453
 github.com/moby/buildkit/solver/llbsolver.(*Solver).Solve
   /src/solver/llbsolver/solver.go:272
 github.com/moby/buildkit/control.(*Controller).Solve
   /src/control/control.go:311
 github.com/moby/buildkit/api/services/control._Control_Solve_Handler.func1
   /src/api/services/control/control.pb.go:1851
 github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
   /src/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc.UnaryServerInterceptor.func1
   /src/vendor/go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc/interceptor.go:325
 main.unaryInterceptor.func1
   /src/cmd/buildkitd/main.go:614
 github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
   /src/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
 github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1
   /src/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
 github.com/moby/buildkit/api/services/control._Control_Solve_Handler
   /src/api/services/control/control.pb.go:1853
 google.golang.org/grpc.(*Server).processUnaryRPC
   /src/vendor/google.golang.org/grpc/server.go:1282
 google.golang.org/grpc.(*Server).handleStream
   /src/vendor/google.golang.org/grpc/server.go:1619
 google.golang.org/grpc.(*Server).serveStreams.func1.2
   /src/vendor/google.golang.org/grpc/server.go:921
 runtime.goexit
   /usr/local/go/src/runtime/asm_amd64.s:1571

 40 v0.6.22 buildkitd --config=/etc/buildkitd.toml
 main.unaryInterceptor.func1
   /src/cmd/buildkitd/main.go:618
 github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1.1.1
   /src/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:25
 github.com/grpc-ecosystem/go-grpc-middleware.ChainUnaryServer.func1
   /src/vendor/github.com/grpc-ecosystem/go-grpc-middleware/chain.go:34
 github.com/moby/buildkit/api/services/control._Control_Solve_Handler
   /src/api/services/control/control.pb.go:1853
 google.golang.org/grpc.(*Server).processUnaryRPC
   /src/vendor/google.golang.org/grpc/server.go:1282
 google.golang.org/grpc.(*Server).handleStream
   /src/vendor/google.golang.org/grpc/server.go:1619
 google.golang.org/grpc.(*Server).serveStreams.func1.2
   /src/vendor/google.golang.org/grpc/server.go:921
 runtime.goexit
   /usr/local/go/src/runtime/asm_amd64.s:1571

 time="2022-09-06T18:28:08Z" level=debug msg="session finished: <nil>"

which was occurring when trying to save an image to the local kubernetes registry (which failed since it's most likely read-only), but simply failed by closing the pipe.