Skip to main content
Version: Release 24.3

Execute Tasks or Scripts using Runner

When the Release Runner is registered on the Release server, the readiness state of the Runner is healthy, and allows it to receive tasks or scripts for execution.

Executors

Release Runner executors are running containers of plugin instances. Each executor can execute only a set of tasks and scripts that the plugin is enabled to execute. The number of executors is limited using the Capacity setting in Runner configuration item. There are two modes on how the executors can run, which are daemon mode or normal mode. You can switch between these two modes by setting the eviction time on the Runner configuration item to 0 or the number of seconds that executor will stay up and running.

If the executor is running in normal mode, and the Eviction time is set to 0, the executor is started as soon as the task or script is received for execution. Once the execution finishes, the executor will be terminated.

Executors can run a set of tasks or scripts that are defined in the same container plugin implementation. Spinning up executors from scratch is a time-consuming process. Hence, the Release Runner runs executors in daemon mode, that is the default value of Eviction time setting is 60 seconds. Once a daemon executor gets a task or script, it stays active and waits for the next one. If there are new jobs to execute and the executor for a job is in Idle state, executor will be used to run it. If there are new jobs to do and the executor for a job is in Idle state, it gets activated to carry out the new job. This reduces the task or script execution time. If no new jobs are received for executor within the eviction time, executor is terminated.

At any time, the number of executors that are in Idle or Running state is limited to the capacity setting of Runner configuration item. In case a new job is received and there is an Idle executor that doesn't match the type of executor needed to run the job, Idle executor is terminated and the new executor running appropriate plugin image is started.

Task Execution

After Runner is registered to the Release server, execution stage of the lifecycle is triggered. During execution stage, Runner does a long poll reserve request. This request will either return info about the job or an empty response within 50 seconds.

In case the job data is received in reserve response, Runner starts the job execution with a confirmation request towards the Release server. Once the job is confirmed based on the image and tag of the script execution, the Runner will either use Idle or start a new executor.

After container becomes ready, job data is passed to the executor and the execution begins. As the job is executed, logs are streamed back to the Runner and passed to the Release server. Upon execution, the finish result is pushed back to the Runner, which then passes it back to Release with a finish job request.

When the data is successfully sent to Release, Runner runs cleanup process to clean all the execution data.

In case the executor is running in daemon mode, it's marked as Idle. Otherwise, the executor is terminated.

Script Execution

Script executions are passed to Release Runner through an SSE channel. When a script execution is triggered on the Release server a ExecuteScript SSE command, containing job description and data is sent to the Runner. Based on the image and tag of the script execution, the Runner will either use Idle or start a new executor.

After container becomes ready, job data is passed to the executor and the execution begins. As the job is executed, logs are streamed back to the Runner and logged into the Runner logs. Upon execution, the finish result is pushed back to the Runner, which then passes it back to Release immediately.

When the data is successfully sent to Release, Runner runs cleanup process to clean all the execution data.

In case the executor is running in daemon mode, it's marked as Idle. Otherwise, the executor is terminated.

Fallback Mechanism

In case the executor finishes execution and the Release Runner goes into restart mode or is unavailable at that point, the executors starts writing its result to a dedicated place managed by the Runner. This ensures that no job execution result will be lost.

Once Runner is up and running again, it will check for executors that might have finished their execution and process them during the start-up recovery phase. At that point all processed execution results will be sent back to Release.