docs(releaseupdate): rewrite the canary comments in plain English (#1716)
deploy / gate (push) Successful in 6m20s
Quality / check (push) Canceled after 8m7s
deploy / archied-image (push) Successful in 2m57s
deploy / agent-image (push) Successful in 11s
deploy / dist-zip (push) Skipped

This commit is contained in:
sam committed 2026-10-31 22:11:04 +11:00
1 parent 2181b5fd08
commit 1bf536d4ab
6 files changed
+48 -42

No files matched your search

+4 -3
View File
@@ -1,6 +1,7 @@
# Judges the release on next against the canary every quarter hour: a hard
# failure rolls the canary back at once, and a release that passes a full
# window is promoted to stable. A rollback turns the run red.
# Every 15 minutes, checks how the newest release on the `next` channel is
# running on the canary host. If a hard check fails, the canary goes back to
# the stable release straight away. If the release stays healthy for 24 hours,
# it is promoted to stable. A rollback fails the run, so it shows up red.
name: canary
on:
+2 -2
View File
@@ -401,8 +401,8 @@ jobs:
"$api/repos/$repo/releases" >/dev/null
echo "published release notes for $tag"
# The canary follows next; canary.yml judges the release on it and
# promotes it to stable or rolls the canary back.
# The canary host follows the `next` channel. canary.yml then decides
# whether this release is promoted to stable or the canary is rolled back.
- name: Install the release on the canary
if: vars.CANARY_URL != ''
env:
+4 -4
View File
@@ -82,8 +82,8 @@ func startCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard, v
return dashboard.Install(ctx, version, canaryInstallWait)
}
// checkCanary judges the release on next once and acts on the verdict. It
// reports rolledBack so a failed canary turns the run red.
// checkCanary judges the release on the next channel once and acts on the
// result. It reports rolledBack so that the caller can fail the run.
func checkCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard, source distribution.Source, latest []string, checkout string, out io.Writer) (rolledBack bool, err error) {
next, err := releaseupdate.Fetch(ctx, source, "next")
if err != nil {
@@ -152,8 +152,8 @@ func rollBackCanary(ctx context.Context, dashboard releaseupdate.CanaryDashboard
}
// migrated reports whether the migrations differ between two release tags.
// Anything it cannot tell counts as migrated, which holds rather than
// restoring a snapshot.
// If it cannot tell, it says they differ, so the canary is held rather than
// rolled back.
func migrated(ctx context.Context, checkout, from, to string) bool {
err := exec.CommandContext(ctx, "git", "-C", checkout, "diff", "--quiet", "v"+from, "v"+to, "--", migrationsDir).Run()
return err != nil
+18 -16
View File
@@ -5,20 +5,20 @@ import (
"time"
)
// Canary evaluation. The canary host takes a release from next; its window
// after the release was issued is compared with its own window of the same
// length before, since a single production host has no simultaneous control.
// The canary host installs each release from the next channel. Its behaviour
// in the 24 hours after a release is compared with its own behaviour in the
// 24 hours before, because there is only one production host to compare with.
const (
// CanaryWindow is how long a release runs on the canary before the
// relative signals are judged: one daily cycle of schedules and traffic.
// CanaryWindow is how long a release runs on the canary before it can be
// promoted. A day covers one full cycle of schedules and traffic.
CanaryWindow = 24 * time.Hour
// canarySettle is how long after issue the install and restart are given
// before the hard signals count.
// canarySettle is how long the install and restart get, counted from when
// the release was issued, before any check can fail the release.
canarySettle = 30 * time.Minute
// minFinished is the fewest finished tasks the park rate is judged on.
// minFinished is the fewest finished tasks needed to judge the park rate.
minFinished = 5
// minLogCoverage is the least of the baseline window the error log must
// cover for the error signal to be judged.
// minLogCoverage is how far back into the baseline window the error log
// must reach before error counts are compared.
minLogCoverage = time.Hour
)
@@ -36,8 +36,8 @@ type CanaryWindowSignals struct {
// Finished counts tasks that reached a terminal or review status; Bad
// is those that parked or died.
Finished, Bad int
// Errors counts error-level log lines over Covered, the part of the
// window the log reaches back over.
// Errors counts error-level log lines within Covered, the part of the
// window that the log still reaches.
Errors int
Covered time.Duration
}
@@ -59,9 +59,10 @@ type CanaryVerdict struct {
Reasons []string
}
// JudgeCanary decides on version elapsed after it was issued. A hard signal
// rolls back at any check once the release has settled; the relative signals
// are judged only when the window has passed, against the baseline window.
// JudgeCanary decides what to do with a release, given how long ago it was
// issued. Once the release has settled, a failed hard check rolls it back at
// any time. Error and park rates are compared with the baseline only after the
// full window has passed.
func JudgeCanary(version string, elapsed time.Duration, s CanarySignals) CanaryVerdict {
if elapsed < canarySettle {
return CanaryVerdict{Decision: CanaryWait, Reasons: []string{"settling after install"}}
@@ -100,7 +101,8 @@ func JudgeCanary(version string, elapsed time.Duration, s CanarySignals) CanaryV
}
// judgeErrors fails when the canary logged more than twice the baseline's
// error lines plus ten, each scaled to a full window from what the log covers.
// error lines plus ten. Each count is scaled up to a full day when the log
// covers only part of its window.
func judgeErrors(baseline, canary CanaryWindowSignals) (string, bool) {
if baseline.Covered < minLogCoverage || canary.Covered <= 0 {
return "error log does not reach back over the baseline; error signal skipped", true
+9 -8
View File
@@ -31,8 +31,8 @@ var (
const updateSettingsPath = "/api/control-plane/resources/update-settings"
// Signals reads what the canary reports, splitting tasks and error lines into
// the window before issued and the window from issued to now.
// Signals reads the canary's current state. Tasks and error lines are split
// into the day before the release was issued and the time since.
func (d CanaryDashboard) Signals(ctx context.Context, issued, now time.Time) (CanarySignals, error) {
var s CanarySignals
var err error
@@ -51,8 +51,8 @@ func (d CanaryDashboard) Signals(ctx context.Context, issued, now time.Time) (Ca
return s, d.errors(ctx, issued, now, &s)
}
// installed is the daemon version the canary runs and the raw snapshot it
// offers, which an install must echo back.
// installed returns the daemon version the canary runs, and the raw update
// snapshot it offers, which an install request must send back unchanged.
func (d CanaryDashboard) installed(ctx context.Context) (string, json.RawMessage, error) {
var body struct {
Snapshot json.RawMessage `json:"snapshot"`
@@ -102,8 +102,8 @@ func (d CanaryDashboard) actionAlerts(ctx context.Context, since time.Time) ([]s
return titles, nil
}
// tasks pages back through tasks by last update until the baseline window
// has been read.
// tasks reads tasks, newest update first, until it reaches tasks older than
// the baseline window.
func (d CanaryDashboard) tasks(ctx context.Context, issued time.Time, s *CanarySignals) error {
from := issued.Add(-CanaryWindow)
cursor := ""
@@ -141,8 +141,9 @@ func (d CanaryDashboard) tasks(ctx context.Context, issued time.Time, s *CanaryS
return nil
}
// errors counts error-level lines in each window. The log read is bounded, so
// a truncated read covers only back to its oldest line.
// errors counts error-level lines in each window. A log read returns a
// limited number of lines, so a truncated read only reaches back as far as
// its oldest line.
func (d CanaryDashboard) errors(ctx context.Context, issued, now time.Time, s *CanarySignals) error {
var body struct {
Entries []struct {
+11 -9
View File
@@ -18,13 +18,14 @@ import (
"github.com/samcharles93/archie-core/internal/infrastructure/signedoci"
)
// Promote points stable at the release published as version. The signature
// covers the statement, not the tag, so stable is the same signed manifest
// and needs no re-signing. A prerelease, or a release issued before the one
// stable names, is refused: hosts would refuse the latter as a replay.
// Promote points the stable tag at a published release. The signature covers
// the release statement, not the tag, so the release does not need signing
// again. It refuses a prerelease, and a release issued before the one stable
// already points at, which hosts would reject as a replay.
//
// Each image repository in latest has its v<version> tag copied to latest
// first, so a failure leaves stable unmoved and a rerun finishes the job.
// Each image repository in latest gets its v<version> tag copied to latest
// before stable moves, so if that fails stable is unchanged and running
// Promote again finishes the job.
func Promote(ctx context.Context, repository string, key ed25519.PublicKey, version string, latest []string) (Statement, error) {
source := distribution.Source{Reference: repository, Key: key}
release, err := Fetch(ctx, source, Tag("exact-pin", version))
@@ -82,9 +83,10 @@ func promoteImage(ctx context.Context, image, version, agentImage string) error
return nil
}
// verifiedManifest is the manifest the version tag resolves to now, checked to
// carry the statement already verified, so a tag moved in between cannot slip
// an unverified manifest onto stable.
// verifiedManifest returns the manifest the version tag points at now, after
// checking it carries the statement that was already verified. This stops a
// tag that moved in the meantime from putting an unverified manifest on
// stable.
func verifiedManifest(ctx context.Context, repo *remote.Repository, version string, statement []byte, key ed25519.PublicKey) (ocispec.Descriptor, error) {
desc, err := repo.Resolve(ctx, Tag("exact-pin", version))
if err != nil {