Node Failure & Recovery
Nodes can disappear while jobs are assigned or actively running, requiring deterministic heartbeats, grace periods, and workload requeuing.
Distributed Job Execution & Application Orchestration Platform
Lightweight distributed job execution and application orchestration platform built in Go, designed for deterministic scheduling, container isolation, and execution-fenced failure recovery.
Core Challenge: Running work across multiple machines introduces critical distributed coordination challenges: node dropouts during execution, worker starvation, stale workers reporting outdated results after recovery, and state desynchronization between desired application state and physical runtime state.
Running work across multiple machines introduces problems that a single-process application does not have:
Distributed state consistency, claim ownership, and failure recovery collapsing into authoritative coordination.
HORIZONTAL SCROLL ON MOBILE ↔RunStack uses a trusted Control Plane as the authoritative source of state, while Agents remain thin execution workers.
Owns authoritative state, node registrations, deterministic scheduling, and application reconciliation loops.
Discovers the host node, maintains heartbeat, polls and claims assigned work, executes tasks, and reports results.
Provides strict process and container lifecycle isolation through Docker or Podman on the host.
Thin agent pull loop: agents poll and claim work over HTTP, keeping the network perimeter outbound-only.
HORIZONTAL SCROLL ON MOBILE ↔Owns authoritative state, node registrations, deterministic scheduling, and application reconciliation loops.
Discovers the host node, maintains heartbeat, polls and claims assigned work, executes tasks, and reports results.
Provides strict process and container lifecycle isolation through Docker or Podman on the host.
RunStack couples an authoritative control plane with lightweight worker agents over HTTP. State, scheduling, and reconciliation remain strictly centralized, while agents manage local execution.
Provides REST endpoints for job admission, app deployment manifests, node registrations, polling, and heartbeat reporting.
Maintains authoritative in-memory state (V1) protected by sync.RWMutex: Node, Job, Application, Deployment, and Instance stores.
Dispatches jobs and instances to healthy online nodes using a sorted node ID ring and a persistent round-robin cursor.
Continuous control loop comparing desired instances from immutable deployments against actual runtime instance status.
Autonomous host daemons that report capabilities, pulse 1000ms heartbeats, claim work atomically, and run tasks locally.
Directly drives Docker or Podman on the host node for strict process isolation, CPU/memory quotas, and exit code extraction.
Unidirectional control plane topology with centralized registries, schedulers, and reconcilers driving thin host agents.
HORIZONTAL SCROLL ON MOBILE ↔Provides REST endpoints for job admission, app deployment manifests, node registrations, polling, and heartbeat reporting.
Maintains authoritative in-memory state (V1) protected by sync.RWMutex: Node, Job, Application, Deployment, and Instance stores.
Dispatches jobs and instances to healthy online nodes using a sorted node ID ring and a persistent round-robin cursor.
Continuous control loop comparing desired instances from immutable deployments against actual runtime instance status.
Autonomous host daemons that report capabilities, pulse 1000ms heartbeats, claim work atomically, and run tasks locally.
Directly drives Docker or Podman on the host node for strict process isolation, CPU/memory quotas, and exit code extraction.
Jobs transition through strict, centrally validated states. The scheduler assigns pending jobs to online nodes, agents atomically claim the execution, and failures evaluate against a deterministic retry budget.
Deterministic job lifecycle: scheduler assignment, atomic agent claim, and bounded retry budget evaluation.
HORIZONTAL SCROLL ON MOBILE ↔A JobID identifies the logical task, while an ExecutionID identifies a specific physical attempt. Separating logical intent from execution identity prevents zombie workers from corrupting cluster state after node recovery.
Physical exactly-once execution is theoretically impossible during network partitions. RunStack guarantees execution-aware result fencing: late results from severed nodes are safely dropped, preserving state correctness.
Node loss triggers recovery and re-assignment under a fresh ExecutionID #2.
HORIZONTAL SCROLL ON MOBILE ↔The Control Plane rejects delayed results from Execution #1 once #2 has been authorized.
HORIZONTAL SCROLL ON MOBILE ↔Four fundamental distributed systems challenges encountered when coordinating uncoordinated compute workers across network boundaries.
Nodes can disappear while jobs are assigned or actively running, requiring deterministic heartbeats, grace periods, and workload requeuing.
A recovered job must strictly reject results from an older execution attempt if a severed worker completes after cluster reassignment.
Claims, results, scheduler operations, and registries must remain strictly consistent under concurrent parallel worker traffic.
Failures must recover automatically without triggering unbounded retry storms or infinite execution loops on faulty workloads.
System guarantees enforced through disciplined concurrency primitives, explicit state guards, and automated verification suites.
Disciplined systems reasoning: Problem → Constraint → Design → Outcome applied across every failure boundary.
A compute node may abruptly disappear while work is assigned or running.
Immediately recovering work risks false-positive failures during transient network drops.
Assigned work returns to the scheduling pool after grace period conditions are satisfied.
Formal resolution mechanics implemented within the Control Plane runtime.
HORIZONTAL SCROLL ON MOBILE ↔A stalled worker can finish an old execution after the Control Plane has recovered the job.
Late execution results must never overwrite fresh results from newly reassigned nodes.
Execution ownership remains explicit; stale ExecutionID results are strictly rejected.
Formal resolution mechanics implemented within the Control Plane runtime.
HORIZONTAL SCROLL ON MOBILE ↔Repeated infrastructure drops or bad commands could trigger infinite retry loops.
Retries must be deterministically finite and observable across cluster state.
Total executions are strictly bounded by MaxRetries + 1, terminating gracefully in FAILED.
Formal resolution mechanics implemented within the Control Plane runtime.
HORIZONTAL SCROLL ON MOBILE ↔Multiple ONLINE nodes need predictable, starvation-free workload assignment.
Scheduling decisions must be reproducible and avoid random uneven distribution.
Node assignment uses sorted node IDs and a persistent round-robin cursor.
Formal resolution mechanics implemented within the Control Plane runtime.
HORIZONTAL SCROLL ON MOBILE ↔Nodes register on startup and maintain an active heartbeat loop with the Control Plane. Missed heartbeats trigger automated offline transition and workload recovery.
Architecture Note: Node capabilities are collected upon registration for cluster visibility, but the V1 scheduler uses deterministic round-robin placement rather than dynamic resource scoring.
Sliding-window node health loop: missed heartbeats transition the node to OFFLINE, triggering recovery.
HORIZONTAL SCROLL ON MOBILE ↔RunStack orchestrates long-running services through declarative specs. An Application defines desired state, a Deployment captures an immutable snapshot, and Instances represent physical containers.
Immutable snapshots decouple application configuration updates from physical running instances.
HORIZONTAL SCROLL ON MOBILE ↔The Reconciler continuously converges physical cluster state toward desired instance count.
HORIZONTAL SCROLL ON MOBILE ↔RunStack strictly separates Instance Status, Health Probes, and Host Node State. Infrastructure drops and application failures are evaluated independently by the Reconciler.
Independent evaluation vectors feeding into the authoritative Reconciler.
HORIZONTAL SCROLL ON MOBILE ↔Node disappearance transitions instances from UNKNOWN to CRASHED, scheduling replacements.
HORIZONTAL SCROLL ON MOBILE ↔Repeated immediate failures pause replacement to protect host nodes from restart storms.
HORIZONTAL SCROLL ON MOBILE ↔Deliberate engineering trade-offs: why each architectural path was chosen, the operational costs accepted, and the delivered outcome.
Concurrency primitives, explicit control over execution, low memory overhead, and single binary deployment across Linux hosts.
More explicit lifecycle and state management required compared to heavy actor framework runtimes.
Clean, portable binaries with microsecond goroutine synchronization and zero runtime dependencies.
Keep initial cluster architecture lightweight, deterministic, and free of external database overhead.
Control plane restart loses runtime state, requiring agent re-registration and job requeueing.
Crystal-clear state machine contracts that established the exact transactional boundaries needed for V2.
Agents do not require inbound listening ports, public IPs, or firewall punching; all connections are outbound.
Execution coordination and dispatch latency are bounded by periodic polling intervals.
Resilient perimeter security where agents safely run across arbitrary private clouds and edge devices.
Separates logical job identity from individual physical execution attempts across nodes.
Demands per-attempt execution tracking, state generation counters, and rigorous fencing validation.
Completely prevents stale worker results from overwriting state after node failure and reassignment.
Provides predictable, starvation-free, deterministic node assignment via a sorted ID ring and persistent cursor.
V1 placement is not dynamic resource-aware and does not balance CPU/RAM utilization.
Deterministic testability and zero starvation across heterogeneous worker nodes.
Move authoritative state toward durable transactional storage with ACID guarantees.
Introduces external database dependency and connection pool lifecycle management.
Durable state, SELECT FOR UPDATE row-level locking, and SQL-level execution fencing for production clusters.
Combined cluster lifecycle linking job state machines to node heartbeat availability. Node disappearance directly feeds into job recovery and rescheduling loops.
State machine transitions evaluated on every polling interval and worker result submission.
HORIZONTAL SCROLL ON MOBILE ↔Heartbeat lapse triggers offline state, re-claiming orphaned jobs back into the scheduler pool.
HORIZONTAL SCROLL ON MOBILE ↔RunStack extends beyond basic process spawning. The agent interfaces with the local container runtime (Docker or Podman) to drive the full container lifecycle, streaming logs, checking health, and feeding telemetry into the Reconciler.
Immutable deployment to host container runtime execution, continuous probing, and active reconciliation.
HORIZONTAL SCROLL ON MOBILE ↔RunStack isolates operator intent from worker execution. The Control Plane acts as the sole security boundary, enforcing ownership validation and rejecting untrusted state mutations.
Strict boundary between cluster operators (deployments, routing, secret references) and worker agents (claims, execution, heartbeat).
Only the node designated by the scheduler can claim and report on an assigned execution attempt.
Every attempt carries an ephemeral ExecutionID token. Stale results from severed or timed-out workers are rejected by the Control Plane.
Secret references are stored securely in the Control Plane and resolved just-in-time into agent container environment injection.
Commands are parsed directly via strings.Fields() into exec.Command arguments, eliminating arbitrary shell injection vulnerabilities.
Guarantees cluster state immutability once a job reaches terminal SUCCEEDED or FAILED status, or when an ExecutionID is superseded.
Unidirectional trust topology isolating administrative actions from worker node execution privileges.
HORIZONTAL SCROLL ON MOBILE ↔Strict boundary between cluster operators (deployments, routing, secret references) and worker agents (claims, execution, heartbeat).
Only the node designated by the scheduler can claim and report on an assigned execution attempt.
Every attempt carries an ephemeral ExecutionID token. Stale results from severed or timed-out workers are rejected by the Control Plane.
Secret references are stored securely in the Control Plane and resolved just-in-time into agent container environment injection.
Commands are parsed directly via strings.Fields() into exec.Command arguments, eliminating arbitrary shell injection vulnerabilities.
Guarantees cluster state immutability once a job reaches terminal SUCCEEDED or FAILED status, or when an ExecutionID is superseded.
Verifiable engineering outcomes built directly into the system architecture, avoiding speculative or ungrounded benchmark claims.
All job state transitions and instance lifecycle phases are strictly controlled centrally.
Strict Attempts <= MaxRetries budget prevents runaway execution storms on failing workloads.
Stale execution results from evicted or lagged workers are deterministically rejected.
ONLINE nodes are sorted by ID and assigned through a persistent round-robin cursor.
Node loss and execution timeouts safely return orphaned work to the active scheduling lifecycle.
Registry state operations are synchronized via sync.RWMutex with race-detector test validation.
Engineering rigor requires documenting what a system does not guarantee. Explicit V1 constraints directly guided the design of the PostgreSQL V2 persistence foundation.
Control Plane restart loses runtime state, requiring worker re-registration.
Agent daemon executes one job at a time to keep local state deterministic.
Capabilities are collected, but V1 placement is round-robin rather than CPU/RAM-weighted.
Fencing prevents stale results, but network partitions can cause duplicate physical container run.
strings.Fields() splits whitespace safely, but quoted arguments with spaces are not supported.
Correctness in distributed systems requires automated enforcement. RunStack standardizes verification through a comprehensive make check pipeline.
Validates all registry sync.RWMutex locks and channel communications under simulated parallel access.
Tests agent SIGINT/SIGTERM cancellation, completing in-flight jobs and unregistering cleanly.
End-to-end execution testing verifying client submission, agent claim, Docker container run, and result receipt.
Verifies database migrations, transactional rollbacks, SELECT FOR UPDATE locks, and SQL fencing.
Every commit validates formatting, static analysis, unit suites, race detection, and binary compilation.
HORIZONTAL SCROLL ON MOBILE ↔Validates all registry sync.RWMutex locks and channel communications under simulated parallel access.
Tests agent SIGINT/SIGTERM cancellation, completing in-flight jobs and unregistering cleanly.
End-to-end execution testing verifying client submission, agent claim, Docker container run, and result receipt.
Verifies database migrations, transactional rollbacks, SELECT FOR UPDATE locks, and SQL fencing.
End-to-end execution pipeline: the lifecycle of a compute workload from HTTP admission, deterministic scheduling, and atomic agent claim through to fenced completion and event history.
Unbroken chain of custody from client intent to authoritative state update and persistent event log.
HORIZONTAL SCROLL ON MOBILE ↔