Submit an issue View all issues Source
MIR-440

Sandbox Creation Saga

Done public
phinze phinze Opened Oct 2, 2025 Updated Apr 2, 2026

Convert sandbox creation to use saga framework, replacing manual defer-based cleanup with crash-recoverable saga pattern.

Scope

Extract Actions from SandboxController.createSandbox:

  • NetworkAllocatorAction - allocate network, compensate by deallocating
  • SpecBuilderAction - build container spec (pure, no compensation)
  • VolumeConfiguratorAction - configure volumes
  • ContainerCreatorAction - create pause container
  • TaskBooterAction - boot initial task
  • ContainersBooterAction - boot all containers
  • MetricsAdderAction - add metrics
  • EntitySaverAction - save final sandbox entity

Action Factories:

  • Create factories for each action type
  • Inject SandboxController dependencies at boot
  • Register factories in SagaRegistry

Definition Registration:

  • Register "create-sandbox" definition with DAG structure
  • Define dependencies between actions

Entry Point:

  • Add CreateSandboxSaga() method alongside existing createSandbox()
  • Feature flag to control which path is used
  • Pass sandbox ID and metadata via InitialInputs

Testing:

  • Integration tests with MockStore
  • Success path verification
  • Failure injection at each step, verify compensation
  • Crash recovery simulation
  • Verify no regressions vs existing implementation

Observability:

  • Logging for saga execution
  • Metrics on saga duration and success rate

Why One Issue

This is a complete end-to-end saga that proves the framework works in production. Splitting it would leave partial, non-functional code.

Dependencies

Requires: MIR-439 (Saga Framework Foundation)

Reference

RFD 0035: Saga Pattern for Distributed Operations Phase 2 from Migration Strategy