Skip to content

Commit 3d63bad

Browse files
committed
address PR comments
1 parent 11ce370 commit 3d63bad

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

agent/agentcontainers/containers_dockercli.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,24 +310,20 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi
310310
// runDockerInspect is a helper function that runs `docker inspect` on the given
311311
// container IDs and returns the parsed output.
312312
// The stderr output is also returned for logging purposes.
313-
func runDockerInspect(ctx context.Context, execer agentexec.Execer, ids ...string) (stdout, stderr []byte, retErr error) {
313+
func runDockerInspect(ctx context.Context, execer agentexec.Execer, ids ...string) (stdout, stderr []byte, err error) {
314314
var stdoutBuf, stderrBuf bytes.Buffer
315315
cmd := execer.CommandContext(ctx, "docker", append([]string{"inspect"}, ids...)...)
316316
cmd.Stdout = &stdoutBuf
317317
cmd.Stderr = &stderrBuf
318-
err := cmd.Run()
318+
err = cmd.Run()
319319
stdout = bytes.TrimSpace(stdoutBuf.Bytes())
320320
stderr = bytes.TrimSpace(stderrBuf.Bytes())
321-
if err != nil {
322-
if bytes.Contains(stderr, []byte("No such object:")) {
323-
// This can happen if a container is deleted between the time we check for its existence and the time we inspect it.
324-
retErr = nil
325-
} else {
326-
retErr = err
327-
}
321+
if err != nil && bytes.Contains(stderr, []byte("No such object:")) {
322+
// This can happen if a container is deleted between the time we check for its existence and the time we inspect it.
323+
return stdout, stderr, nil
328324
}
329325

330-
return stdout, stderr, retErr
326+
return stdout, stderr, err
331327
}
332328

333329
// To avoid a direct dependency on the Docker API, we use the docker CLI

agent/agentcontainers/devcontainercli_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"os/exec"
1212
"path/filepath"
13-
"runtime"
1413
"strings"
1514
"testing"
1615

@@ -230,9 +229,6 @@ func TestDockerDevcontainerCLI(t *testing.T) {
230229
if os.Getenv("CODER_TEST_USE_DOCKER") != "1" {
231230
t.Skip("skipping Docker test; set CODER_TEST_USE_DOCKER=1 to run")
232231
}
233-
if runtime.GOOS != "linux" {
234-
t.Skip("Skipping on non-Linux OS")
235-
}
236232
if _, err := exec.LookPath("devcontainer"); err != nil {
237233
t.Fatal("this test requires the devcontainer CLI: npm install -g @devcontainers/cli")
238234
}

0 commit comments

Comments
 (0)