Skip to content

Part 9 · Blueprint 63

Cloud CI/CD & Ephemeral Container Execution

15 min reading · Sources · Editorial review pending

Destroying a container does not prove a clean host or prevent cross-tenant cache disclosure.

More
20px
Reading list
Page details

Published date · Last edited:

Draft edition. Editorial review and supplementary reading recommendations are still being completed.

Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Message Queues & Event Streams: Kafka vs. RabbitMQ, Security Architecture, Zero-Trust & Multi-Tenancy, Distributed Task & Cron Scheduler (Temporal / Quartz Scale).

Sixty-second mental model

Problem: Destroying a container does not prove a clean host or prevent cross-tenant cache disclosure.

Use: Use an explicit sandbox and separate reusable artifacts from secrets.

Design boundary: Run tenant-supplied builds under explicit isolation, artifact and credential boundaries. A container image is not alone a complete security boundary for hostile build code.

Layer 1 · Intuition

Hypothetical scenario: Northwind is designing ci and ephemeral execution. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one job attempt means and which component owns the job state and isolation boundary.

Think of a controlled workshop rented for one untrusted job. Separate the requester from job state and isolation boundary, then identify the retained evidence needed after failure.

Authority
The entitled state owner.
Invariant
A rule preserved across concurrency and failures.

Architecture and worked reasoning

Design boundary: Run tenant-supplied builds under explicit isolation, artifact and credential boundaries. A container image is not alone a complete security boundary for hostile build code.

Responsibilities on the request path

CI and ephemeral execution: responsibilities and request directionRun tenant-supplied builds under explicit isolation, artifact and credential boundaries. A container image is not alone a complete security boundary for hostile build code.Job admissionIsolated runnerArtifact stagingPublication policy
Run tenant-supplied builds under explicit isolation, artifact and credential boundaries. A container image is not alone a complete security boundary for hostile build code.

Workload and limiting resource

Hypothetical 100 jobs/minute with three-minute mean runtime require about 300 concurrent slots under stable-flow assumptions. At two selected CPU cores/slot, that requests 600 cores before headroom and control-plane work. Bursts and long-tail runtime can exceed this average occupancy.

Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.

Mutation or publication path

CI and ephemeral execution: mutation boundaryAuthorize repository/job identity and resource budget. Then: Run with constrained network, filesystem and short-lived credentials. Then: Verify and publish artifacts only from the permitted job state.Step 1
Authorize repository/job identity and resource budget.
Step 2
Run with constrained network, filesystem and short-lived credentials.
Step 3
Verify and publish artifacts only from the permitted job state.
Authorize repository/job identity and resource budget. Then: Run with constrained network, filesystem and short-lived credentials. Then: Verify and publish artifacts only from the permitted job state.
  1. Authorize repository/job identity and resource budget.
  2. Run with constrained network, filesystem and short-lived credentials.
  3. Verify and publish artifacts only from the permitted job state.

Observation and recovery path

CI and ephemeral execution: observation boundaryRead a stable job/attempt timeline. Then: Download authorized artifacts with provenance. Then: Expire secrets/workspaces and recover orphan attempts.Step 1
Read a stable job/attempt timeline.
Step 2
Download authorized artifacts with provenance.
Step 3
Expire secrets/workspaces and recover orphan attempts.
Read a stable job/attempt timeline. Then: Download authorized artifacts with provenance. Then: Expire secrets/workspaces and recover orphan attempts.
  1. Read a stable job/attempt timeline.
  2. Download authorized artifacts with provenance.
  3. Expire secrets/workspaces and recover orphan attempts.

Failure that changes the decision

Hypothetical scenario: A build steals a reusable deployment credential and publishes an unrelated artifact. Scope credentials and require provenance/policy at publication, not merely at job submission.

Attempt this decision before reading the explanation

Can reusing the same workspace safely accelerate every tenant’s build?

Not without strong cleanup/isolation. Cached files can disclose secrets or poison later builds; define cache keys, trust scope and verification.

Supporting mechanism analysis

Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.

Hypothetical scenario. Northwind teams submit document conversions and scheduled reports. Dev places a queue in front of containers. Maya asks for a stable receipt even when dispatch is interrupted; Priya asks which data and services a running job may access.

Connect submission identity, accepted lifecycle, admission, isolation and results. Start with approved job types and immutable inputs; arbitrary customer code remains a different security product. This is a core System Design case with no model or agent prerequisite.

Before you continue: Does creating a delivery message alone define the accepted job lifecycle?

That leaves submission uncertainty, results and ownership transitions dependent on transport state. Define the durable obligation and the relationship between one job and its attempts.

