Continuous Delivery & Operations
Learning Objectives
- You can separate a verified build artifact from environment-specific release configuration.
- You can plan backward-compatible API and schema changes across mixed revisions.
- You can design release gates, smoke checks, and rollback decisions without requiring a cloud account.
In the CI example, renaming a response field stopped the source check because the view still expected its old name. Updating both the producer and the view could make that check pass. What happens to someone who opened the page before either change was released?
Delivery concerns how a verified change reaches an environment where older clients may still be running and the database contains valuable state. We will follow a field change across two browser versions, then follow a release from its built artifacts to a request through the running application.
Source revisions and release artifacts
Call the existing revision r17 and the proposed revision r18. These are short labels for this example; a real release records its source revision. Build its artifacts from the revision that passed checks, retaining the dependency lockfiles and build configuration for both API and client. Also record whether uncommitted changes were present when building. A fresh unpinned dependency install on the production machine could produce different output from the artifact that was tested.
Compatibility with older browser clients
The listing response from the CI example originally contains:
{ "title": "Desk lamp" }The new source changes it to:
{ "name": "Desk lamp" }The new typed client may compile perfectly with the new API. Before reading on, predict what the old browser will obtain from the new response. This small JavaScript model keeps the two readers visible:
const oldHeading = (listing) => listing.title;
const currentHeading = (listing) => listing.name;
const response = { name: "Desk lamp" };
console.log(oldHeading(response));console.log(currentHeading(response));Running the model prints undefined, then Desk lamp. The old reader no longer obtains its heading, while the new reader does. The source check for r18 compared its current producer and consumer; it could not update a page already open with the r17 JavaScript.
An additive transition might temporarily return both fields, update clients, observe the remaining usage, and remove the old field only under an explicit compatibility policy. A versioned endpoint is another choice. Document the compatibility and maintenance costs of the chosen strategy.
For this listing release, choose the additive transition: r18 returns both title and name, each containing Desk lamp. Both readers obtain the expected heading. Keep the old field while the previous browser version remains supported.
Preserve a small old-client or recorded-request contract check when evolving an API that promises compatibility. For this change, that check would expose the missing heading before release. Raw HTTP remains useful because the consumers are not all rebuilt from the same TypeScript source.
The next exercise uses a separate profile response with displayName and
name. Its name formatting and two consumer functions are supplied. Preserve
the field read by the older consumer while supporting the newer one. Predict
what removing displayName would do to an already-open browser, then check your
implementation against both consumers.
Profile representation
0 / 15 points
The editor contains three files:
- Edit
profile.ts. - Keep
legacy-profile.tsandconsumers.tsunchanged.
Use Files to select a file, or Show file tree if the tree is hidden. All three files are submitted, including unchanged files and unopened tabs.
Complete publicProfile(record) for an additive response change. The older consumer requires id and displayName; the new consumer requires name. Both must keep working without edits, and name must equal the existing public display name.
The provided legacyProfile(record) formats the name and returns the existing public representation. Reuse its result and keep the input record unchanged. The input record also contains private data; the new response must contain only the existing public fields and name.
For example, an existing public display name of Sam Lin remains the value seen by the older consumer and becomes the value seen through name by the new consumer. Do not change name formatting or rebuild the consumers around the new field.
Choose Submit solution. Preserving the older consumer is worth 5 points; supplying the same value to the new consumer is worth 10.
Supporting both fields lets an already-open browser continue using the response while the newer browser uses its new field.
Schema changes across application versions
The database has a similar compatibility boundary: a destructive schema change can break the running old API before the new API is ready. An expand-and-contract approach separates adding compatible structures from removing obsolete ones.
For example, add a nullable column or new table, deploy code that can populate and read it safely, and migrate existing data deliberately. Enforce new constraints or remove old structures only after all relevant application versions support the change. The details depend on the invariant and database size.
Figure 1 shows the ordering during a version overlap. Adding r18 does not itself retire r17’s database needs. Keep the compatible structures while preparing the data and retiring the old code paths; remove obsolete structures only when that transition is ready.
Rolling back application code does not automatically undo a database migration. A migration may destroy information or take substantial time. Backups, restore practice, and forward fixes can be part of the recovery plan.
Imagine that r18 has started while some requests still reach r17. Trace which database structures both versions need before deciding when an obsolete structure can be removed.
Overlapping API revisions
0 / 5 points
An older API reads accounts.display_name. A newer API will use display_label, and both revisions may serve requests during a release. Existing accounts already have display_name values.
Which plan supports a compatible transition?
Browser-to-database path in the local release
With a compatible response and schema, we can follow r18 into its release
environment. The public listing read is now backed by PostgreSQL.
Figure 2 shows the browser’s same-origin path
through the release gateway. The gateway serves the exported client files and
forwards /api/... to Hono. Hono resolves the session, authorizes the operation
and accesses PostgreSQL.
After login sets an HttpOnly session cookie, the browser automatically includes that matching cookie in subsequent same-origin requests. Client JavaScript reads the session response’s CSRF token and adds it to protected requests. The gateway forwards these headers, and Hono checks permission.
The database URL and server cookie/origin settings belong to the release environment. Keep server secrets in the server’s runtime or release configuration; browser bundles are visible to their users. Non-secret browser configuration, such as an API base URL, may be fixed at build time, so decide whether each environment needs a distinct browser build or a deliberately designed runtime configuration endpoint. Derive these settings from the browser-facing topology and protocol:
| Decision | Local HTTP rehearsal | Hosted HTTPS behind the same-origin gateway |
|---|---|---|
| Browser API destination | Relative /api/... requests through the page’s origin | Relative /api/... requests through the page’s origin |
| Allowed client origin | The exact HTTP scheme, host and browser-facing port | The exact public HTTPS origin |
Session cookie’s Secure attribute | Omitted for the stated HTTP configuration | Enabled so the browser sends it only over HTTPS |
| Build mode | A release artifact built in production mode | A release artifact built in production mode |
For example, a page opened at https://market.example.test/ can request /api/listings at that same origin. The gateway forwards that request to the API container’s internal address.
The release cases name these settings explicitly. publicApiBase is the prefix before /api/...; an empty string keeps that request relative. CLIENT_ORIGIN identifies the permitted browser origin, and COOKIE_SECURE controls the session cookie attribute. Hono enforces API authorization. The hosted HTTPS gateway provides the encrypted browser connection.
Release gates, readiness and smoke checks
A release gate is a check or decision that must succeed before the next release step. A readiness check asks whether the started service can accept its intended requests. A smoke check exercises a small representative path through the running release, such as login followed by a protected request.
A raw HTTP smoke script has no browser cookie jar unless one is explicitly supplied. Such a script must extract the received session cookie and send a Cookie header on later requests. A release workflow might be:
verify source-> build identified artifacts-> prepare target configuration-> apply reviewed compatible migrations-> start new revision-> readiness checks-> route traffic-> bounded smoke checks and monitoringContinuous delivery can include manual approval before deployment.
Following a failed readiness check
Suppose r18 has passed CI and produced identified artifacts. Its process starts
and /health returns 200. Would you send users to it yet? Consider this release log:
artifact revision: r18process startedGET /health -> 200readiness: GET /api/listings -> 500API log: permission denied for table listingstraffic switch: blockedThe process answers HTTP, but this revision cannot read its listings table. The
build and /health checks exercised narrower paths. The log points to the
database role configured for r18; inspect its access before repeating the
read.
In this scenario, an operator corrects the role’s required access and repeats
the failed check. This time, /api/listings returns 200 with the expected public
records. The release can proceed to its next gate. A bounded authenticated smoke
check then logs in and performs a protected request through the same gateway.
Keep readiness checks bounded, and keep smoke accounts and writes controlled so they do not contaminate real user data. When rehearsing with Compose, stop only the recorded project that owns those services. After that controlled flow succeeds, continue observing error rates and logs as the release receives traffic.
Logs, monitoring and recovery
Record useful request identifiers and structured error information without passwords, tokens, or sensitive bodies. Observe request errors, latency, and resource saturation. Decide which observations should trigger investigation or a recovery step so the monitoring can guide an action.
A short recovery procedure identifies the logs to inspect, the gate that failed and the available recovery actions. In our example, the failed readiness gate kept users on the existing revision while the configuration was corrected. A failure after traffic has moved needs a decision about restoring the earlier application, fixing forward, or another prepared recovery action. Revisit the database compatibility before choosing a code rollback.
Diagnose release configuration and evidence
Use the following cases to trace the browser’s destination, then the gateway and API checks. Identify where expected behavior is lost, or why the stated gates permit the next step. You can reason from the configurations and observations without setting up a release environment.
Each release observation supports a particular claim. Build checks verify artifact production. HTTP checks, including HTML fetches, observe server responses. A browser check can execute the released JavaScript and exercise its authenticated session workflow. In the final question, match each claim to the evidence actually supplied.
Match observations to claims
0 / 5 points
A revision produces a successful client build, starts a server
process, returns the declared JSON from /api/listings, and logs that
request. Select every claim directly supported by one of those
observations.
Check Your Understanding
- Why should released artifacts be identifiable by source and dependency revision?
- Why does current-source type safety not establish old-client compatibility?
- What does an expand-and-contract migration try to preserve?
- Why is database rollback different from restarting an older application image?
- Which observations should continue after a smoke check passes?