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

Cancelled jobs leave containers running #127

Closed
lox opened this issue Jun 1, 2019 · 3 comments · Fixed by #129
Closed

Cancelled jobs leave containers running #127

lox opened this issue Jun 1, 2019 · 3 comments · Fixed by #129

Comments

@lox
Copy link
Contributor

lox commented Jun 1, 2019

We've had reports that long running scripts run in the docker plugin leave the container running when the job is cancelled.

I verified this with this gist: https://gist.github.com/lox/045a4b56a0c1e1c815fd011657c34b46/708574c0b0ff9ec8748d2cd736de31951da555cb

The output looks like:
image

For some context, the agent initiates cancellation and sends a SIGTERM to the process group of buildkite-agent bootstrap that is executing the job.

It appears that docker run doesn't like being SIGTERM'd and terminates without stopping the container. My previous understanding was that docker run would proxy signals through to the container, and whilst there were some caveats around how pid 1 operates, it should be ok with the --init flag or a tini entrypoint, however, that doesn't seem to be accurate.

DarkDimius added a commit to sorbet/sorbet-build-image that referenced this issue Jun 2, 2019
@lox lox changed the title Job cancellation doesn't clean up containers correctly if they don't correctly Cancelled jobs leave containers running Jun 2, 2019
@lox
Copy link
Contributor Author

lox commented Jun 2, 2019

moby/moby#9098 (comment):

The root cause is when using --tty signal proxying is entirely disabled with no way to enable it (even with --sig-proxy).

🤦🏼‍♂️

@lox
Copy link
Contributor Author

lox commented Jun 2, 2019

Breakage was introduced in 2013, and there is an open patch to moby at docker/cli#1841.

@lox
Copy link
Contributor Author

lox commented Jun 2, 2019

I'll fix this with a pre-exit hook that calls:

docker kill --signal=SIGTERM my_container
docker rm -v my_container

@lox lox closed this as completed in #129 Jun 3, 2019
DarkDimius added a commit to sorbet/sorbet that referenced this issue Jun 5, 2019
* Move linux release build to elastic ci

* Run linters on linux cloud

* Run coverage on linux in cloud

* Build sorbet-runtime on linux

* Build website on linux

* Run linux tests in cloud

* This is part of dockerfile now

* It's hard even for me to remember what builds already are cloud-powered.

Mark them

* Update comment

* Dedup configs

* Move non-security related hooks into repo

* Update docker plugin to have a fix for

buildkite-plugins/docker-buildkite-plugin#127

* Debug coverage

* Soft-fail coverage
stevendanna added a commit to chef/automate that referenced this issue Jul 25, 2019
This moves us back to the linux executor with a docker based studio.
We are moving back because of

buildkite-plugins/docker-buildkite-plugin#127

which is still present in the build that we have.

Signed-off-by: Steven Danna <steve@chef.io>
stevendanna added a commit to chef/automate that referenced this issue Jul 25, 2019
This moves us back to the linux executor with a docker based studio.
We are moving back because of

buildkite-plugins/docker-buildkite-plugin#127

which is still present in the build that we have.

Signed-off-by: Steven Danna <steve@chef.io>
stevendanna added a commit to chef/automate that referenced this issue Jul 25, 2019
This moves us back to the linux executor with a docker based studio.
We are moving back because of

buildkite-plugins/docker-buildkite-plugin#127

which is still present in the build that we have.

Signed-off-by: Steven Danna <steve@chef.io>
stevendanna added a commit to chef/automate that referenced this issue Jul 25, 2019
This moves us back to the linux executor with a docker based studio.
We are moving back because of

buildkite-plugins/docker-buildkite-plugin#127

which is still present in the build that we have.

Signed-off-by: Steven Danna <steve@chef.io>
stevendanna added a commit to chef/automate that referenced this issue Jul 25, 2019
This moves us back to the linux executor with a docker based studio.
We are moving back because of

buildkite-plugins/docker-buildkite-plugin#127

which is still present in the build that we have.

Signed-off-by: Steven Danna <steve@chef.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant