Skip to content

refactor(gitaly): move gitaly process to pid 1

Steve Xuereb requested to merge fix/gitaly-pid into master

What does this MR do?

What

Move the gitaly process to be PID 1 inside of the container by using exec in start up script and CMD in exec form as well.

Why

In gitlab-org/charts/gitlab#3249 (closed) we found out that most image we build their main process doesn't run as PID 1. This can lead to issues where we assume SIGTERM is being sent to the process but it isn't, it's sent to the bash script that starts the process which doesn't redirect the signal to the gitaly process.

Process tree before:

git@gitlab-gitaly-0:/$ ps faux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
git        13477  0.5  0.0   5992  3764 pts/0    Ss   09:10   0:00 bash
git        13484  0.0  0.0   8592  3388 pts/0    R+   09:10   0:00  \_ ps faux
git            1  0.0  0.0   2420   584 ?        Ss   07:19   0:00 /bin/sh -c "/scripts/process-wrapper"
git           11  0.0  0.0   5728  3212 ?        S    07:19   0:00 /bin/bash /scripts/process-wrapper
git           12  0.2  1.1 1548072 118988 ?      Sl   07:19   0:14  \_ /usr/local/bin/gitaly /etc/gitaly/config.toml
git           23  0.2  0.8 368148 84104 ?        Sl   07:19   0:19  |   \_ ruby /srv/gitaly-ruby/bin/gitaly-ruby 12 /tmp/gitaly-304670354/sock.d/ruby.0
git           24  0.2  0.8 374292 85108 ?        Sl   07:19   0:19  |   \_ ruby /srv/gitaly-ruby/bin/gitaly-ruby 12 /tmp/gitaly-304670354/sock.d/ruby.1
git           13  0.0  0.0   2316   696 ?        S    07:19   0:00  \_ xtail /var/log/gitaly

Process tree after:

git@gitlab-gitaly-0:/$ ps faux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
git          102  0.0  0.0   5992  3800 pts/0    Ss   12:09   0:00 bash
git          110  0.0  0.0   8592  3220 pts/0    R+   12:09   0:00  \_ ps faux
git            1 38.7  1.4 1474020 148688 ?      Ssl  12:09   0:04 /usr/local/bin/gitaly /etc/gitaly/config.toml
git           12  0.0  0.0   2316   696 ?        S    12:09   0:00 xtail /var/log/gitaly
git           22 26.5  0.7 362516 77556 ?        Sl   12:09   0:01 ruby /srv/gitaly-ruby/bin/gitaly-ruby 1 /tmp/gitaly-3174026939/sock.d/ruby.1
git           23 26.5  0.7 362516 77968 ?        Sl   12:09   0:01 ruby /srv/gitaly-ruby/bin/gitaly-ruby 1 /tmp/gitaly-3174026939/sock.d/ruby.0

Related issues

Reference: 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

Merge request reports