Shell executor killed on system shutdown when managed by systemd
Summary
When you have gitlab-runner as a systemd service and the machine is turned off, the jobs are killed immediately with no graceful termination causing failed jobs.
Steps to reproduce
-
Start an ubuntu machine for example:
gcloud compute instances create steveazz-ubuntu --image ubuntu-2004-focal-v20210315 --image-project ubuntu-os-cloud
-
Edit the unit file with a drop-in override specifying the following
cat /etc/systemd/system/gitlab-runner.service.d/override.conf
cat /etc/systemd/system/gitlab-runner.service.d/override.conf [Service] TimeoutStopSec=7200 KillSignal=SIGQUIT
-
Start a job
-
Run
shutdown -h
Actual behavior
Expected behavior
Job finishes gracefully and not fail
Used GitLab Runner version
v13.9.0