-
Notifications
You must be signed in to change notification settings - Fork 18.6k
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
Calling ContainerExecAttach and ContainerExecStart will lead to unnoticed race condition #42408
Comments
Huge +1 to this - I've been doing the same create/attach/start call, had no idea that Attach actually started the command, and have my Execs fail very occasionally (maybe once very 20 runs), and only on CI where there's a larger lag between client & the Docker engine. Extra weirdness about this: when this bug shows up, the |
What's proposed here would be the same as doing a
The only possible alternative could be to make |
Making |
IIRC, |
Yep, it does perform the start (that's what causes this race condition)! It makes sense why it might do it that way, so making |
Would just removing these lines be enough to fix the issue? I'd like to make sure there wouldn't be other issues if I do that with a PR. Lines 169 to 172 in 3b423ea
In my case, I would like to attach to a single
If @thaJeztah 's comment above is true, could someone point me to what I would need to do to resolve this properly (by making I'm more than glad to submit a PR to fix this. |
Description
There is race condition calling the client api functions
ContainerExecAttach
andContainerExecStart
.Depending on the exec state a call to this APIs errors in docker daemon but this is not reflected on the docker client side.
If welcome I can create a PR which changes this behavior.
Steps to reproduce the issue:
ContainerExecCreate
ContainerExecAttach
ContainerExecStart
Describe the results you received:
The above call order is invalid, since
ContainerExecAttach
will implicitly start the execution and callingContainerExecStart
afterwards will run successfully.But in some cases the docker daemon responds with
Error: exec command xxx is already running
.Describe the results you expected:
The client should check if a command is already running prior to starting the command and fail if the call would be invalid, because the execution is already running.
Additional information you deem important (e.g. issue happens only occasionally):
This may sound like a nitpick according to the API, but I think it would be quite helpful to allow to use the API in the expected way.
Since the docker daemon returns an error, the client should return an error as well, either by checking upfront if the call is valid at all or by returning the error from the daemon.
Since this is a race condition (only happens sometimes), it was a hard to understand issue in act.
Output of
docker version
:Output of
docker info
:Additional environment details (AWS, VirtualBox, physical, etc.):
Using debian linux.
The text was updated successfully, but these errors were encountered: