-
Notifications
You must be signed in to change notification settings - Fork 883
all processes in container receive SIGTERM when sending SIGTERM to rkt process #3512
Comments
This is probably happening because the default systemd |
Possibly. But they would receive |
This issue has come up again for me. There's gotta be some kind of solution or workaround. I'm a big boy, I can handle my own signals, thankyouverymuch systemd. I really don't want to use Docker for my current problem. Or worse, not run in a container at all! |
There's a generated systemd
Why can't that single service have |
@blalor is this a pod with a single app inside? My understanding is that your root problem comes from the pod also being torn down with this single application. |
Yes, it's a single-application pod. I need the application to shut down in a controlled fashion, whereby the process launched by systemd is able to initiate cleanup and then notify child processes to exit. I can't do that if the child processes are told to terminate by systemd (and I'm unable to inhibit the child processes' SIGTERM handling). This is the second time I've run into this problem, which revolves around managing data for a stateful application. I'm currently attempting to get an Elasticsearch node to remove itself from the cluster by deallocating shards on shutdown. A wrapper script is responsible for starting and stopping the main ES process; when SIGTERM is received, it updates the cluster state to move shards away from the terminating node, waits for the shards to be relocated, and then sends SIGTERM to the main ES process. |
I'm not sure if this works, but you may as well try: instead of stopping the pod, just enter the running stage1 (via |
I'm working with containers scheduled via Nomad; that's not a viable production solution. I can test it on Monday against a running pod if you're looking for verification of the final config of the unit, but that's not something I can entertain in a production scenario. |
I started working on custom |
Environment
What did you do?
With the attached file at
/tmp/assassin.py
:In another window ¡ASSUMING THERE ARE NO OTHER CONTAINERS RUNNING!:
Wait for the container to exit. Then:
What did you expect to see?
What did you see instead?
What just happened here?
assassin.py
spawns 10 child processes. The parent and all the children write a log message whenever they receiveSIGTERM
, but they do not exit. The parent does not automatically propagate signals to its children (inhibited viaos.setpgrp()
). Therefore, sendingSIGTERM
to the parent process (or the process that spawned the container) should only result in a single log message being generated by the parent. This is in fact exactly what happens when you runassassin.py
in a terminal and send the parent processSIGTERM
from another terminal. rkt (or more likely systemd), on the other hand, sendsSIGTERM
to every single process in the container.This makes it very difficult for a process which spawns children to shut down properly when the container is being shut down, especially when trying to wrangle an application whose source you don't directly control. When combined with #2870, it is impossible to implement any kind of processing after the main application (process, whatever) has exited on command from the rkt runtime.
The text was updated successfully, but these errors were encountered: