diff --git a/executor/containerdexecutor/executor.go b/executor/containerdexecutor/executor.go index 308371f7100b0..3be6d1a6f4974 100644 --- a/executor/containerdexecutor/executor.go +++ b/executor/containerdexecutor/executor.go @@ -19,6 +19,7 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/moby/buildkit/executor" "github.com/moby/buildkit/executor/oci" + "github.com/moby/buildkit/frontend/gateway/client" "github.com/moby/buildkit/identity" "github.com/moby/buildkit/snapshot" "github.com/moby/buildkit/solver/errdefs" @@ -380,7 +381,7 @@ func (w *containerdExecutor) runProcess(ctx context.Context, p containerd.Proces ExitCode: status.ExitCode(), Err: status.Error(), } - if status.ExitCode() == errdefs.ContainerdUnknownExitStatus && status.Error() != nil { + if status.ExitCode() == client.UnknownExitStatus && status.Error() != nil { exitErr.Err = errors.Wrap(status.Error(), "failure waiting for process") } select { diff --git a/executor/runcexecutor/executor.go b/executor/runcexecutor/executor.go index 62c2891a57287..6665d2cab4b2e 100644 --- a/executor/runcexecutor/executor.go +++ b/executor/runcexecutor/executor.go @@ -19,6 +19,7 @@ import ( "github.com/docker/docker/pkg/idtools" "github.com/moby/buildkit/executor" "github.com/moby/buildkit/executor/oci" + "github.com/moby/buildkit/frontend/gateway/client" "github.com/moby/buildkit/identity" "github.com/moby/buildkit/solver/errdefs" "github.com/moby/buildkit/solver/pb" @@ -334,7 +335,7 @@ func (w *runcExecutor) Run(ctx context.Context, id string, root executor.Mount, func exitError(ctx context.Context, err error) error { if err != nil { exitErr := &errdefs.ExitError{ - ExitCode: errdefs.ContainerdUnknownExitStatus, + ExitCode: client.UnknownExitStatus, Err: err, } var runcExitError *runc.ExitError diff --git a/frontend/gateway/client/client.go b/frontend/gateway/client/client.go index 09d86cad820c1..8193a3038b3b2 100644 --- a/frontend/gateway/client/client.go +++ b/frontend/gateway/client/client.go @@ -12,6 +12,16 @@ import ( fstypes "github.com/tonistiigi/fsutil/types" ) +const ( + // UnknownExitStatus might be returned in (*errdefs.ExitError).ExitCode via + // ContainerProcess.Wait. This can happen if the process never starts + // or if an error was encountered when obtaining the exit status, it is set to 255. + // + // This const is defined here to prevent importing github.com/containerd/containerd + // and corresponds with https://github.com/containerd/containerd/blob/40b22ef0741028917761d8c5d5d29e0d19038836/task.go#L52-L55 + UnknownExitStatus = 255 +) + type Client interface { Solve(ctx context.Context, req SolveRequest) (*Result, error) ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt) (digest.Digest, []byte, error) diff --git a/frontend/gateway/gateway.go b/frontend/gateway/gateway.go index 4067f87f10eb6..fd30b52e990bc 100644 --- a/frontend/gateway/gateway.go +++ b/frontend/gateway/gateway.go @@ -1169,7 +1169,7 @@ func (lbf *llbBridgeForwarder) ExecProcess(srv pb.LLBBridge_ExecProcessServer) e var exitError *errdefs.ExitError var statusError *rpc.Status if err != nil { - statusCode = errdefs.ContainerdUnknownExitStatus + statusCode = gwclient.UnknownExitStatus st, _ := status.FromError(grpcerrors.ToGRPC(err)) stp := st.Proto() statusError = &rpc.Status{ diff --git a/frontend/gateway/grpcclient/client.go b/frontend/gateway/grpcclient/client.go index 84a2767306c6d..3c49eb3176c44 100644 --- a/frontend/gateway/grpcclient/client.go +++ b/frontend/gateway/grpcclient/client.go @@ -882,7 +882,7 @@ func (ctr *container) Start(ctx context.Context, req client.StartRequest) (clien Message: exit.Error.Message, Details: convertGogoAny(exit.Error.Details), })) - if exit.Code != errdefs.ContainerdUnknownExitStatus { + if exit.Code != client.UnknownExitStatus { exitError = &errdefs.ExitError{ExitCode: exit.Code, Err: exitError} } } else if serverDone := msg.GetDone(); serverDone != nil { diff --git a/hack/util b/hack/util index d6d342d1e7673..e84928f801d07 100755 --- a/hack/util +++ b/hack/util @@ -14,7 +14,7 @@ if [ "$CONTINUOUS_INTEGRATION" = "true" ] || [ "$CI" = "true" ]; then progressFlag="--progress=plain" fi -buildmode="buildkit" +buildmode="docker-buildkit" buildxCmd() { if docker buildx version >/dev/null 2>&1; then set -x diff --git a/solver/errdefs/exit.go b/solver/errdefs/exit.go index 696fe25563eed..cab7709c57778 100644 --- a/solver/errdefs/exit.go +++ b/solver/errdefs/exit.go @@ -2,16 +2,6 @@ package errdefs import "fmt" -const ( - // ContainerdUnknownExitStatus is returned when containerd is unable to - // determine the exit status of a process. This can happen if the process never starts - // or if an error was encountered when obtaining the exit status, it is set to 255. - // - // This const is defined here to prevent importing github.com/containerd/containerd - // and corresponds with https://github.com/containerd/containerd/blob/40b22ef0741028917761d8c5d5d29e0d19038836/task.go#L52-L55 - ContainerdUnknownExitStatus = 255 -) - // ExitError will be returned when the container process exits with a non-zero // exit code. type ExitError struct { diff --git a/worker/tests/common.go b/worker/tests/common.go index 6160523df58b6..333de9c020100 100644 --- a/worker/tests/common.go +++ b/worker/tests/common.go @@ -22,7 +22,7 @@ import ( ) func NewBusyboxSourceSnapshot(ctx context.Context, t *testing.T, w *base.Worker, sm *session.Manager) cache.ImmutableRef { - img, err := source.NewImageIdentifier("docker.io/library/busybox:latest") + img, err := source.NewImageIdentifier("docker-hub.netflix.net/library/busybox:latest") require.NoError(t, err) src, err := w.SourceManager.Resolve(ctx, img, sm, nil) require.NoError(t, err)