Skip to content
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

docker: close response connection once stdin is exhausted #24202

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

shoenig
Copy link
Member

@shoenig shoenig commented Oct 14, 2024

This PR ensures we close the hijacked writer connection once there is no more data going into the stdin buffer of the exec'd command. Without this, the command (tar in this case) would hang forever awaiting more input.

Fixes #24171

Internal: NET-11378

@shoenig
Copy link
Member Author

shoenig commented Oct 17, 2024

Spot check e2e tests...

Nomad 1.9 hangs as expected:

➜ nomad version
Nomad v1.9.0
BuildDate 2024-10-10T07:13:43Z
Revision 7ad36851ec02f875e0814775ecf1df0229f0a615

➜ go test -v
=== RUN   TestDockerAllocExec
=== RUN   TestDockerAllocExec/testDockerExecStdin
    docker_exec_test.go:88:
        docker_exec_test.go:88: expected nil error
        ↪ error: context deadline exceeded
--- FAIL: TestDockerAllocExec (16.06s)
    --- FAIL: TestDockerAllocExec/testDockerExecStdin (16.06s)
FAIL
exit status 1
FAIL    github.com/hashicorp/nomad/e2e/allocexec        16.064s

With fix:

➜ nomad version
Nomad v1.9.1-dev
BuildDate 2024-10-17T14:46:04Z
Revision 98d35280d48052249f6667986d7777b682be923c

➜ go test -v
=== RUN   TestDockerAllocExec
=== RUN   TestDockerAllocExec/testDockerExecStdin
--- PASS: TestDockerAllocExec (6.15s)
    --- PASS: TestDockerAllocExec/testDockerExecStdin (6.15s)
PASS
ok      github.com/hashicorp/nomad/e2e/allocexec        6.158s

Copy link
Member

@tgross tgross left a comment

Choose a reason for hiding this comment

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

LGTM! Nice test!

@shoenig shoenig merged commit b188516 into main Oct 17, 2024
32 checks passed
@shoenig shoenig deleted the docker-exec-close-stdin-conn branch October 17, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.9.x+ent Changes are backported to 1.9.x+ent backport/1.9.x backport to 1.9.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression in Nomad 1.9.0: Stdin might not be closed in Docker exec
2 participants