Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment setupRunner

cicd/runners::setupRunner


Configuration

⬡ dispatcher: cicd/runners::CicdDispatchEngine
⬡ runner: cicd/runners::CicdRunnerEngine

Parameters

↳ var arch: Option<Arch> = _ (work/resources/arch::Arch)
↳ var containers: Vec<Container> = [] (work/resources::Container)
↳ var cpu: u32
↳ var edition: Option<string> = _
↳ var max_duration: u32 = 3600
↳ var memory: u32
↳ var name: string
↳ var service_containers: Vec<ServiceContainer> = [] (work/resources::ServiceContainer)
↳ var stop_on_failure: bool = true
↳ var storage: u32
↳ var system: Option<System> = _ (work/resources/system::System)
↳ var tags: Vec<string> = []
↳ var volumes: Vec<Volume> = [] (work/resources::Volume)

Inputs

⇥ trigger: Block<void>

Outputs

↦ failed: Block<void>
↦ ready: Block<void>


Setup a runner.

The runner configuration values are:

  • cpu: CPU amount requested for the worker, in millicores (1000 means one full CPU, 500 half of it);

  • memory: memory requested for the worker, in megabytes;

  • storage: filesystem storage requested for the worker, in megabytes;

  • max_duration: maximum duration for which the worker will be effective, in seconds;

  • arch: hardware architecture the worker must have (should be none if nothing specific is required);

  • edition: edition of the Mélodium engine the worker must rely on (standard, desktop, container, …), can be none if nothing specific is required (any edition suits). It is not the container image, which is defined by the distribution requested in system; Compose runs the standard and container editions on an Alpine image, and edition only matters on container targets, workers on virtual machines satisfy any edition;

  • system: what the worker must run on, either an operating system built with |linux, |windows, |macos, |freebsd and the other work/resources/system functions, or one exact machine image built with |image (a name resolved by whatever spawns the worker, never a container image); none if nothing specific is required;

  • containers: list of containers to instanciate alongside Mélodium engine as executors;

  • service_containers: list of containers to instanciate alongside Mélodium engine as services;

  • volumes: list of filesystem volumes that can be shared between the Mélodium engine and containers.

Every need except tags is a requirement, and an operating system and a machine image cannot be requested together.

Tags are hints: they are never a requirement and never a reason to refuse a run. Whatever spawns the worker may use them, for example by copying them to the resources it creates.

Where the worker is spawned

The location of the dispatching engine tells where the worker is spawned:

locationWhere the worker is spawned
"api"Mélodium Services spawn the worker somewhere (container, virtual machine…)
"compose"Compose: the worker is a container started on the machine running this engine, with podman or docker (tried in this order)

Compose can only offer what its official image is. Each need is checked before anything is started:

NeedCompose acceptsCompose refuses
edition (optional)none, standard, containerdesktop, webassembly, mock
system (optional)none, |linux(), |linux_distribution("alpine")|linux_distribution("ubuntu"), |linux_distribution_version("alpine", "3.20"), |windows(), |image("nixos-ci")
arch (optional)none, the architecture of this machineany other architecture
tagsanythingnever refused

A request Compose cannot satisfy starts nothing: failed is emitted and the errors say which need cannot be satisfied. The edition is the one of the engine the worker runs, while the container image is defined by the Linux distribution of system. Editions and systems are only requirements on container locations, a virtual machine worker satisfies any edition.

Example, asking Compose for a standard engine on Alpine:

use std/engine/util::startup
use std/ops/option::|wrap
use cicd/runners::CicdDispatchEngine
use cicd/runners::CicdRunnerEngine
use cicd/runners::setupRunner
use work/resources/system::System
use work/resources/system::|linux_distribution

treatment main()
  model dispatcher: CicdDispatchEngine(location="compose")
  model runner: CicdRunnerEngine()
{
    startup()
    setupRunner[dispatcher=dispatcher, runner=runner](
        name="example", cpu=500, memory=500, storage=500,
        edition="standard",
        system=|wrap<System>(|linux_distribution("alpine")),
        tags=["example"]
    )
    startup.trigger -> setupRunner.trigger
}

It should be noted that the CPU and memory requirements for the Mélodium engine and possible containers are cumulative. Also, multiple different architecture cannot be requested for the same worker, so containers in the same request all have to use the same architecture. Finally, the cumuled size of all volumes must be equal or less than the Mélodium engine storage value, and each container must have storage values at least equal to the sum of the volumes mounted inside them.