This gives a lost receipt a stable identity to recover. The selected worker-time calculation can then distinguish useful capacity from repeated attempts and waiting.

A submission contract identifies the tenant, job type, immutable input reference, selected limits and caller intention. Repeating an uncertain submission with the same intention returns the existing job identity. Reusing that identity with incompatible input is rejected. This prevents a lost receipt from silently creating another report or conversion.

The authoritative job record is durable before the service acknowledges acceptance. Record a recoverable scheduling obligation in the same transactional boundary where possible. A queue message can then be published and retried independently. Without that connection, a crash can leave an accepted job permanently absent from the worker queue.

Acceptance is not a reservation of immediate compute. The receipt states whether the job is admitted to a bounded queue and how its deadline and cancellation work. Reject before acceptance when the tenant’s retained-work or resource budget is exhausted. Returning an optimistic receipt and later forgetting the job violates the very contract the platform exists to provide.

The scheduler assigns an attempt identity and ownership generation through a conditional transition. A worker claims that attempt, obtains narrowly scoped input access and runs the approved job type. Heartbeats are observations supporting timeout decisions; they do not prove that a silent worker has stopped.

Store attempt outcomes separately from the logical job state. A failed attempt may leave the job eligible for retry, while a terminal input error may end it. The final result reference is published only by a currently authorized transition. Logs and progress events help diagnosis but are not the sole source of accepted completion.

Use immutable result objects named by job and attempt. The platform can retain an unaccepted attempt’s object temporarily without exposing it as the authoritative result. A conditional result pointer connects the accepted job outcome to exactly one complete artifact. This avoids using overwrite arrival order as the winner rule.

Hypothetical scenario. Submit operation K creates job J with immutable input and a durable scheduling obligation. A broker notification wakes the scheduler but is not the sole record that J exists. Scheduler restart rebuilds pending work from durable state rather than assuming every accepted job still has a queue message.

The scheduler chooses a worker compatible with the job's declared CPU, memory and capability requirements. A task queue distributes items; resource scheduling additionally decides whether a particular worker can admit the item without violating tenant or machine limits. Keep resource claims recoverable and release them through a guarded lifecycle.

A worker receives a scoped attempt identity, input reference and authority token, not unrestricted platform credentials. It uploads an immutable candidate result; the job authority accepts it only for the current attempt generation and required input. Cancellation changes which transitions remain legal, but a running process may continue until enforcement reaches it. State which effects can be stopped and which require protected remote identities.

Hypothetical worked example. Select twelve worker slots and a mean attempt occupancy of thirty seconds for one homogeneous job class. Ignoring scheduling overhead and failures, the attempt capacity is 12 ÷ 30 = 0.4 attempts per second, or 0.4 × 60 = 24 attempts per minute. This is a planning subtotal, not a measured service guarantee.

Select eighteen new logical jobs per minute and one attempt per job initially. Useful spare capacity is 24 − 18 = 6 jobs per minute. A backlog of one hundred twenty jobs would drain in 120 ÷ 6 = 20 minutes if arrivals and successful service remain constant. Increasing submission throughput does not increase those worker slots.

Now select an average of 1.2 attempts per successful logical job under retries. The same twenty-four attempts per minute support 24 ÷ 1.2 = 20 successful jobs per minute. Spare useful capacity becomes 20 − 18 = 2 jobs per minute, and the backlog drain estimate becomes 120 ÷ 2 = 60 minutes. Attempt occupancy and retry mix can differ in reality; these deliberately fixed assumptions expose the unit change.

For the approved-type baseline, workers receive read access to declared inputs and write access only to their attempt output prefix. The control plane keeps scheduler credentials and tenant policy outside that environment. Apply CPU, memory, storage, network and wall-clock bounds; a memory cap does not bound outbound requests or retained logs.

Containers are a packaging and resource-management mechanism. Their suitability as isolation depends on the threat model, runtime and host boundary. Running hostile code may require a stronger sandbox and a separate worker fleet. Do not infer safety from a container icon while mounting broad credentials or permitting privileged host access.

Admission must also account for fairness. A tenant with a large backlog should not consume every scarce slot indefinitely. Separate classes or weighted scheduling can help, but enforce both retained-work limits and active-resource limits. Otherwise a polite active limit can coexist with an unbounded tenant queue.

Kubernetes documents Job completion and replacement behavior . Inspect its failure and retry semantics before using it as the execution substrate. Controller-managed completion does not establish exactly-once business effects; the application still needs stable identities and a guarded result boundary.

