refactor(gitlab-exporter): use CMD exec form
What does this MR do?
Related issues
What
- Update the CMD
to be in
exec form
rather thenshell form
so/bin/sh
isn't PID 1, and thepuma
process is set to PID 1. - Move the command into a
process-wrapper
script so that variable expansion works, since usingCMD []
will escape it.
Why
In gitlab-org/charts/gitlab#3249 (closed) we found
out that most containers don't have the main process as PID 1, so the
termination signal is not sent to the main application this results into
SIGKILL
being sent to the process rather then SIGTERM
.
We want to move the CMD exec form
for every container we develop for
consistency.
For testing I've used the example configuration in https://gitlab.com/gitlab-org/gitlab-exporter/-/blob/master/config/gitlab-exporter.yml.example
Process tree before:
ps faux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
git 22 0.0 0.0 8592 3228 ? Rs 12:16 0:00 ps faux
git 1 0.0 0.0 2420 596 ? Ss 12:16 0:00 /bin/sh -c /usr/bin/gitlab-exporter web -c ${CONFIG_DIRECTORY}/${CONFIG_FILENAME}
git 8 1.0 0.8 139716 32620 ? Sl 12:16 0:00 puma 5.6.2 (tcp://0.0.0.0:9168) [/]
Process tree after:
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
git 12 0.0 0.0 8592 3404 ? Rs 13:30 0:00 ps faux
git 1 0.0 0.8 139716 32632 ? Ssl 13:00 0:01 puma 5.6.2 (tcp://0.0.0.0:9168) [/]
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