Ch.36: System Design: Why Green CI Still Breaks Production

Outline

Transcript

0:00 Take a checkout release. CI builds it, every required check turns green, and a regional canary sends the new version to a small first slice of live traffic. 5 minutes later, checkout errors jump from 1% to nine. Oh, wow. All green above the deploy button, red everywhere below it. Pause the rollout. The second-wave commands were already in flight across six Regions when that health verdict arrived. Then the controller restarts. Current reports put the new artifact in two Regions, the old one in one, and stale data in three.

0:31 So green CI is the easy part. We cannot prove what half of production is running. Here is the CI/CD release-system design problem we will return to: prevent one failed canary from becoming a global outage. Build and verify one artifact on the left, persist release intent and policy in the release authority, send bounded waves through regional agents, then feed health and observed state back through evaluation and reconciliation. We will unpack each path, then use this same map to recover the incident at the end.

1:01 Yeah. One commit, one artifact identity, and two states: what we want versus what we can prove. That stops the next wave without guessing. That partial rollout gives us the functional requirements. A reviewed revision and authorized policy trigger one workflow. The platform builds the bytes once, gives them an immutable content fingerprint called the artifact digest, and attaches signed build provenance: who built them, from which inputs, and how. CI has to prove more than “tests passed,” you know?

1:31 It runs a dependency-aware graph, meaning each build, test, or scan starts only after its prerequisites succeed, and the release barrier waits for every required result. If that evidence passes, an authorized user creates an immutable release manifest naming the artifact, configuration, targets, rollout policy, health policy, and initiator. Production starts with a small canary, then advances through bounded regional waves. Operators still need pause, resume, cancel, rollback, and supersession. Supersession means a newer release generation replaces the older one as the authority. Those controls must survive restarts, repeated commands, late replies, missing replies, and a wave that finished in only some Regions.

2:11 The audit API keeps two facts separate. Desired state is what the release asks each Region to run. Observed state is what each Region can freshly prove it runs. It also shows health evidence, blockers, transitions, and actor identity. And source, build, release, deployment, and rollback authority stay separate. Each component now has a clean line of responsibility we can test against the incident. The functional boundary now forces a harder question: what guarantees must still hold when a worker, coordinator, or Region fails?

2:42 Those functional requirements imply the non-functional requirements. Promote exactly the verified digest. Never rebuild for production under the same release, and never advance on unavailable, old, conflicting, or statistically thin evidence. Bound the first exposure and the number of Regions changing together. Record each transition before its command leaves the control plane, and make repeated commands converge on the same operation. Regional rollout must keep converging if the coordinator restarts or loses contact with a Region, because its replacement recovers from durable state rather than memory.

3:15 For sizing, assume 200 services, 24 Regions, 300 releases a day, and bursts of 30 workflow starts a minute. At that burst rate, none of us is nursing the queue by hand; workflow starts need durable queuing. Across the full footprint, local control contains reachability failures. A decisive health breach should begin rollback within 2 minutes, and every release decision should remain queryable for a year. Credentials stay isolated by role. Rollback also has a compatibility limit. Restoring old code cannot unwrite a migration, recall a message, or reverse an external charge.

3:49 That narrows the guarantee to controlled exposure and explainable recovery, not zero failures or time travel. The complete control loop is next. With both requirement sets fixed, unpack the build and release-authority path first instead of reading the summary map box by box. The reviewed revision enters the Workflow API and durable workflow store. A graph scheduler sends ready work to isolated builders and test workers. Successful output becomes artifact A seven in the registry, with signed provenance beside it.

4:20 The Release API freezes release R 42 and its transition log, while policy checks authorization and required evidence. Yeah. The wave scheduler writes the authorized regional targets, and then... Each agent asks its regional cluster controller to converge on A seven and reports the live local version. Canary metrics, service health, and control-plane signals feed an evaluator whose answer is promote, hold, or roll back. When that coordinator comes back, the reconciler compares durable desired state with those fresh regional reports, and the audit API explains every gap.

4:53 Exactly. The arrows form a loop, not a one-way pipeline. If three Regions go quiet, the loop does not, you know, color them green just to finish the diagram. Yeah. CI proves what we built. The release side limits exposure, and reconciliation tells the replacement controller what happened. The public docs supporting these patterns are linked in the description. That complete loop depends on one trustworthy identity. What does “build once” require? The worker receives pinned source, dependency locks, a toolchain image, and build parameters. It runs in isolation and produces A seven.

5:29 The registry computes its cryptographic digest, the content fingerprint we defined earlier. Change 1 byte and the identity changes. My instinct is to hear “same commit” and, honestly, assume “same artifact.” The source is identical, so why not rebuild? For example, a release engineer rebuilds on Friday after a base image moved on Thursday. Production gets different bytes, while the green test record still describes Wednesday's artifact. Oh, right. The digest follows A seven through every stage. Build provenance connects that digest to its builder, declared inputs, and process, so policy can verify both the bytes and their history before promotion.

