exec-env/exec-file signal handling might be broken
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 23.1k
- Forks
- 1.1k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 9
Description
Hey folks,
We've encountered some issues after we started using exec-file for our software. For example, py.test being run with exec-file inside a docker container would terminate on sigterm immediately, whereas normally it prints test failures first, which is quite annoying.
I'm sorry that I can't provide a minimal reproducing case as we just started exporting secrets before running our process "naked", which solved those problems for us, but after looking through the sources my theory to why that's happening is as follows:
- docker starts a docker container with
sopsas its main process sopsspawns our process in a subprocess here https://github.com/mozilla/sops/blob/66043e71a81787d6513bc2e5505a29aac67dc6f1/cmd/sops/subcommand/exec/exec_unix.go#L15- the subprocess is in the same process group, which means both
sopsand the subprocess will receive incoming signals - we ask Docker to send sigterm (or sighup)
- Docker sends sigterm (or sighup) to that process group
sopsexits immediately- docker container is terminated immediately and no stdout is sent to the host
…which sounds similar to the problem someone was having in this blog post https://bigkevmcd.github.io/go/pgrp/context/2019/02/19/terminating-processes-in-go.html
If my understanding is correct, it's a subtle problem for a lot of software using sops. The solution would be for sops to spawn subprocess into a separate process group and pass signals on manually, waiting for the process to finish.
Thank your for your awesome piece of software!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with cmd/sops/subcommand/exec/exec_unix.go, the subprocess entry point referenced in the report, and compare exec-file behavior with the Docker and py.test signal scenario described. Reproduce the termination sequence if possible; done means the child process can finish and its output is preserved when the container receives SIGTERM or SIGHUP.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- cli, devops, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100