diff --git a/agent/agentcontainers/containers_dockercli.go b/agent/agentcontainers/containers_dockercli.go index e7364125b8e0f..3842735116329 100644 --- a/agent/agentcontainers/containers_dockercli.go +++ b/agent/agentcontainers/containers_dockercli.go @@ -59,6 +59,11 @@ func (dcl *DockerCLILister) List(ctx context.Context) (codersdk.WorkspaceAgentLi } dockerPsStderr := strings.TrimSpace(stderrBuf.String()) + if len(ids) == 0 { + return codersdk.WorkspaceAgentListContainersResponse{ + Warnings: []string{dockerPsStderr}, + }, nil + } // now we can get the detailed information for each container // Run `docker inspect` on each container ID diff --git a/agent/agentcontainers/containers_internal_test.go b/agent/agentcontainers/containers_internal_test.go index b9f34261ddcad..e15deae54c2bd 100644 --- a/agent/agentcontainers/containers_internal_test.go +++ b/agent/agentcontainers/containers_internal_test.go @@ -2,8 +2,7 @@ package agentcontainers import ( "fmt" - "os/exec" - "runtime" + "os" "strconv" "strings" "testing" @@ -27,15 +26,14 @@ import ( // dockerCLIContainerLister.List method. It starts a container with a known // label, lists the containers, and verifies that the expected container is // returned. The container is deleted after the test is complete. +// As this test creates containers, it is skipped by default. +// It can be run manually as follows: +// +// CODER_TEST_USE_DOCKER=1 go test ./agent/agentcontainers -run TestDockerCLIContainerLister func TestDockerCLIContainerLister(t *testing.T) { t.Parallel() - if runtime.GOOS != "linux" { - t.Skip("creating containers on non-linux runners is slow and flaky") - } - - // Conditionally skip if Docker is not available. - if _, err := exec.LookPath("docker"); err != nil { - t.Skip("docker not found in PATH") + if ctud, ok := os.LookupEnv("CODER_TEST_USE_DOCKER"); !ok || ctud != "1" { + t.Skip("Set CODER_TEST_USE_DOCKER=1 to run this test") } pool, err := dockertest.NewPool("") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy