Sub topic 13
Operating the fleet: images, updates, logs, and failure modes
This chapter assumes you can write a basic workflow, use the gh CLI and a Linux shell, and understand how ephemeral runners and just-in-time (JIT) configuration work. Once every job gets a fresh runner, the work shifts from repairing machines to maintaining the image they start from and watching the system that creates them.
Treat the image as the product
An ephemeral runner starts from a runner image, which is a VM image or container image with the runner software and your build tools already installed. Nothing you change on a running runner survives, so every fix goes into the image.
- Pin tool versions in the image build, not in jobs that install tools at run time.
- Bake in the current runner application release. A runner that must download an update at startup adds delay to every job.
- Rebuild on a schedule, for example weekly, to pick up operating system patches.
- Tag each image with a version and keep the previous one, so you can roll back.
Updates
The runner application updates itself by default. GitHub refuses to give jobs to runners that fall too far behind its current release. If you disable self-update, you must replace the image yourself on time. Because ephemeral runners are short-lived, the simplest policy is to rebuild the image for each new runner release and let old instances finish their one job and disappear.
Roll out a new image gradually. Send a small share of new runners to it first, and watch for startup failures before switching the rest.
Logs
Job logs stay in GitHub and are available from the workflow run. The runner's own diagnostic logs are different. They are written to the _diag folder inside the runner directory, and they vanish when the instance is destroyed. These logs explain registration and connection failures, which job logs never show.
Ship _diag and the host's system logs to a central store before teardown. Add the runner name and instance ID to every log line. Then you can match a failed job in GitHub to the machine that ran it.
Common failure modes
| Symptom | Likely cause | Response |
|---|---|---|
| Jobs stay queued | No idle runner carries every label in `runs-on`, or the scaler is down | Check labels, scaler logs, and cloud quotas |
| Runner starts and exits at once | Registration token expired or the JIT config was already used | Request a new JIT config for each runner |
| Many offline runners listed | Instances crashed before or during a job | Delete the stale entries and find the crash cause |
| Slow job start | Image pulls or runner update at startup | Bake the image and the runner release in advance |
| Disk full mid-job | Large caches or build outputs | Size disks for the worst job. A fresh runner gets a clean disk each time |
A crashed instance can leave a runner entry in GitHub that never comes back. This script lists offline runners in one repository and removes them:
#!/usr/bin/env bash
set -euo pipefail
REPO="OWNER/REPO"
gh api --paginate "/repos/${REPO}/actions/runners" \
--jq '.runners[] | select(.status == "offline") | .id' |
while read -r id; do
echo "Removing offline runner ${id}"
gh api --method DELETE "/repos/${REPO}/actions/runners/${id}"
doneWhat to watch
A small set of measurements shows most problems early:
- Queue time, the delay between a job being queued and starting. A rising value means the fleet is too small or the scaler is failing.
- Runner startup time, which tracks image size and pull speed.
- Registration failures per hour.
- Count of offline runner entries.
- Cloud spend per job, to spot runaway scaling.
Set a maximum fleet size in the scaler. Without it, a burst of pull requests or a loop that keeps retrying can create runners until a cloud quota stops it.
Exercise
Your ephemeral runners start, but jobs still wait about two minutes before beginning, and the runner logs show an update being downloaded each time. What do you change, and why?
Show answer
Rebuild the image with the current runner application release already installed. The runner then has no update to download at startup. Because each runner is new, the image is the only place the fix can live. Changing a running runner would be lost when it is destroyed after its job.