Skip to main content

Private beta: Request private beta access

zenitya

Runner reference

The runner's policy file, commands, files, failure codes and logs.

View as markdown

Everything about zenitya-runner: its policy file, its commands, the files it keeps and the codes it reports. To set one up, start with Running tools on your network.

config.yaml

/etc/zenitya-runner/config.yaml is the runner's local policy. It must be owned by root and writable by no one else, nor may any directory above it be. Unknown keys and keys given twice are errors, so a typo fails loudly. Check it with zenitya-runner config check; the service reads it when it starts.

FieldTypeDefaultMeaning
projectslistnoneProject IDs whose calls the runner accepts. Every other project's calls are refused. At most 1,000
egresslistnoneWhat calls may reach. Each rule sets exactly one of cidr or host, and ports. At most 256 rules
egress[].cidrstringAn IPv4 network such as 10.20.0.0/16, written with its network address. It may not overlap the ranges calls never reach
egress[].hoststringA host name such as db.internal.example.com, resolved by the machine's DNS. Exact names only, no wildcards
egress[].portslistTCP ports, 1 to 65535, at most 64 per rule
secretsmapnoneLocal secrets by name, at most 256. Names follow the project secret rules
secrets.<NAME>.envstringRead the value from this variable in /etc/zenitya-runner/environment when the service starts
secrets.<NAME>.filestringRead the value from this file for each call, without a trailing newline. Absolute, and outside /home, /root, /tmp, /var/tmp and /run/user
secrets.<NAME>.projectslistevery listed projectThe projects whose calls get this secret, at most 32, each one in projects
limits.concurrencyinteger4Calls running at once, 1 to 64. Beyond it calls fail with runner_busy
limits.memoryMbinteger512Memory per call in MB, 128 to 65536, without swap
limits.cpusnumber1CPUs per call, 0.1 to 64
gcpCredentialslistnoneProject IDs whose calls get this Google Cloud VM's service account through Application Default Credentials. Each must be in projects. See Google Cloud credentials
updates.pinstringfollow the latest releaseStay on this release, such as 0.4.0
apistringhttps://api.zenitya.comThe Zenitya API origin. HTTPS, or HTTP on loopback only

Each secret sets exactly one of env and file.

What calls never reach

