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

[19.03 backport] Do not disable sig-proxy when using a TTY #2177

Merged
merged 3 commits into from
Nov 5, 2019

Conversation

thaJeztah
Copy link
Member

backport of:

This partially reverts moby/moby@e0b59ab (moby/moby#2426), and does not automatically disable proxying signals in TTY-mode

fixes moby/moby#28872 (docker client doesn't pass signals when a terminal is attached)
fixes moby/moby#3793 docker client not passing signals to dockerd

relates to:

Before this change:

Start a container with a TTY in one shell:

docker run -it --init --name repro-28872 busybox sleep 30

then, in another shell, kill the docker cli:

kill `pgrep -f repro-28872`

Notice that the CLI was killed, but the signal not forwarded to the container;
the container continues running

docker container inspect --format '{{ .State.Status }}' repro-28872
running

docker container rm -f repro-28872

After this change:

Start a container with a TTY in one shell:

docker run -it --init --name repro-28872 busybox sleep 30

then, in another shell, kill the docker cli:

kill `pgrep -f repro-28872`

Verify that the signal was forwarded to the container, and the container exited

docker container inspect --format '{{ .State.Status }}' repro-28872
exited

docker container rm -f repro-28872

- Description for the changelog

- Fix docker client doesn't pass signals when a terminal is attached

- A picture of a cute animal (not mandatory but encouraged)

thaJeztah and others added 3 commits October 29, 2019 15:19
This partially reverts moby/moby@e0b59ab,
and does not automatically disable proxying signals in TTY-mode

Before this change:
------------------------------------

Start a container with a TTY in one shell:

```
docker run -it --init --name repro-28872 busybox sleep 30
```

then, in another shell, kill the docker cli:

```
kill `pgrep -f repro-28872`
```

Notice that the CLI was killed, but the signal not forwarded to the container;
the container continues running

```
docker container inspect --format '{{ .State.Status }}' repro-28872
running

docker container rm -f repro-28872
```

After this change:
------------------------------------

Start a container with a TTY in one shell:

```
docker run -it --init --name repro-28872 busybox sleep 30
```

then, in another shell, kill the docker cli:

```
kill `pgrep -f repro-28872`
```

Verify that the signal was forwarded to the container, and the container exited

```
docker container inspect --format '{{ .State.Status }}' repro-28872
exited

docker container rm -f repro-28872
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit ee29504)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Add a test to verify that killing the docker CLI forwards
the signal to the container. Test-case for moby/moby 28872

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7cf1a8d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
exec.CombinedOutput should not be used here because:
 - it redirects cmd Stdout and Stderr and we want it to be the tty
 - it calls cmd.Run which we already did

While at it
 - use pty.Start() as it is cleaner
 - make sure we don't leave a zombie running, by calling Wait() in defer
 - use test.Name() for containerName

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit bc4ed69)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewhsu andrewhsu merged commit 99c5edc into docker:19.03 Nov 5, 2019
@thaJeztah thaJeztah deleted the 19.03_backport_fix_sig_proxy branch November 5, 2019 00:58
@ANogin
Copy link

ANogin commented Dec 14, 2019

Note that this change in behavior could be a very unpleasant surprise for people, particularly as it relates to SIGHUP. I am used to running very long-term jobs on a remote machine, under docker. I would ssh into the machine, start a container, suspend my laptop, and then later ssh back in and attach to the still-running container to see the job status. But suddenly all my jobs started disappearing! Turned out that this change suddenly meant that SIGHUPs from ssh connections dying were propagating into the containers and killing them! I would recommend specifically mentioning this difference in changelog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants