Sync and arrival
How snapshots reach a deployment, what can hold them back, and how they are applied in waves with jobs and a prune limit.
A deployment does not apply whatever is in git the instant it changes. A new snapshot first arrives, then passes a few checks, then is applied in order. This page explains each step and the safety stops in between, so you know why a push sometimes waits for a person.
arrives ──▶ arrival checks ──▶ render guard ──▶ guardrails ──▶ applied in waves ──▶ prune check
(branch, refused if held if empty blocked if jobs before and held prune if
request, behind or or shrinking a rule says no after, ordered it removes too
promoted) images missing by half muchArrival
A deployment's arrival decides which snapshots it takes.
| Arrival | Meaning |
|---|---|
branch (shown Automatic) | A new snapshot on every push to the deployment's branch. This is sync on push. |
request | A snapshot only when someone asks for one, or when a pipeline promotes one in. |
A deployment set to observe renders and compares but is never applied.
A pipeline stage arrives by Auto-promote or By request. The first stage has no incoming route, so how builds land there is its deployments' own arrival. See Pipelines.
Sync on push
When a tracked branch moves, Wardn reads the branch's head commit itself, rather than trusting the webhook's payload, skips it if it has already rendered that commit, and renders one snapshot for that commit. Pushes are handled in order, per deployment. If several arrive while an apply is running, only the newest waits; a newer snapshot replaces an older one that was queued and not yet sent.
A push reaches Wardn as a webhook if you use the GitHub App, and every tracked branch is also checked once a minute, so a missed webhook only delays a deploy. See Sources and apps.
Promote
Promotion is a pipeline's job. A deployment never takes snapshots from another deployment by itself: a pipeline moves the exact snapshot from one stage to the next, by auto-promotion or by a person asking. Nothing is rendered again, so what you tested in staging is what reaches production, object for object. Promotion is checked against the stage's rules and any guardrails that cover the target, such as the protected-branch rule.
Arrival checks
Every snapshot that lands passes two checks that are always on and cannot be turned off: a branch sync, an auto-promotion, a request and a promotion by hand. The one exception is an explicit rollback or restore, which goes back to a snapshot on purpose.
| Check | Passes when |
|---|---|
| Ahead of what runs | For each app, the incoming commit is the running commit or descends from it. A commit that is behind or has diverged is refused. If the git host cannot say, Wardn warns and goes on. |
| Images exist | Every image in the snapshot resolves in its registry. A missing image is refused. If the registry cannot be asked, Wardn warns and goes on. |
On the promote review they show as Always on, Met or Not met, and a check that could not be made shows a muted "Not checked" line. A snapshot that fails one is refused (promotion.arrival_ahead or promotion.arrival_images, 409) and no bypass lifts it. When a sync or an auto-promotion is held by one, the reason is written to Activity.
The render guard
A bad commit can render nothing: a wrong path, a broken overlay, a values file that turns everything off. A tool that prunes will then delete what runs, faithfully. The render guard is the first stop.
It compares a new snapshot with the newest snapshot the deployment approved (never a held or discarded one). It holds the snapshot when:
- it renders no objects at all, or
- it would remove more than half of the objects the last approved snapshot had.
A held snapshot is stored, shown in the Snapshots tab and written to Activity with the reason and the counts. Nothing is sent to the cluster. A person with the snapshot:signoff duty releases or discards it. See Held snapshots.
The 50 percent threshold is fixed for now.
Guardrails
After the render guard, guardrails decide whether the snapshot may go to this deployment at all. For example, production environments take snapshots only from a protected branch by default. A snapshot that fails is stored and recorded as blocked, and not applied.
If a guardrail needs a fact Wardn does not know yet, the deploy waits and is retried; it is not let through on a guess.
Applying in waves
Wardn signs an apply command and sends it to the operator in the target cluster. The operator applies the objects with server-side apply, as the deployment's service account, in waves. Each wave waits for the one before to become ready.
A wave comes from the annotation wardn.dev/sync-wave (an integer, lower first). Without it, the kind decides:
| Order | Kinds |
|---|---|
| First | Namespaces and CRDs |
| Then | Service accounts and roles |
| Then | ConfigMaps, Secrets and volume claims |
| Last | Everything else |
If the operator does not answer within ten minutes (WARDN_APPLY_TIMEOUT), the apply is marked failed. A cluster that is offline is not timed out: the apply stays queued and is sent when it returns.
Jobs
A deployment can run Kubernetes Jobs before the first wave and after the last, for example a schema migration. A job is a batch/v1 Job that runs in the deployment's namespace as its service account.
| Setting | Meaning |
|---|---|
| Failure policy | What a failed job does to the deploy: Stop, don't deploy (the default), Carry on, or Roll back this deployment. |
| Timeout | Five minutes by default, at most an hour. |
| Undo job | Runs in place of the job when the deploy is a rollback. A job with no undo is skipped then. |
See Jobs and waves.
Prune and the prune limit
With prune on, objects that were in the previous snapshot and are not in the new one are deleted from the cluster. Wardn deletes only objects that carry the annotation wardn.dev/deployment with this deployment's id.
The prune limit keeps one bad commit from emptying a namespace even when it passes the render guard. If an apply would delete more than the limit (50 percent of the deployment's objects by default, and never when three objects or fewer), the operator applies the snapshot, removes nothing, and reports a held prune. The deployment waits for a person to approve or reject the removal. A later successful apply closes an old held prune as superseded.
| Guard | Looks at | Holds |
|---|---|---|
| Render guard | The new snapshot against the last approved one, before anything is sent | The whole snapshot |
| Prune limit | What this apply would delete, in the cluster | Only the deletions |
Why it is built this way
Each stop answers a failure that a controller which simply syncs does not handle. Git can be wrong, and a controller that follows git then faithfully breaks production. The guards add a person only where the change is large or odd, and leave ordinary pushes alone.
When Wardn or the connection is down, clusters keep running what they last had and nothing new is applied. See How it works.
Guides that use this
- Deployment settings: arrival, prune and the prune limit.
- Held snapshots.
- Jobs and waves.
- Run a database migration before an apply.