Release candidates¶
Maturity: experimental
Release candidates are new in 0.83.0 and may change in a minor release, with a changelog entry. See the Roadmap for every feature’s status.
A release candidate is a commit that an environment already tested, with its images copied to the registry paths you release from. The GitOps controller prepares it for you: once an environment passes a commit (its deploy run ended with every check green) and no newer commit passes for a quiet time, it copies the images of that run, by digest, to your outside registry. The bytes you release are the bytes that were tested.
Declare it¶
from piceli.infra import Candidate, CandidateCopy, Controller
controller = Controller(
on="node-a",
candidate=Candidate(
environment="staging",
quiet="30m",
keep=5,
copies=(
CandidateCopy(
component="web",
to="oci://ghcr.io/example/shop-web",
tag="{commit}",
),
),
),
)
environment: the environment whose passed commits are candidates. With several sources, the first source’s commit names the candidate, unless you setsource.source(optional, 0.85.0): the name of the followed source whose commit names the candidate, for examplesource="product"for an environment that follows{workspace: "main", product: "main"}. It is the name the source has in the environment (the keygitops historylists undersources), not the name of a Python variable. That commit fills{commit}in a copy’s tag, its passed commits are the ones recorded, and the commit you give tocandidate requestis that source’s. Unset keeps the first source. An environment that does not follow the source is refused when the composition loads (candidate-source-unknown, naming the sources it follows).A copy takes the run’s image of the component, whatever commit built it: an image whose inputs did not change since an older commit (
current_foringitops history) is the one the candidate copies. Nothing compares the build commit to the candidate’s (0.86.0).quiet(default30m): how long no newer commit may have passed.keep(default5): how many of the newest candidates stay. A released candidate always stays.copies: oneCandidateCopyper image.componentis the component whose image of the passed run is copied;toisoci://host/repository(no tag, no digest);tagis optional and may hold{commit}(the first 12 characters of the commit). Without a tag the image is copied by digest only. A component and a target appear once.copiesmay be empty: the candidate is then a ready marker. It copies nothing and becomesreadyafter the quiet time (or arequest) once the run that passed the commit is found;digestslists the image digests of that run (a component without an image is not listed).credentialsof a copy names a Secret in the controller’s namespace with the keycredentials.json:{"username": "...", "password": "..."}or{"token": "..."}. The controller mounts it as a file, never as a variable. Without it, the copy is anonymous. The Secret may be missing when the controller starts: the mount is optional, so a missing Secret fails the candidate withcandidate-credentials-missing(the detail names the Secret), never the controller.
The copies are done by the resumable copy set (piceli.artifacts.copy_set):
every image is copied by digest, a ledger remembers what is done, and a retry
continues where it stopped.
States¶
piceli gitops status prints one line per candidate:
candidate abc1234: ready
candidate def5678: not ready: waiting for a quiet time until 2026-11-26T10:30:00Z
candidate 0123abc: not ready: candidate-no-image (component web has no image reference)
State |
Meaning |
|---|---|
|
The commit passed; the quiet time is not over. |
|
The images are being copied. A temporary failure (a registry that does not answer; since 0.96.0 also |
|
Every image is copied. |
|
|
|
A newer commit passed while it was building. A request continues it from its ledger. |
Reasons: candidate-no-image (a component of the run has no image digest;
the detail names it; since 0.87.0 a digest without an image reference is
copied from the cluster registry, <registry repository>/<component>@digest), candidate-no-component (the run has no such component),
candidate-run-missing (the history no longer has the run), candidate-copy-error,
candidate-credentials-missing, and the reason the copy set reports.
The detail names the component and, since 0.96.0, the copy’s own text:
for copy-verification-failed the check that failed and what it compared
(web: tag abc1234def56: the target names nothing, not sha256:…).
candidate-superseded is the reason of a cancelled candidate.
A newer passed commit cancels a candidate still building (the copy stops between
two images) and starts a new quiet time. The same lines are in the status
document (piceli gitops status --json) as candidates: a list of
{commit, state, since, reason, detail, copies, released, run, passed_at, digests} (and quiet_until while waiting). copies maps each component to
pending, copied or failed.
Commands¶
$ piceli gitops candidate request abc1234 # start it now, no quiet wait
$ piceli gitops candidate release abc1234 # mark a ready one released
$ piceli gitops candidate list [--json] # every candidate, newest first
request accepts a commit that passed (7 to 40 characters). A candidate that is
already building or ready is left as it is; a failed or cancelled one starts
again. release accepts only a ready candidate and keeps it whatever keep
says. All three take --kubeconfig and --context, or --state-dir for a local
controller.
Protected digests¶
The controller keeps the newest keep candidates and every released one, and
forgets the others. The images of the kept candidates must survive the registry
cleanup. piceli gitops candidate list --json gives their digests; pass them to
the cleanup as pins:
$ piceli gitops candidate list --json | jq -r '.candidates[].digests[]' > pins.txt
$ piceli artifacts retention --pin-file pins.txt
In code, piceli.gitops.candidates.protected_digests(state) returns the same set
from the controller’s state.
Prebuilt releases (0.99.0)¶
A candidate can also build the Nix host releases ahead of time, so the later tag release only moves a pointer: nothing is built when you release.
from piceli.infra import Candidate, Controller, NixRelease, Promotion
web_release = NixRelease(
web,
source=hosts,
builder="builder-1",
gate=Promotion(input="app", environment="staging", source="app"),
)
controller = Controller(
on="node-a",
candidate=Candidate(
environment="staging",
releases=(web_release,),
release_branch="main",
),
)
releases: theNixReleases (or their names) the candidate prebuilds.release_branch(defaultmain): the branch of each release’s source whose head is prebuilt.
Once the copies are done (right away without copies), the controller reads the
head of release_branch in the release’s source (here hosts). When that
head’s flake.lock pins the gate’s input (app) to the candidate’s commit, it
asks the release’s build host to build the head, push the closure to the cache
and upload its signed manifest. No tag and no pointer are written.
What the composition must hold, checked when it loads:
each name is a
NixReleasewith agate(Promotion) whose environment is the candidate’s and whose source is the candidate’s source;a name is not in both
releasesandrehearse.
And what your repositories must hold: the head of release_branch pins the
candidate’s commit. Until it does, the candidate stays building with the
reason candidate-release-not-pinned; the detail names the head and the
commit it pins. Push a head that pins it and the next poll prebuilds.
Each release of a candidate has a state:
State |
Meaning |
|---|---|
|
Nothing asked yet: the head pins another commit, or the gate cannot be read. |
|
The build host builds it. |
|
The closure and its manifest are in the cache. |
|
The build host answered |
The candidate is ready when every release is built (and every rehearsal
passed, below). A newer head that still pins the candidate’s commit is
prebuilt again; a head that pins another commit leaves a built release as it
is. A superseded or cancelled candidate drops what it asked for.
candidate request COMMIT starts the failed parts again; built ones stay.
What the release then does. When the release later plans a tag (or branch)
publish of a commit a candidate prebuilt, with the same attribute, cache,
inputs and pinned commit, the plan names the prebuild (prebuilt: store path,
NAR (Nix archive) hash, manifest digest, candidate). The approval covers it, as it covers the
rest of the plan. The build host then checks the prebuild in the cache, signs
a manifest for the tag and moves the pointer: no build.
Rehearsal (0.99.0)¶
A rehearsal deploys the prebuilt closure on a canary host and waits for its checks before the candidate is ready.
canary = NixHost("canary-1", ..., follow=Branch("canary"), cache=cache)
canary_release = NixRelease(canary, source=hosts, builder="builder-1", gate=gate)
Candidate(
environment="staging",
releases=(web_release,),
rehearse=(canary_release,),
)
rehearse: releases of rehearsal hosts. Each host must followBranch(...); the composition refuses another one. Its gate follows the same rule as inreleases.The controller never publishes a
rehearserelease on its own: only its candidates do.
A rehearse release is prebuilt first, as above. Then the controller asks
the build host to rehearse it: the build host moves the rehearsal host’s branch
pointer (canary) to the prebuilt commit, then reads the host’s status until
it deployed it, failed, or 30 minutes passed. The build host answers
nix-rehearsed, and only the build host holding the claim may answer.
Rehearsal |
Meaning |
|---|---|
|
The prebuild is not built yet. |
|
The build host moved the pointer and waits for the host. |
|
The host deployed it and its checks passed. |
|
The host failed it, the wait timed out, or the build host could not start: the candidate fails with |
piceli gitops candidate list prints one line per release under its
candidate (state, commit, store path or reason) and one per rehearsal (host,
state, checks passed). --json adds releases to each candidate:
{name: {state, commit, build, store_path, nar_hash, manifest_sha256, reason, detail, rehearsal}}.
Not in this release¶
Nix closure candidates, a macOS build host, records-only paths and an upgrade environment are not part of 0.83.0.
Steps (0.99.0)¶
A candidate’s prebuild starts from the head of release_branch only once
that head’s flake.lock pins the candidate’s commit. Steps make that commit
without a person: a command runs on a build host, and Piceli commits and
pushes the files it changed (release signatures, build records, the
flake.lock pin).
hosts = Source(
"https://github.com/org/hosts.git",
records=["config/release-signatures/**", "flake.lock"],
)
Candidate(
environment="staging",
releases=(web_release,),
steps=(
Step(
"sign",
command=["./scripts/sign-release.sh"],
builder="builder-1",
secrets=["signing-key"],
records=["config/release-signatures/**", "flake.lock"],
timeout="30m",
push="git-write",
),
),
)
name: the step’s name (a DNS label), unique in the candidate.command: the command and its arguments, run without a shell.builder: the build host that runs it.secrets: names of Piceli secrets on that build host.records: the paths the step may change (glob patterns, at least one;*stays in one folder,**spans folders).timeout: how long the command may run (default30m).source: the source it commits to (default: the source of the candidate’s releases). The composition refuses a source withoutSource(records=).branch: the branch it commits to (default:release_branch).push: the name of the build host’s Git write credential.
Steps run in order, once the copies are done and before the prebuilds. A
failed step stops the later ones and fails the candidate
(candidate-step-failed). piceli gitops candidate request COMMIT runs it
again.
What the command gets¶
It runs in a checkout of the branch’s head, with a clean environment:
PATHandHOMEof the build host;PICELI_CANDIDATE_COMMIT: the candidate’s commit;PICELI_CANDIDATE_FILE: a JSON (JavaScript Object Notation) file, removed when the step ends:{"schema": "piceli.candidate.v1", "commit", "environment", "copies": [{"component", "target", "digest"}]};each secret as
PICELI_SECRET_<NAME>, upper case,-and.as_(signing-keyisPICELI_SECRET_SIGNING_KEY).
Every secret value is replaced by *** in the log tail Piceli keeps. A
command past its timeout is stopped with everything it started
(candidate-step-timeout).
What Piceli commits¶
Every changed path must match the step’s
recordsand the source’sSource(records=), so the commit starts no run. Any other change fails the step (candidate-step-unrecorded-change, naming up to 5 paths), and nothing is pushed.No change: the step is done, with no commit.
Otherwise one commit by
Piceli <piceli@users.noreply.example>, messagecandidate <commit>: <step>, pushed to the branch, never forced.When the branch moved meanwhile, the commit is put on the new head once and pushed again. If that fails too, the step fails (
candidate-step-push-rejected).The next step starts from the pushed commit. The prebuild starts from the new head once it pins the candidate’s commit.
What the build host needs¶
Its own composition declares the step:
piceli builder serveloads the cluster module itself and takes the command, the secrets and the record paths from there, never from the controller’s request. A step its own composition does not declare is not claimed.The secrets, in its Piceli secrets (
piceli secrets ..., orpiceli secrets restoreof a backup).A Git token with write access to the source, as a
git-token:piceli secrets git-token git-write --host github.com --prompt. Git reads it throughGIT_ASKPASS, over HTTPS on that host only; it never reaches the command, a command line or the log.
piceli gitops candidate list shows each step: done (with the commit it
pushed, or no change), running, waiting, or failed (with its reason and log
tail). --json adds steps to each candidate: {name: {state, commit, files, reason, detail, at, log_tail}}.