yyyar / gobetween

:cloud: Modern & minimalistic load balancer for the Сloud era
http://gobetween.io
Other
1.94k stars 210 forks source link

exec healthcheck does not close bash #336

Open colaH16 opened 8 months ago

colaH16 commented 8 months ago

I am using exec to do a healthcheck. Using multiple servers in config file doesn't matter. However, if I have multiple backend static_lists for each server, some processes are left behind.

The Docker image provided is based on the scratch image. Therefore, there is no /bin/bash. I just changed the base image and docker build to use it.

# HOST> pstree
systemd─┬─ModemManager───3*[{ModemManager}]
        ├─NetworkManager───3*[{NetworkManager}]
        ├─2*[agetty]
        ├─auditd─┬─sedispatch
        │        └─2*[{auditd}]
        ├─chronyd
        ├─cloudflared───8*[{cloudflared}]
        ├─containerd-shim─┬─s6-svscan─┬─s6-supervise───s6-linux-init-s
        │                 │           ├─s6-supervise───s6-ipcserverd
        │                 │           ├─s6-supervise
        │                 │           ├─s6-supervise───busybox
        │                 │           ├─s6-supervise───nginx─┬─2*[nginx───160*[{nginx}]]
        │                 │           │                      └─nginx
        │                 │           └─s6-supervise───php-fpm82───8*[php-fpm82]
        │                 └─12*[{containerd-shim}]
        ├─containerd-shim─┬─gobetween─┬─1361*[bash]
        │                 │           └─11*[{gobetween}]
        │                 └─10*[{containerd-shim}]

1361 processes. Keep growing, and healthcheck failed

# docker> ps -A -o pid,ppid,pgid,sid,command | grep -F '[bash] <defunct>' | grep -v grep 
29941 27748 29933 29919 [bash] <defunct>
29942 27748 29937 29925 [bash] <defunct>
29988 27748 29977 29970 [bash] <defunct>
29993 27748 29983 29971 [bash] <defunct>
30004 27748 29998 29981 [bash] <defunct>
30005 27748 30000 29982 [bash] <defunct>
30041 27748 30029 30016 [bash] <defunct>
30043 27748 30033 30017 [bash] <defunct>
30083 27748 30077 30065 [bash] <defunct>
30088 27748 30084 30068 [bash] <defunct>
30092 27748 30090 30073 [bash] <defunct>
30093 27748 30076 30064 [bash] <defunct>
30096 27748 30094 30072 [bash] <defunct>
30137 27748 30129 30126 [bash] <defunct>
30155 27748 30148 30138 [bash] <defunct>
30158 27748 30149 30134 [bash] <defunct>
30161 27748 30152 30131 [bash] <defunct>
30199 27748 30195 30175 [bash] <defunct>
30200 27748 30189 30173 [bash] <defunct>
30204 27748 30194 30182 [bash] <defunct>
30243 27748 30232 30225 [bash] <defunct>
30249 27748 30245 30227 [bash] <defunct>
colaH16 commented 8 months ago

here is my healtch check script

#!/bin/bash

# udp=$2
tcp=` expr $2 - 2`

if `timeout 0.1s /bin/bash -c "cat < /dev/null > /dev/tcp/$1/$tcp" ` ; then echo -n 0; else echo -n 1; fi
#return 0;
exit