Whatever the rules say, calls never reach 0.0.0.0/8, 127.0.0.0/8, 169.254.0.0/16 (link-local and cloud metadata), 100.100.100.200 and 168.63.129.16 (Alibaba and Azure host endpoints), 224.0.0.0/4, 240.0.0.0/4, 10.200.0.0/16 (the calls' own network), any address of the runner machine itself, or IPv6. The calls of a project in gcpCredentials are the one exception: at 169.254.169.254:80 and metadata.google.internal they reach the runner's own metadata server, which passes on only the service account's credentials and the project ID. A cidr rule overlapping the fixed ranges is an error; a host name that resolves to any of them gets no answer for those addresses.

Calls reach allowed destinations over TCP only. DNS answers only the host names in egress, with IPv4 addresses, each valid for a minute after the lookup; any other name does not exist.

Commands

Run them as root, except version, config check and logs for a member of the systemd-journal group.

CommandWhat it does
zenitya-runner enroll --token zrt_…Generates the machine key, enrolls it with a single-use token, installs and starts the service. install.sh runs it
zenitya-runner status [--json]The runner and organization IDs, the key's fingerprint, the connection, running calls, the release, and whether the policy changed since the service started
zenitya-runner config check [--json]Validates the policy and summarizes it. --json prints it parsed, with secret sources, never values
zenitya-runner restartApplies the policy. First makes the service's start checks, local secrets and permissions included; if they pass, restarts it once its running calls end
zenitya-runner logsThe service's events, readable. -f follows, --errors keeps failures, --since "1 hour ago", --json for tools
zenitya-runner logs --attempt <id>Every field of one call's event, by its attempt ID or how it starts
zenitya-runner update [--version X.Y.Z]Installs the pinned, latest or given release; the service switches once its running calls end. --check only reports
zenitya-runner uninstall --yesStops and removes the service, the machine key, its state, network setup and the user it created. Keeps the policy
zenitya-runner version [--json]The release, and with --json the IDs of the job keys it trusts

zenitya-runner run is what the service runs. Every command takes --config and --state for other paths. Errors print as error[CODE]: detail, and --json output goes to stdout.

Files

PathWhat it is
/etc/zenitya-runner/config.yamlThe policy. Root's, writable by no one else
/etc/zenitya-runner/environmentNAME=value lines for env: secrets. Root's, readable by no one else
/var/lib/zenitya-runnerThe machine key, identity and artifact cache. Root only
/usr/lib/zenitya-runner/<version>A release: the runner, runsc and the calls' read-only root file system. current names the one in use
/usr/local/bin/zenitya-runnerLinks to the release in use
zenitya-runner.serviceThe systemd unit

The service runs as root, since it creates network namespaces, nftables rules and gVisor sandboxes, with only the capabilities those need. What calls talk to on the network (their egress proxy, DNS server and metadata server) runs apart from it, as the unprivileged zenitya-runner user, with no capabilities. The service creates that user and its group when it starts, and refuses to start while a user or group of that name exists that it did not create; uninstall removes them. The gateway can read what any local user can, such as config.yaml, so keep file: secrets readable by root only.

The service refuses to start (insecure_permissions) while the policy, the release's runsc or root file system can be changed by anyone but root, or the environment file or state directory can be read by anyone but root.

Call failures

What an agent or zya exec gets when a call on a runner fails:

CodeMeaning
runner_unavailableThe runner is not connected, or was revoked. Nothing ran
runner_busyThe runner is running limits.concurrency calls. Nothing ran
runner_restartingThe runner is restarting, into an update or to apply its policy. Nothing ran; retry in a few seconds
runner_refusedThe policy does not list the project, or a local secret has the name of a project secret. Nothing ran
runner_outdatedThe runner's release is too old for this call (calls need 0.7.0 or later). Nothing ran. Update it
runner_outcome_unknownThe runner disconnected during the call; it may or may not have run. It is never run again on its own
timeoutThe call ran past its deadline and was stopped

Service errors

Why the service would not start, or stopped. zenitya-runner logs --errors shows them with details.

CodeMeaning
not_enrolledNo machine key or identity. Enroll with a token
invalid_configThe policy is invalid, or a local secret cannot be read
insecure_permissionsA file the runner relies on is open to others; the detail names it and the fix
sandbox_unavailablerunsc, the root file system, nftables or cgroup v2 is missing, or the zenitya-runner user could not be created, or a user or group of that name exists that the runner did not create
gateway_failedThe process answering calls on the network stopped. systemd starts the service again
revokedThe runner was revoked, which is permanent. It stays stopped
key_replacedAnother machine enrolled for this runner. It stays stopped
unknown_runnerZenitya does not know this runner as enrolled. It stays stopped
runner_outdatedZenitya needs a newer release and the update failed, or updates.pin holds an older one. It stays stopped

A runner that stays stopped exits with status 3, which systemd does not restart. What brings it back:

  • revoked: nothing. Create a new runner, run its install command on the machine, which enrolls and starts the service, and move the projects to it.
  • key_replaced: choose Enroll again on the runner's page and run the install command it shows.
  • unknown_runner: if the runner's page shows it revoked, as for revoked; otherwise as for key_replaced.
  • runner_outdated: sudo zenitya-runner update, or raise updates.pin, then sudo systemctl start zenitya-runner.

Logs

The service writes one JSON event per unit of work to the journal, never a call's input, output or secret values:

EventWhen
startupThe service starts: its release, policy summary and sandbox, or why it could not start
handshakeEach connection attempt
connectionA connection ends: how long it lasted, how many calls, why it closed
jobA call ends: tool, project, exit code, memory and CPU used, and what it reached for or was refused
prefetchAn artifact downloaded before its first call
updateA release applied or failed
shutdownThe service stops, and why