6:08 Yes. Stages add evidence around A seven without replacing it. Configuration gets its own version because it can alter behavior without changing the binary. Now we can trust the object entering CI. Once artifact identity is stable, CI decides which evidence is required. A sequential script can waste time and hide dependencies, so model the workflow as a graph where jobs start only when their parents succeed. Compile can unlock unit tests, integration fixtures, a security scan, and a platform matrix. Packaging waits for its declared parents, while promotion waits for all required leaves to finish.

6:43 Matrix jobs expand one definition across versions or platforms. An earlier attempt can wake up after its retry succeeds. The scheduler stores a generation with each worker's time-limited job claim, so that stale worker cannot overwrite the successful result. Consider a CI engineer who changes a Python dependency lock but leaves the cache key tied only to the source commit. Can yesterday's green result still count? Not safely. We have probably all trusted a cache hit that had no business being green.

7:13 The key must name every meaningful input, and policy must permit reuse. Fail-fast stops doomed downstream work; collect-all keeps independent diagnostics. Then the barrier means this exact graph passed for A seven. It is evidence about the artifact, not a production verdict; release policy judges live traffic. That green evidence opens the release contract. What must be frozen before the first Region changes? Freeze R 42. Its manifest binds A seven to the configuration, target set, rollout and health policies, initiator, and workflow evidence.

7:46 A release manager might say, “We are only widening the target. Why create a new release?” Yes. For example, an operator widens an approved six-Region target to the full global fleet. If the same row mutates, the audit history can no longer prove which scope the approver accepted. Yeah. The manifest stays immutable and progress lives separately. A changed target or policy creates a newer generation with lineage to the old one. That split helps. Policy verifies that the actor may release this service to these targets, required CI evidence is current, provenance passed, and configuration is approved.

8:22 The manifest answers what we authorized; the transition log answers what happened. That gives dispatch a stable contract. The immutable manifest leads straight to the dispatch boundary. When does R 42's command become real? The dangerous implementation writes “deploying” in memory, sends commands, and plans to persist afterward. A crash can then produce a real deployment with no durable record. Reverse the order. Commit the next desired transition and an outbound command record in one transaction. A dispatcher reads that durable intent and sends it to the regional agent.

8:55 Imagine it crashes after send but before acknowledgement. The replacement sends again. Wait, that flips my instinct. I still read “command accepted” as “deployment finished.” Here it actually means duplicate sends are normal. Yes. Duplicate send is normal; duplicate work is what the identity prevents. The command carries release ID, target, desired digest, generation, and an operation token. The agent records that identity before acting, so a repeat returns the existing operation. Right. The acknowledgement also names the generation.

9:26 A late response from an older release generation cannot advance R 42. We have at-least-once command delivery, but idempotent handling makes repeats converge on one desired operation. Because intent existed before dispatch, a replacement controller can resume the durable outbound-command queue and find operations that still lack fresh observations. Restart recovery becomes a replay of durable work instead of guesswork. Next, durable dispatch raises the ownership question. Why put an agent in every Region instead of letting one global controller call every cluster directly? A regional agent narrows credentials and failure domains.

10:02 It watches its Region's authorized target, validates generation order, delegates rollout inside the local cluster, and publishes observations back. Observation is more than “command received,” right? Much more. For example, Region West accepts R 42, replaces some instances, and then loses the global link. Local convergence may continue while the global control plane kind of goes blind to that Region. Yeah. Command acknowledgement proves the agent accepted an instruction. Observed state proves what the local controller reports now.

10:32 Neither proves the application is healthy. Exactly. Think of a three-step delivery: a dispatch receipt says the instruction arrived, a doorstep scan says what reached the target, and opening the package tells you whether it works. That leaves health evaluation with three separate evidence questions. I love that separation. With regional convergence established, define the wave scheduler's unit of exposure. Preproduction verifies wiring. A one-box or small-instance canary limits the initial live impact.

11:01 Later waves add bounded zones or Regions, with a concurrency cap. Yeah. The on-call watching a clean canary is going to ask, “Why are we still waiting?” Because Google's public SRE guidance calls out the low-traffic trap: a short comparison can mislead without enough time and samples. Bake time is the waiting period that lets traffic, cache churn, dependency calls, and scheduled work reveal a failure. Oh, right. For example, picture a midnight canary that serves only a handful of checkouts and happens to miss every failure.

11:33 “No errors” looks perfect because almost nothing happened. Insufficient evidence means hold, not pass. And a percentage alone can hide concentration in one critical dependency or failure domain. That is why AWS's public deployment guidance layers one-box exposure, waves, isolated failure areas called Availability Zones, and Regions. The target plan needs the Region layout and service dependencies, not just a percentage slider. Right. Progressive delivery is controlled experimentation with a stop condition, and each wave buys another chance to detect harm before the blast radius widens.

12:07 That sample floor leads to a health decision once enough traffic arrives. The canary finally has enough traffic. What does the evaluator compare? First, compare it with a control group still running the prior release. Look at checkout errors, latency, saturation, and business success. Relative comparison helps separate release harm from a site-wide event. Yes. Consider a payment provider failing for every checkout. Both groups degrade together, the relative difference looks small, and customers still cannot pay.

