Skip to main content

plan

Function plan 

Source
pub fn plan(
    repositories: &[Repository],
    profiles: &BTreeMap<String, Profile>,
    budget: Budget,
    now: SystemTime,
) -> Plan
Expand description

Decides which slots start a runner and which idle runners stop, and why each job left queued waits.

repositories holds each repository’s pools; a job is served by the pool whose labels match it, and one no pool of its repository matches waits for a pool (Waiting::NoPool) unless it is for GitHub’s own runners. Each pool gets a runner per matching queued job, less its runners still waiting for a job. Jobs are served oldest first across repositories, each in the lowest free slot of its repository’s profile, while what the runner takes (Repository::runner_memory, by default the slot’s memory) fits budget.memory and budget.host, and its CPU (Repository::runner_cpu, by default the slot’s cpus) fits budget.cpu (None: no budget). A job that does not fit takes the room of warm runners of other repositories, which stop. A repository whose job had a slot and memory but not CPU is held once (Decision::HeldForCpu). An idle runner stops once no queued job is left for it, it is not one of its repository’s warm runners, and it waited IDLE_TIMEOUT. Once a held repository waited CPU_PRIORITY_AFTER, no younger job starts until its own fits. Last, while no job waits for room, each repository short of its warm runners starts them at its profile’s caps, one per repository at a time.