appsody / controller

Appsody controller running in the development container. This repo will be archived soon.
https://appsody.dev
Apache License 2.0
2 stars 12 forks source link

Windows 10 : ctrl-c doesn't remove the container #66

Closed tnixa closed 4 years ago

tnixa commented 4 years ago

Describe the bug I am sshing to my windows 10 system as jenkinstest user (non-Azure) and I have the shell set to git bash for ssh and when I do an appsody run and then do a ctrl-c to exit out of the run the container does not get removed...

[Container] App started on PORT 3000
[Container] [ControllerDebug] The watch interval is set to: 2s seconds.
[Info] Running command: docker stop express-dev
[Debug] CLI exit error is:  exit status 2
[Info] Closing down, development environment was interrupted.
jenkinstest@DESKTOP-GRG3EVR MINGW64 ~/projects/013020/express
$ ~/bats_temp/temp/src/github.com/appsody/appsody/build/appsody-0.0.0-windows-amd64.exe ps
CONTAINER ID    NAME            IMAGE                                   PORTS                                           STATUS
26cb6c891a52    express-dev     docker.io/appsody/nodejs-express:0.4    0.0.0.0:3000->3000/tcp, 0.0.0.0:9229->9229/tcp  Up 28 seconds
$ echo $SHELL
/c/program files/git/bin/bash.exe

To Reproduce Steps to reproduce the behavior:

  1. ssh jenkinstest@9.10.255.188
  2. mkdir express
  3. cd express
  4. appsody init nodejs-express
  5. appsody run
  6. ctrl-c

Environment Details (please complete the following information):

If applicable please specify:

tnixa commented 4 years ago

Testing this further and ctrl-c doesn't work on local windows git bash terminal or command prompt terminal. I tried to backlevel Docker Desktop to 2.1.0.5 and the problem was still there. I backleveled appsody to 0.5.4 and the problem went away (ctrl-c was killing the container). I then went up to appsody 0.5.5 and the problem came back. So it appears something was introduced in appsody 0.5.5 to cause ctrl-c to not work properly

kylegc commented 4 years ago

More testing today, and we found the issue is intermittent. It doesn't matter which version of appsody cli or controller or docker, the problem comes and goes.

The root cause is that the windows docker client immediately kills the container on ctrl-c rather than sending the signal inside and waiting for graceful cleanup. Our appsody cli tries to call docker stop, however the main thread ends so quickly that sometimes docker stop gets called and sometimes it doesn't.

I've implemented a fix in the CLI https://github.com/appsody/appsody/pull/875 which tells the main thread to wait if a signal processing thread is active. This resolves the issue on windows and does not impact other platforms as far as we know.

Alternatives we considered is passing -i to docker run which seems to change the way windows docker sends the signals. However we are not sure of other side effects which may occur when doing this.