Create a GitLab Runner process wrapper
What does this MR do?
Implements a wrapper for the GitLab Runner process.
Why was this MR needed?
Justification for the wrapper can be found in Create a GitLab Runner process wrapper (#38216 - closed) • Tomasz Maczukin • 17.6
What's the best way to test this MR?
After building/downloading the binary, you can start runner through the wrapper and interact with the gRPC server.
If normally you start runner with:
gitlab-runner run --config ~/.gitlab-runner/config.toml
then to use the wrapper you should start it as:
gitlab-runner wrapper -- run --config ~/.gitlab-runner/config.toml
The wrapper will explicitly call the Runner binary with all arguments that are present after --. In other words, everything after -- will be taken as arguments and called with gitlab-runner through exec.Command.
The syntax is:
gitlab-runner [global-options] wrapper [command-options] -- [internal-global-options] [internal-command] [internal-command-options]
Where:
-
global-optionsare the regular global options available forgitlab-runnerbinary and that will be used by the wrapper process only. -
command-optionsare options for thewrappercommand. Currently Wrapper provides two of these:-
--grpc-listenwhich defines listen address for the gRPC server. Default islocalhost:7777. -
--process-termination-timeoutwhich defines what's the timeout of waiting for the internal runner process termination when the wrapper process is terminated. Default is10s.
-
-
internal-global-optionsare thegitlab-runnerglobal options that will be used by the internal process only. -
internal-commandis any of thegitlab-runnercommands -
internal-comand-optionsis any of the chosen command options
Runner wrapper will take the arguments after -- and transition it to:
gitlab-runner [internal-global-options] [internal-command] [internal-command-options]
and this will be started in a dedicated process group, managed by the wrapper.
Some examples:
If you want to customize the gRPC server listening address:
gitlab-runner wrapper --grpc-listen ":1111" -- run --config ~/.gitlab-runner/config.toml
You can get some more logs from the wrapper by enabling debug logging for the wrapper process:
gitlab-runner --debug wrapper -- run --config ~/.gitlab-runner/config.toml
If you want to enable (for any reason) debug logging for the internally started runner process, the global --debug flag must be added after --:
gitlab-runner wrapper -- --debug run --config ~/.gitlab-runner/config.toml
or to have both the wrapper and the internal process logging in debug:
gitlab-runner --debug wrapper -- --debug run --config ~/.gitlab-runner/config.toml
Remember that none of the options used in context of the wrapper command will be used by the internal process, as they don't share the memory. Wrapper will start totally separate process (just tracked and "owned" by it) and any configuration needs to be explicitly provided after --.
What are the relevant issue numbers?
Closes #38216 (closed)