Skip to content

Fix the register-the-runner script

Jeremy Huntwork requested to merge jhuntwork/gitlab-runner:posix-fix into main
  • Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA

What does this MR do?

Fixes a shell script error in the embedded register-the-runner script

Why was this MR needed?

Because otherwise it does not work as intended and sends errors to the log.

The embedded register-the-runner script identifies (via the shebang line) that it is bash. However on line 64 of this file we actually execute it by doing if ! sh /configmaps/register-the-runner which essentially skips the shebang line evaluation and interprets the whole script through sh. In POSIX, signals do not have a SIG prefix (https://pubs.opengroup.org/onlinepubs/009696799/utilities/trap.html).

This results in the trap actually not being registered for the script and the following errors printed in the logs:

trap: SIGINT: bad trap
trap: SIGQUIT: bad trap

To fix we can either expressly call this script via bash on line64, or we can just remove any existing bash-isms and allow it to continue to be called through sh.

I am opting for the latter here since the fix is simple enough and POSIX always remains more portable if we are able to use it.

Also remove the spurious exit 0 at the end. If the code reaches that point, it will naturally exit with success unless you tell it otherwise.

Edited by Jeremy Huntwork

Merge request reports

Loading