The platform can translate an accepted job into a Kubernetes Job while retaining its own tenant, input and result contract. Avoid exposing raw infrastructure state as the complete user lifecycle. A pod may disappear while the durable job remains unresolved, and a completed process can still fail result publication.

Layer 3 · Internals

A CI platform executes code supplied by a tenant and therefore needs a threat model stronger than assuming every build is trusted application code. A container shares its host kernel; a microVM supplies a different isolation boundary, with its own image, device and operational requirements. Firecracker documents a minimal virtual-machine monitor and mechanisms intended for isolated multi-tenant workloads; its existence does not prove a particular deployment is secure.

Separate the workflow DAG, each job's logical identity and every execution attempt. Bind outputs to verified input and environment digests before reusing a shared cache. A cache artifact is untrusted input unless its producer and integrity policy justify more trust; secret-bearing files must not become another tenant's dependency hit. Stream logs with bounded buffering and redaction, but keep completion in durable state rather than inferring it from the last log line. Destroy ephemeral compute and revoke credentials even when a worker disappears before reporting that cleanup finished.

Trade-offs and limits

ApproachProvidesRequires
Container isolationEfficient startup and familiar packaging.The shared host kernel remains part of the trust boundary.
MicroVM isolationProvides a separate guest-kernel boundary for a job.Images, virtual devices, host policy and lifecycle cleanup still require hardening.

Recovery decision

Hypothetical scenario: A build steals a reusable deployment credential and publishes an unrelated artifact. Scope credentials and require provenance/policy at publication, not merely at job submission.

Not without strong cleanup/isolation. Cached files can disclose secrets or poison later builds; define cache keys, trust scope and verification.

Write your design before revealing the review

Can reusing the same workspace safely accelerate every tenant’s build?

Evidence you can explain in your own design

Drafts and self-review are stored only in this browser. They are separate from reading completion.

Compare your decision

Not without strong cleanup/isolation. Cached files can disclose secrets or poison later builds; define cache keys, trust scope and verification.

A build steals a reusable deployment credential and publishes an unrelated artifact. Scope credentials and require provenance/policy at publication, not merely at job submission.

Check your understanding

Can reusing the same workspace safely accelerate every tenant’s build?

Not without strong cleanup/isolation. Cached files can disclose secrets or poison later builds; define cache keys, trust scope and verification.

How would you recover from this failure: A build steals a reusable deployment credential and publishes an unrelated artifact. Scope credentials and require provenance/policy at publication, not merely at job submission.

Start with the exact boundary that failed. Authorize repository/job identity and resource budget. Run with constrained network, filesystem and short-lived credentials. Verify and publish artifacts only from the permitted job state. Then recover evidence through the observation path: Read a stable job/attempt timeline. Download authorized artifacts with provenance. Expire secrets/workspaces and recover orphan attempts. Preserve the distinction between a confirmed state change and an unavailable response.

Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?

Hypothetical 100 jobs/minute with three-minute mean runtime require about 300 concurrent slots under stable-flow assumptions. At two selected CPU cores/slot, that requests 600 cores before headroom and control-plane work. Bursts and long-tail runtime can exceed this average occupancy. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Run tenant-supplied builds under explicit isolation, artifact and credential boundaries. A container image is not alone a complete security boundary for hostile build code.

Which component in this topology could be removed from a smaller first deployment?

Job admission, Isolated runner, Artifact staging, Publication policy name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Authorize repository/job identity and resource budget.

What evidence must a caller have before relying on the observation path?

Read a stable job/attempt timeline. Download authorized artifacts with provenance. Expire secrets/workspaces and recover orphan attempts. Not without strong cleanup/isolation. Cached files can disclose secrets or poison later builds; define cache keys, trust scope and verification.

45-minute interview rubric

  1. 00–05: scope job attempt and job state and isolation boundary.
  2. 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
  3. 12–28: draw job state and isolation boundary, numbered writes and reads.
  4. 28–40: challenge recovery: Use an explicit sandbox and separate reusable artifacts from secrets.
  5. 40–45: defend workflow_id placement, observations and remaining assumptions.

Go deeper

  • Firecracker · Primary document · firecracker-microvm.github.io. Use an explicit sandbox and separate reusable artifacts from secrets. Verified 2026-10-26.
  • Jobs | Kubernetes · Primary document · kubernetes.io. Use an explicit sandbox and separate reusable artifacts from secrets. Verified 2026-10-26.

Decision log

Use an explicit sandbox and separate reusable artifacts from secrets.

Preserve job attempt identity and job state and isolation boundary ownership.

Revisit changed workload, observations or recovery objectives.