You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Openshift router pod (docker container) doesn't reap zombie processes #1242
The openshift router pod running the openshift/origin-haproxy-router:v* image does not reap the haproxy zombie processes. Its probably not a big deal for now - but we will hit process limits when this list of unreaped children grows - dependent on how often the /var/lib/haproxy/reload-haproxy reload script is called.
In general, the 3rd option is most sane. We have systemd container for this, also supervisor and a few others. None of them are ideal. The important thing is that haproxy must know it is being restarted.
There may be a golang library already for acting as pid 1 - you should investigate that.
HAProxy knows it is being restarted, the old pid is stopped and is defunct. I think the issue is the parent process (the router plugin) doesn't care and isn't gathering the exit code so it lingers until the parent process stops (which running under init would do if it inherited the child).
But, I can do this without anything crazy or OS specific code if I have the restart script pass back the old pid and do something like this in a go routine:
I haven't run across any "do it for you" solutions. I did find a similar issue that led me to the SIGCHLD solution that was OS specific. I will look again since I was mainly searching for reaping with our process acting as pid 1.
HAProxy knows it is being restarted, the old pid is stopped and is defunct. I think the issue is the parent process (the router plugin) doesn't care and isn't gathering the exit code so it lingers until the parent process stops (which running under init would do if it inherited the child).
But, I can do this without anything crazy or OS specific code if I have the restart script pass back the old pid and do something like this in a go routine:
proc, e := os.FindProcess(int(pid))
proc.Wait()
if that seems reasonable. Preliminary testing seems to work fine.
I haven't run across any "do it for you" solutions. I did find a similar issue that led me to the SIGCHLD solution that was OS specific. I will look again since I was mainly searching for reaping with our process acting as pid 1.
—
Reply to this email directly or view it on GitHub.
My preferred solution here would be a simple addition to our Go binaries which detect when they are PID 1 and enable a simple minimal behavior for reaping (Wait on child processes in a goroutine) and proper signal handling. Docker may already have this from the old dockerinit code - I'd be surprised if someone hasn't handled it. @mrunalp you aware of anything like that?
@smarterclayton delved into that last week in lib container. Should be possible to put something together. I will take a closer look at the router tomorrow and see what we can do.
@smarterclayton@mrunalp - that doesn't seem too difficult. I will wait to see if Mrunal knows of something already done. I looked at runsit, it seems to do the trick but makes setting up the image a little less obvious. Still solvable but if we'd prefer a simpler solution (I would) then I won't spend more time diving in.
@mrunalp - let me know if there is anything I can do to help
@pweil- I am going to prototype what @smarterclayton suggested; basically make the process act as a simple init that reaps zombies. If it works reliably, then we can use that else look for a real init.
@mrunalp - this may not be the ideal implementation since it doesn't catch /any/ child process but it seemed to work fine for me as a general solution. master...pweil-:router-reaper . It was my prototype for option 2 in the comment above
Activity
ramr commentedon Mar 6, 2015
@pweil- fyi.
smarterclayton commentedon Mar 6, 2015
Sigh
pweil- commentedon Mar 6, 2015
Hrm, well that's troublesome since we're checking for a pid file and sending finish signals in the restart if we found it:
pweil- commentedon Mar 6, 2015
Some thoughts:
cc @pmorie
smarterclayton commentedon Mar 6, 2015
In general, the 3rd option is most sane. We have systemd container for this, also supervisor and a few others. None of them are ideal. The important thing is that haproxy must know it is being restarted.
There may be a golang library already for acting as pid 1 - you should investigate that.
pweil- commentedon Mar 6, 2015
@smarterclayton
HAProxy knows it is being restarted, the old pid is stopped and is defunct. I think the issue is the parent process (the router plugin) doesn't care and isn't gathering the exit code so it lingers until the parent process stops (which running under init would do if it inherited the child).
But, I can do this without anything crazy or OS specific code if I have the restart script pass back the old pid and do something like this in a go routine:
if that seems reasonable. Preliminary testing seems to work fine. Full test code: master...pweil-:router-reaper
I haven't run across any "do it for you" solutions. I did find a similar issue that led me to the SIGCHLD solution that was OS specific. I will look again since I was mainly searching for reaping with our process acting as pid 1.
smarterclayton commentedon Mar 6, 2015
There's a golang process manager written by brad fitz. It's worth a look.
pweil- commentedon Mar 6, 2015
checking out dinit, and baseimage-docker. Will check that one out too.
smarterclayton commentedon Mar 6, 2015
BaseImage docker is a terrible pattern
pweil- commentedon Mar 6, 2015
rm -Rf pauls_brain/baseimage-dockersmarterclayton commentedon Mar 9, 2015
My preferred solution here would be a simple addition to our Go binaries which detect when they are PID 1 and enable a simple minimal behavior for reaping (Wait on child processes in a goroutine) and proper signal handling. Docker may already have this from the old dockerinit code - I'd be surprised if someone hasn't handled it. @mrunalp you aware of anything like that?
mrunalp commentedon Mar 9, 2015
@smarterclayton delved into that last week in lib container. Should be possible to put something together. I will take a closer look at the router tomorrow and see what we can do.
pweil- commentedon Mar 9, 2015
@smarterclayton @mrunalp - that doesn't seem too difficult. I will wait to see if Mrunal knows of something already done. I looked at runsit, it seems to do the trick but makes setting up the image a little less obvious. Still solvable but if we'd prefer a simpler solution (I would) then I won't spend more time diving in.
@mrunalp - let me know if there is anything I can do to help
mrunalp commentedon Mar 9, 2015
@pweil- I am going to prototype what @smarterclayton suggested; basically make the process act as a simple init that reaps zombies. If it works reliably, then we can use that else look for a real init.
pweil- commentedon Mar 9, 2015
@mrunalp - this may not be the ideal implementation since it doesn't catch /any/ child process but it seemed to work fine for me as a general solution. master...pweil-:router-reaper . It was my prototype for option 2 in the comment above
smarterclayton commentedon Mar 14, 2015
Fixt
Squashed 'cmd/service-catalog/go/src/github.com/kubernetes-incubator/…
Squashed 'cmd/service-catalog/go/src/github.com/kubernetes-incubator/…
fix lint errors (openshift#1242)