Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23bcd23

Browse files
committed
avoid disconnected error handling
1 parent 3d63bad commit 23bcd23

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

agent/agentcontainers/containers_dockercli.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,14 @@ func runDockerInspect(ctx context.Context, execer agentexec.Execer, ids ...strin
318318
err = cmd.Run()
319319
stdout = bytes.TrimSpace(stdoutBuf.Bytes())
320320
stderr = bytes.TrimSpace(stderrBuf.Bytes())
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
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+
return stdout, stderr, nil
325+
}
326+
return stdout, stderr, err
324327
}
325-
326-
return stdout, stderr, err
328+
return stdout, stderr, nil
327329
}
328330

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

0 commit comments

Comments
 (0)