12:37 Yeah. Canary and control are two checkout lanes; absolute service health is the building fire alarm. The relative view can actually look even while both lanes are unsafe. How quickly the service consumes its allowed failure budget, hard error ceilings, dependency health, and checkout completion can all block promotion. Every checkout signal needs a freshness window and enough samples. Metrics older than the wave they judge cannot approve it; missing or contradictory evidence holds. Yes. The evaluator records the query window, policy version, sample counts, result, and evidence link.

13:10 Healthy relative and absolute signals promote. A decisive breach rolls back. Right. Silence is not green; a broken metrics path holds the rollout instead of authorizing a wider wave. That hold-on-missing rule opens the controller-restart case, and this is where it gets weird. Durable intent says wave two targets six Regions. Two fresh reports show A seven, one shows A six, and three reports have expired. A dashboard really wants one label. “In progress” feels harmless, but it hides the safety question.

13:41 Desired state asks all six Regions to run A seven. Fresh observations prove the current version in only three. The others are `UNKNOWN`, meaning we cannot currently prove what they run. Take six smoke sensors: three dead sensors do not average to safe. Unknown is not failed because the agents may have finished locally, and it is not succeeded because their reports are stale. What does the reconciler do? It stops further promotion, refreshes observations, and safely repeats any durable command whose target has not confirmed the current generation. Regional idempotency absorbs duplicates.

14:17 If a Region still runs the prior digest, reconciliation can reissue the operation. If it reports A seven, no new rollout starts. And if communication stays down? The release remains held. Policy may define a separate contingency, but absence alone never manufactures success. The audit surface shows the exact gap instead of compressing uncertainty into a color. That prevents an unknown Region from authorizing the next wave. Next, the decisive breach opens rollback. Do we reverse R 42? We create R 43, an authorized forward release whose desired artifact is the previously approved digest A six.

14:52 It gets its own immutable manifest, then uses the same wave, command, observation, and health-gate machinery. Why call that forward when the code is older? Because the coordinator advances to a new generation. History does not rewind, and late acknowledgements for R 42 stay with that attempt. R 43 explicitly supersedes it. Hold on. The code moves backward, but release history only moves forward. The application may still have written data under A seven. Take A seven writing a required database field and charging a customer before its canary fails. A six must still read the row, while the charge needs idempotency or a separate refund because reverting the binary does not actually recall it.

15:36 Yeah. Database changes often need an expand-and-contract sequence: add a shape both versions can read, move readers and writers, then remove the old shape. Messages need schemas old and new consumers can both understand. Policy blocks an incompatible rollback or requires a safer forward fix. That compatibility boundary carries into the supersession race. That rollback creates one more race. Imagine an operator clicking resume on R 42 just as automation creates R 43. Without concurrency control, both generations can command the same Region.

16:08 Right. Give each target one authoritative generation. R 43's compare-and-set update succeeds only if the stored generation is still the one it expects. Yeah. So a stale resume click loses the race instead of resurrecting R 42? Exactly. Pause and resume use the same expected-generation check. Once superseded, the scheduler refuses new R 42 work. Regional agents reject older generations but still publish their observations. Right. Only one current release generation may advance each regional target at a time. Yeah. One generation advances the target; reports from every older generation stay attached to their own audit trail.

16:45 Old evidence stays visible instead of regaining authority. That supersession guard raises the recovery question: can we replay the incident without two releases competing for the same target? Return to the unchanged architecture. The Workflow API bound checkout's revision to A seven, the graph completed, and the registry preserved its digest and provenance. Production failed, but the verification record did not change with it. The Release API recorded R 42 before dispatch. Wave one reached the canary; relative checkout errors and the absolute error ceiling failed, so the evaluator wrote a rollback decision and blocked any further promotion.

17:22 The restart did not actually erase wave two intent. The reconciler reads durable history, then asks each regional agent one question... What are you running now? Two Regions confirm A seven, one remains on the prior version, and half the wave is still unknown. Right. A blind global rollback would be another guess. R 43 targets A six and supersedes R 42. Agents deduplicate repeats by generation and operation token. Regions already on A six do nothing, Regions on A seven roll back, and silent Regions keep the release held.

17:55 Yeah. The audit API can now answer which artifact passed CI, who authorized production, which waves received commands, what each Region reported, why promotion stopped, and what rollback could not undo. The result is recovery without guessing. Durable intent survived the restart, idempotent agents converged locally, and uncertainty stayed visible until fresh evidence resolved it. That recovery walkthrough leaves one final question: what safety contract did the architecture actually buy? It bought a smaller blast radius and an honest answer when the controller wakes up confused. Green CI proves that required checks passed for specific bytes.

18:31 It does not prove those bytes are safe under production traffic. Honestly, I like that restraint. The system refuses to call silence success just to look finished. Progressive delivery limits the uncertainty, while supersession and regional reconciliation make restart and rollback explicit. Exactly. Build once. Persist desired state. Bound each wave. Demand evidence. Preserve uncertainty until you can resolve it. That is how the release platform helps contain a bad deploy before a regional failure spreads systemwide.

19:00 Thanks for listening to Learning Podcasts.