Skip to content

Commit

Permalink
move UnknownExitStatus to gateway client package from errdefs
Browse files Browse the repository at this point in the history
Signed-off-by: Cory Bennett <[email protected]>
  • Loading branch information
coryb committed Nov 22, 2020
1 parent dec4da0 commit 5b5c7f9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 16 deletions.
3 changes: 2 additions & 1 deletion executor/containerdexecutor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion executor/runcexecutor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions frontend/gateway/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion frontend/gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion frontend/gateway/grpcclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion hack/util
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions solver/errdefs/exit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion worker/tests/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5b5c7f9

Please sign in to comment.