Skip to content

Commit 056f0b7

Browse files
authored
Merge pull request #523 from mutagen-io/v019-development
docker: handle new error code delineation in Moby v28+
2 parents 2335240 + b7c1505 commit 056f0b7

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- uses: actions/checkout@v4
3232
- uses: actions/setup-go@v5
3333
with:
34-
go-version: '1.23.2'
34+
go-version: '1.23.6'
3535
- name: "Install sha256sum"
3636
run: brew install coreutils
3737
- run: scripts/ci/setup_go.sh
@@ -72,7 +72,7 @@ jobs:
7272
timeout-minutes: 30
7373
strategy:
7474
matrix:
75-
goversion: ['1.22.8', '1.23.2']
75+
goversion: ['1.22.12', '1.23.6']
7676
steps:
7777
- uses: actions/checkout@v4
7878
- uses: actions/setup-go@v5
@@ -93,7 +93,7 @@ jobs:
9393
- uses: actions/checkout@v4
9494
- uses: actions/setup-go@v5
9595
with:
96-
go-version: '1.23.2'
96+
go-version: '1.23.6'
9797
- run: scripts/ci/setup_go.sh
9898
shell: bash
9999
- run: scripts/ci/setup_docker.sh
@@ -127,7 +127,7 @@ jobs:
127127
- uses: actions/checkout@v4
128128
- uses: actions/setup-go@v5
129129
with:
130-
go-version: '1.23.2'
130+
go-version: '1.23.6'
131131
- uses: docker/setup-qemu-action@v3
132132
- uses: docker/setup-buildx-action@v3
133133
- uses: docker/login-action@v3

images/sidecar/linux/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Use an Alpine-based Go builder.
2-
FROM golang:1.23.2-alpine3.20 AS builder
2+
FROM golang:1.23.6-alpine3.21 AS builder
33

44
# Disable cgo in order to match the behavior of our release binaries (and to
55
# avoid the need for gcc on certain architectures).
@@ -21,7 +21,7 @@ RUN ["go", "build", "-o", "mutagen-agent-sspl", "-tags", "mutagenagent,mutagenss
2121

2222

2323
# Switch to a vanilla Alpine base for the final image.
24-
FROM alpine:3.20 AS base
24+
FROM alpine:3.21 AS base
2525

2626
# Copy the sidecar entry point from the builder.
2727
COPY --from=builder ["/mutagen/mutagen-sidecar", "/usr/bin/mutagen-sidecar"]

pkg/agent/transport/docker/transport.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,20 @@ func (t *dockerTransport) ClassifyError(processState *os.ProcessState, errorOutp
509509
return false, false, fmt.Errorf("unable to probe container: %w", err)
510510
}
511511

512+
// Check if the error code indicates that an agent installation attempt is
513+
// warranted. In Docker v28.0.0 and later, the exit codes for "invalid
514+
// command" and "command not found" are properly delineated (into 126 and
515+
// 127, respectively). Prior to that, they were both returned as 126. The
516+
// remainder of this comment applies to pre-v28.0.0 Docker versions and is
517+
// retained for posterity. It makes suggestions about how we might use these
518+
// delineated values to better detect Windows containers, which might be an
519+
// optimization worth pursuing at some point, but it would involve probing
520+
// the Docker engine version and adjusting behavior accordingly. Also, this
521+
// new delineated behavior might not apply on Windows, so we'd need to check
522+
// that first.
523+
//
524+
// For Docker pre-v28.0.0:
525+
//
512526
// Docker alises cases of both "invalid command" (POSIX shell error 126) and
513527
// "command not found" (POSIX shell error 127) to an exit code of 126. It
514528
// even aliases the Windows container equivalents of these errors to 126.
@@ -533,7 +547,8 @@ func (t *dockerTransport) ClassifyError(processState *os.ProcessState, errorOutp
533547
// Anyway, the exit code we need to look out for with both POSIX and Windows
534548
// containers is 126, and since we know the remote platform already, we can
535549
// return that information without needing to resort to the error string.
536-
if !process.IsPOSIXShellInvalidCommand(processState) {
550+
if !(process.IsPOSIXShellInvalidCommand(processState) ||
551+
process.IsPOSIXShellCommandNotFound(processState)) {
537552
return false, false, errors.New("unknown process exit error")
538553
}
539554

scripts/ci/docker/linux/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Set the base image.
2-
FROM alpine:3.20
2+
FROM alpine:3.21
33

44
# Add the HTTP demo server.
55
COPY ["httpdemo", "/httpdemo"]

0 commit comments

Comments
 (0)