fix(webservice): set puma to PID 1
What does this MR do?
What
- Update the
CMD
to be inexec form
- Use
exec
inside of theprocess-wrapper
so thatpuma
is not a child process and takes the PID of theprocess-wrapper
which is PID 1 to recive the termination signals.
Process tree before:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
git 67 2.0 0.0 5992 3728 pts/0 Ss 07:12 0:00 bash
git 74 0.0 0.0 8592 3228 pts/0 R+ 07:12 0:00 \_ ps faux
git 1 0.0 0.0 2420 532 ? Ss 07:11 0:00 /bin/sh -c /scripts/process-wrapper
git 19 0.0 0.0 5728 3320 ? S 07:11 0:00 /bin/bash /scripts/process-wrapper
git 22 0.0 0.0 2316 696 ? S 07:11 0:00 \_ xtail /var/log/gitlab
git 23 72.5 8.7 1264596 898288 ? Sl 07:11 1:06 \_ puma 5.6.2 (tcp://0.0.0.0:8080) [gitlab-puma-worker]
git 31 28.8 0.3 133132 32652 ? Sl 07:12 0:03 \_ ruby /srv/gitlab/bin/metrics-server
git 34 10.3 8.6 1332732 883160 ? Sl 07:12 0:01 \_ puma: cluster worker 0: 23 [gitlab-puma-worker]
git 36 8.9 8.5 1319928 874148 ? Sl 07:12 0:00 \_ puma: cluster worker 1: 23 [gitlab-puma-worker]
Process tree after:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
git 27 1.0 0.0 5992 3684 pts/0 Ss 07:59 0:00 bash
git 35 0.0 0.0 8592 3148 pts/0 R+ 07:59 0:00 \_ ps faux
git 1 89.7 8.7 1252280 890108 ? Rsl 07:58 1:10 puma 5.6.2 (tcp://0.0.0.0:8080) [gitlab-puma-worker]
git 21 0.0 0.0 2316 632 ? S 07:58 0:00 xtail /var/log/gitlab
Why
When we use CMD command param1 param2
(shell form) PID 1 is /bin/sh -c
so termination signals that are sent to the container such as SIGTERM it is sent
to /bin/sh
. This could lead to ungraceful termination of the process because
it never gets the signal it expects to start graceful termination. Using
CMD ["executable","param1","param2"]
(exec form, this is the preferred
form) will set the executable of CMD
as PID 1 which will in turn
make signal handling work as expected.
Related issues
gitlab-org/charts/gitlab#3249 (closed)
Checklist
See Definition of done.
For anything in this list which will not be completed, please provide a reason in the MR discussion
Required
-
Merge Request Title, and Description are up to date, accurate, and descriptive -
MR targeting the appropriate branch -
MR has a green pipeline on GitLab.com
Expected (please provide an explanation if not completing)
-
Test plan indicating conditions for success has been posted and passes -
Documentation created/updated -
Integration tests added to GitLab QA -
The impact any change in container size has should be evaluated
Edited by Jason Plum