Zaroz
Units your code controls

The unit contract v1

The contract is the stable surface between the platform and your process. It is published as JSON Schemas (draft 2020-12) and is versioned by an integer major.

Environment

VariableValue
ZAROZ_CONTRACT_VERSION1
ZAROZ_DIR/zaroz
ZAROZ_UNIT_ID, ZAROZ_UNIT_KEYthe unit's id and key
ZAROZ_WORKLOADthe Workload's slug
ZAROZ_PRIVATE_NAME<key>.<workload>, how other Workloads of the project reach this unit alone
ZAROZ_PROJECT_ID, ZAROZ_REGION, ZAROZ_SERVICE_INSTANCE_IDwhere it runs
MEMORY_LIMIT_MIBset by some product templates: the memory the plan includes, in MiB. Despite its name it equals ZAROZ_MEMORY_BUDGET_MIB, not the kill limit. Prefer the ZAROZ_ variables
ZAROZ_CPU_MILLICORESthe CPU the unit may use, in millicores (250 for a quarter of a core)
ZAROZ_MEMORY_BUDGET_MIBthe memory the unit is held to, in MiB: its own size, or the plan's. Size heaps and caches from this
ZAROZ_MEMORY_LIMIT_MIBthe memory at which the process is killed, in MiB
ZAROZ_API_URLonly when the Workload has a service principal

Per-unit values are fixed when the pod is created, because a unit's key never changes. ZAROZ_CPU_MILLICORES, ZAROZ_MEMORY_BUDGET_MIB, ZAROZ_MEMORY_LIMIT_MIB and /zaroz/resources.json are in the main container of every unit. The other ZAROZ_ variables are only in pods that carry the agent or a principal: a Workload that does not use these features runs unchanged.

Files in /zaroz

PathSchemaNotes
contract.jsoncontract.schema.json{version: 1, agent_version}
unit.jsonunit.schema.jsonidentity; labels update live
user-data.jsonuser-data.schema.jsonthe JSON value or null
allocation.jsonallocation.schema.jsonnull or {id, allocated_at, generation}
state.jsonstate.schema.json{draining: false} or {draining: true, reason}
resources.jsonresources.schema.json{schema_version, cpu_millicores, memory_budget_mib, memory_limit_mib}, in every unit, with or without the agent. See Limits
signals/write-only: ready, accepting, idle, busy, shutdown
signal.socksignal-response.schema.json, accepting-request.schema.json, error.schema.jsonHTTP/1.1 over a Unix socket
credentials/tokenonly with a principal; rotated, read it per request

Every file is written atomically. See Signals for how to use them.

Events

The envelope of GET .../units/events and of webhook deliveries is event.schema.json. See Events. data is typed per event type.

The versioning rule

  • Within a major, changes are additive only: new optional fields, new files, new signals, new event types. Consumers must ignore what they do not know.
  • Removing or renaming a field, or changing a type or a meaning, is a new major, chosen per Workload by contract_version on the policy (default: the newest).
  • The previous major keeps being served for at least 12 months after the next one ships.
  • The agent embeds every supported major's schemas and validates every file it writes and every event against them. The kernel's event emitter is tested against the same files.

Guarantees

The lifecycle guarantees (ready means ready, allocate is atomic, drain before kill, stopped costs nothing, fast refusal, out of load balancing in about a second, events never skip) are listed on Units your code controls. Each is checked by the open conformance suite.

Last modified on