Skip to content

Support graceful process termination for GitLab Runner on Windows

Release notes

The ability to enable graceful shutdown on Windows is now available behind a feature flag. To enable, set the feature flag FF_USE_WINDOWS_LEGACY_PROCESS_STRATEGY to false.

Overview

Currently "graceful shutdown" - understood as Runner waiting for all executed jobs to exit before Runner process itself is finished - is supported only for Unix systems, where SIGQUIT signal can be sent to the process. Windows doesn't have such concept and currently process termination triggers the force-shutdown strategy where all executed jobs are interrupted.

We should start supporting "graceful shutdown" also for Windows.

Proposal

Introduce an optional way to turn down GitLab Runner in a three-times-interrupt strategy:

  1. Graceful waiting for jobs to finish and not accepting new jobs.
    • First interrupt call (whether it's done by a Signal in Unix way or in the native Window way): would transfer runner to the graceful shutdown state. As a reminder: no new jobs are being requested and runner waits to finish all already handled jobs.
  2. More forceful shutdown, ensuring all jobs are killed.
    • Second interrupt call that stops the graceful shutdown and forces runner to immediately stop all jobs. GitLAb Runner waits for the job to exit before turning down.
  3. Really forceful, kill Runner process and don't worry about jobs that might still be running.
    • Third interrupt call immediately stops runner process and ignores the running jobs.

Detailed discussion here.

Edited by Darren Eastman