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

[BUG] Alpine image doesn't reap zombie processes #681

Closed
rofafor opened this issue Jun 28, 2023 · 0 comments · Fixed by #682
Closed

[BUG] Alpine image doesn't reap zombie processes #681

rofafor opened this issue Jun 28, 2023 · 0 comments · Fixed by #682

Comments

@rofafor
Copy link
Contributor

rofafor commented Jun 28, 2023

Describe the bug

KeyDB Helm chart is using wrapper shell scripts for k8s liveness/readiness probes. Each execution will leave a defunct process as init process (keydb-server) isn't reaping zombie processes. Pods will eventually be restarted as no new processes can be forked anymore.

To reproduce

% docker run -d --rm eqalpha/keydb:alpine_x86_64_v6.3.3
ebd2a9ecec577986486b3a064036808e3cf8ebff45c93467e6d4fd2d72f4780d

% docker exec -it ebd2a9ecec577986486b3a064036808e3cf8ebff45c93467e6d4fd2d72f4780d sh
/data # ps aux
PID   USER     TIME  COMMAND
    1 keydb     0:00 keydb-server *:6379
   23 root      0:00 sh
   29 root      0:00 ps aux
/data # timeout -s 15 5 keydb-cli -h localhost -p 6379 PING
PONG
/data # ps aux
PID   USER     TIME  COMMAND
    1 keydb     0:00 keydb-server *:6379
   23 root      0:00 sh
   32 root      0:00 [timeout]
   33 root      0:00 ps aux
/data # timeout -s 15 5 keydb-cli -h localhost -p 6379 PING
PONG
/data # ps aux
PID   USER     TIME  COMMAND
    1 keydb     0:00 keydb-server *:6379
   23 root      0:00 sh
   32 root      0:00 [timeout]
   36 root      0:00 [timeout]
   37 root      0:00 ps aux
/data #

Expected behavior

Similar as within Ubuntu based image:

% docker run -d --rm eqalpha/keydb:x86_64_v6.3.3
3979bba50756a12402d403631d8519fe74a2c7d1e2a4db02a015c2c61b53f84d

% docker exec -it 3979bba50756a12402d403631d8519fe74a2c7d1e2a4db02a015c2c61b53f84d sh
# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
keydb        1  1.6  0.1 254448 15240 ?        Ssl  14:36   0:00 keydb-server *:6379
root        29  1.0  0.0   4640   788 pts/0    Ss   14:36   0:00 sh
root        35  0.0  0.0  34416  2864 pts/0    R+   14:36   0:00 ps aux
# timeout -s 15 5 keydb-cli -h localhost -p 6379 PING
PONG
# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
keydb        1  1.4  0.1 254448 15240 ?        Ssl  14:36   0:00 keydb-server *:6379
root        29  0.1  0.0   4640   788 pts/0    Ss   14:36   0:00 sh
root        38  0.0  0.0  34416  2860 pts/0    R+   14:36   0:00 ps aux
# timeout -s 15 5 keydb-cli -h localhost -p 6379 PING
PONG
# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
keydb        1  1.5  0.1 254448 15236 ?        Ssl  14:36   0:00 keydb-server *:6379
root        29  0.1  0.0   4640   788 pts/0    Ss   14:36   0:00 sh
root        41  0.0  0.0  34416  2916 pts/0    R+   14:37   0:00 ps aux
#

Additional information

This can be fixed by using tini as init wrapper:

% cat Dockerfile
FROM eqalpha/keydb:alpine_x86_64_v6.3.3
RUN apk add --no-cache tini
ENTRYPOINT ["tini", "--", "docker-entrypoint.sh"]
CMD ["keydb-server", "/etc/keydb/keydb.conf"]

% docker build -t keydb:alpine_tini .
[+] Building 0.1s (6/6) FINISHED
 => [internal] load .dockerignore                                                                                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                                                                                          0.0s
 => [internal] load build definition from Dockerfile                                                                                                                                                                     0.0s
 => => transferring dockerfile: 173B                                                                                                                                                                                     0.0s
 => [internal] load metadata for docker.io/eqalpha/keydb:alpine_x86_64_v6.3.3                                                                                                                                            0.0s
 => [1/2] FROM docker.io/eqalpha/keydb:alpine_x86_64_v6.3.3                                                                                                                                                              0.0s
 => CACHED [2/2] RUN apk add --no-cache tini                                                                                                                                                                             0.0s
 => exporting to image                                                                                                                                                                                                   0.0s
 => => exporting layers                                                                                                                                                                                                  0.0s
 => => writing image sha256:acdd5665b2a90b814f1bb7aaab1868ccf9071dfd69763b72b269a965317dc4f6                                                                                                                             0.0s
 => => naming to docker.io/library/keydb:alpine_tini
 
% docker run -d --rm keydb:alpine_tini
c84eba1de6ea46d0e9482d1cf69a7134a51ee4851f8fc361d88d62be489f5787

% docker exec -it c84eba1de6ea46d0e9482d1cf69a7134a51ee4851f8fc361d88d62be489f5787 sh
/data # ps aux
PID   USER     TIME  COMMAND
    1 root      0:00 tini -- docker-entrypoint.sh keydb-server /etc/keydb/keydb.conf
    7 keydb     0:00 keydb-server *:6379
   24 root      0:00 sh
   30 root      0:00 ps aux
/data # timeout -s 15 5 keydb-cli -h localhost -p 6379 PING
PONG
/data # ps aux
PID   USER     TIME  COMMAND
    1 root      0:00 tini -- docker-entrypoint.sh keydb-server /etc/keydb/keydb.conf
    7 keydb     0:00 keydb-server *:6379
   24 root      0:00 sh
   34 root      0:00 ps aux
/data # timeout -s 15 5 keydb-cli -h localhost -p 6379 PING
PONG
/data # ps aux
PID   USER     TIME  COMMAND
    1 root      0:00 tini -- docker-entrypoint.sh keydb-server /etc/keydb/keydb.conf
    7 keydb     0:00 keydb-server *:6379
   24 root      0:00 sh
   38 root      0:00 ps aux
/data #
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