Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 17, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
avoid disconnected error handling
  • Loading branch information
johnstcn committed Apr 17, 2025
commit 23bcd23268c9ca8d9c42d39793e61ebdfc0f6a34
12 changes: 7 additions & 5 deletions agent/agentcontainers/containers_dockercli.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,14 @@ func runDockerInspect(ctx context.Context, execer agentexec.Execer, ids ...strin
err = cmd.Run()
stdout = bytes.TrimSpace(stdoutBuf.Bytes())
stderr = bytes.TrimSpace(stderrBuf.Bytes())
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
if err != nil {
if 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
}
return stdout, stderr, err
}

return stdout, stderr, err
return stdout, stderr, nil
}

// To avoid a direct dependency on the Docker API, we use the docker CLI
Expand Down
Loading