Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(agent/agentcontainers): handle race between docker ps and docker inspect#17447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 5 commits intomainfromcj/flake/exp-rpty-container
Apr 17, 2025

Conversation

johnstcn
Copy link
Member

Comment on lines 231 to 243
// DockerCLILister is a ContainerLister that lists containers using the docker CLI
type DockerCLILister struct {
execer agentexec.Execer
}

var _ Lister = &DockerCLILister{}

func NewDocker(execer agentexec.Execer, opts ...func(*DockerCLILister)) Lister {
return &DockerCLILister{
execer: agentexec.DefaultExecer,
}
}

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

review: just moved down a bit closer to the method definitions

Comment on lines 233 to 238
if runtime.GOOS != "linux" {
t.Skip("Skipping on non-Linux OS")
}
if _, err := exec.LookPath("devcontainer"); err != nil {
t.Fatal("this test requires the devcontainer CLI: npm install -g @devcontainers/cli")
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

review: I didn't look too closely into what was actually going on here, but I suspect it's related to path differences between the host and the Docker VM on MacOS/Windows.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I've run this on macOS as well, so IMO we could allow that, but agree that we need to verify the devcontainer CLI here, good add 👍🏻

Comment on lines 233 to 238
if runtime.GOOS != "linux" {
t.Skip("Skipping on non-Linux OS")
}
if _, err := exec.LookPath("devcontainer"); err != nil {
t.Fatal("this test requires the devcontainer CLI: npm install -g @devcontainers/cli")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I've run this on macOS as well, so IMO we could allow that, but agree that we need to verify the devcontainer CLI here, good add 👍🏻

@johnstcn
Copy link
MemberAuthor

I've run this on macOS as well, so IMO we could allow that

Interesting, so "works on my machine" 🤔 I tried to figure out what the root cause was on my end, but the error returned bydevcontainer-cli is not terribly useful:

          Error Trace:/Users/cian/src/coder/coder/agent/agentcontainers/devcontainercli_test.go:256            Error:      Received unexpected error:                        exit status 1                        devcontainer up failed: error (description: An error occurred setting up the container., message: Command failed: docker run --sig-proxy=false -a STDOUT -a STDERR --mount type=bind,source=/tmp/nix-shell.56XzZC/TestDockerDevcontainerCLIContainerLifecycle1281021640/001,target=/workspaces/001,consistency=cached -l devcontainer.local_folder=/tmp/nix-shell.56XzZC/TestDockerDevcontainerCLIContainerLifecycle1281021640/001 -l devcontainer.config_file=/tmp/nix-shell.56XzZC/TestDockerDevcontainerCLIContainerLifecycle1281021640/001/.devcontainer/devcontainer.json -e TEST_CONTAINER=true --label com.coder.test=devcontainercli --entrypoint /bin/sh -l devcontainer.metadata=[{"containerEnv":{"TEST_CONTAINER":"true"}}] alpine:latest -c echo Container started

@johnstcnjohnstcn requested a review frommafredriApril 17, 2025 12:01
@mafredri
Copy link
Member

@johnstcn interesting, here's me on macOS:

❯ CODER_TEST_USE_DOCKER=1 go test ./agent/agentcontainers -count=1ok      github.com/coder/coder/v2/agent/agentcontainers 4.978s

Perhaps it's a Nix issue?

@johnstcn
Copy link
MemberAuthor

@johnstcn interesting, here's me on macOS:

❯ CODER_TEST_USE_DOCKER=1 go test ./agent/agentcontainers -count=1ok      github.com/coder/coder/v2/agent/agentcontainers 4.978s

Perhaps it's a Nix issue?

It happens outside the nix environment as well, strangely enough 🤷

return stdout, stderr, err
if err != nil && bytes.Contains(stderr, []byte("No such object:")) {
// This can happen if a container is deleted between the time we check for its existence and the time we inspect it.
return stdout, stderr, nil
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change

Nit: Ideally I'd like to avoid disconnected err handling (code slipping in betweenerr := andreturn err due to whitespace), but I'll settle for removing the newline.

(Preferable, but not required: return explicitly either nil or err fromif err != nil-block.)

@mafredri
Copy link
Member

It happens outside the nix environment as well, strangely enough 🤷

Then it's probably a matter of your Docker configuration, you might have to add/tmp to allowed paths.

@johnstcnjohnstcn merged commit6a79965 intomainApr 17, 2025
29 checks passed
@johnstcnjohnstcn deleted the cj/flake/exp-rpty-container branchApril 17, 2025 12:50
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 17, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

flake: TestExpRpty/Container
2 participants
@johnstcn@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp