Fix(packaging): prevent pre-remove script aborting when service not installed

What does this MR do?

Prevents the pre-remove and post-install packaging scripts from aborting when gitlab-runner status returns a non-zero exit code (e.g., when the service is not installed or service management is unavailable).

Why was this MR needed?

In packaging/root/usr/share/gitlab-runner/pre-remove and post-install, check_service_management previously toggled set +e and set -e around error_output=$(gitlab-runner status 2>&1). Under set -e, subshell command assignment can still cause the script to fail and abort package removal/upgrade when gitlab-runner status exits with a non-zero exit code.

Additionally, gitlab-runner stop and gitlab-runner uninstall in pre-remove could fail and block package removal if the runner service wasn't installed.

What's the best way to test this MR?

  1. Build Linux DEB/RPM packages (make package).
  2. Install the package without starting/registering the runner service.
  3. Uninstall or upgrade the package (dpkg -r gitlab-runner or rpm -e gitlab-runner).
  4. Verify package removal succeeds cleanly without script failure aborts.

What are the relevant issue numbers?

Closes #39557 (closed)

Edited by Gourab Singha

Merge request reports

Loading