Merge Phase 26-32 Helm lifecycle, read-only operations, restart persistence, cleanup reliability, and v0.3.4 alpha documentation.
6.2 KiB
Runtime State Machines
Document status: protocol/model reference. It is useful for reading runtime code and protocol boundaries, but it is not the source of truth for current release claims. Use
quickstart-kubernetes.mdandreleases/README.mdfor validated user behavior.
This is a lightweight map for engineers reading the runtime code for the first time. It is descriptive, not a normative protocol specification.
The key idea: seaweed-block is not one giant state machine. It is a group of
smaller loops with explicit ownership boundaries.
Mini-Protocol Model
The runtime should be treated as a cluster of small protocols running at the same time, not as one large protocol layer.
The authority/epoch substrate is shared, but each lifecycle has its own protocol rules:
| Mini-protocol | Owns |
|---|---|
| Authority | identity, epoch, assignment lineage, stale-owner fencing |
| Replication | peer probing, degraded/catching-up/healthy state, rebuild eligibility |
| Frontend iSCSI | login/session, ALUA metadata, SCSI read/write/sync behavior |
| Frontend NVMe | Connect, Identify, ANA, controller/namespace identity |
| CSI lifecycle | provision, publish, stage, mount, unstage, delete |
| TestOps | run status, provenance, cleanup, artifact bundle validation |
Design rule:
do not create a grand protocol layer until two mini-protocols truly share a
state transition; instead, make each mini-protocol explicit, observable, and
test-pinned.
For any lifecycle that can affect safety or operator trust, the expected shape is:
- explicit state names,
- narrow transition points,
- structured status or artifact evidence,
- component tests for illegal transitions,
- runner-native gates for OS/Kubernetes/kernel behavior.
This keeps protocol-specific semantics out of the storage engine while still preventing hidden state machines from growing inside scattered conditionals and log-only assertions.
System Map
flowchart TB
K8S[Kubernetes PVC / Pod]
CSI[blockcsi]
BM[blockmaster]
LIFE[lifecycle stores]
AUTH[authority publisher]
LAUNCH[launcher]
BV[blockvolume]
ISCSI[iSCSI frontend]
WAL[WAL-backed storage]
REC[recovery / replication]
K8S --> CSI
CSI --> BM
BM --> LIFE
BM --> AUTH
BM --> LAUNCH
LAUNCH --> BV
AUTH --> BV
BV --> ISCSI
ISCSI --> WAL
BV --> REC
REC --> WAL
Reading order:
- Kubernetes asks for a volume.
- CSI calls
blockmaster. blockmasterrecords desired state and publishes authority through the authority module.- launcher materializes
blockvolumereplicas. blockvolumeexposes iSCSI and owns the data path.- recovery/replication feed lagging peers without redefining authority.
Control Plane Loop
stateDiagram-v2
[*] --> DesiredVolume : CreateVolume
DesiredVolume --> PlacementIntent : planner
PlacementIntent --> VerifiedPlacement : observation matches intent
VerifiedPlacement --> AssignmentAsk : bridge request
AssignmentAsk --> AssignmentPublished : authority publisher
AssignmentPublished --> RuntimeManifest : launcher
RuntimeManifest --> ReplicaObserved : blockvolume heartbeat
Main owners:
| State | Owner |
|---|---|
| Desired volume | core/lifecycle |
| Placement intent | core/lifecycle planner/reconciler |
| Verified placement | core/host/master + lifecycle observation store |
| Assignment | core/authority |
| Runtime manifest | core/launcher |
| Replica observation | cmd/blockvolume heartbeat to cmd/blockmaster |
Important boundary:
verified placement != assignment
assignment != data continuity proof
Data Plane Loop
flowchart LR
POD[Pod filesystem write]
DEV[Linux block device]
SCSI[iSCSI session]
FRONT[blockvolume frontend]
BACK[backend Write]
SYNC[Sync / durable boundary]
WAL[WAL]
EXT[extent/checkpoint work]
POD --> DEV --> SCSI --> FRONT --> BACK --> WAL
FRONT --> SYNC --> WAL
WAL --> EXT
The current alpha path is iSCSI-first. NVMe-oF should plug in later as another frontend, not as a different storage truth model.
Recovery / Replication Loop
stateDiagram-v2
[*] --> PeerHealthy
PeerHealthy --> PeerLagging : missed sync / ship failure / probe evidence
PeerLagging --> CatchingUp : WAL window available
PeerLagging --> Rebuilding : WAL window not enough
CatchingUp --> PeerReady : base not needed and witness closes
Rebuilding --> PeerReady : base complete and witness closes
PeerReady --> PeerHealthy : authority / policy admits it
CatchingUp --> PeerLagging : session fails
Rebuilding --> PeerLagging : session fails
Data-plane rule:
one peer, one WAL-feeding decision owner
Recovery may send base data and WAL data through different internal mechanisms, but the decision about what WAL to feed next must be single-owner and monotonic per peer.
Frontend Eligibility Loop
flowchart TD
ASSIGN[authority assignment]
LOCAL[local engine projection]
SUPER[supersede probe]
VIEW[frontend projection]
IO{allow IO?}
ASSIGN --> SUPER
LOCAL --> VIEW
SUPER --> VIEW
VIEW --> IO
IO -->|healthy| OPEN[open/read/write]
IO -->|stale or superseded| CLOSED[fail closed]
This is why core/host/volume/projection_bridge.go exists. A local engine can
still look healthy while another replica has become authoritative. The frontend
must fail closed in that case.
CSI Node Flow
sequenceDiagram
participant K as kubelet
participant C as blockcsi
participant M as blockmaster
participant V as blockvolume
participant OS as Linux iSCSI/mount
K->>C: ControllerPublishVolume
C->>M: lookup publish target
M-->>C: iSCSI address + IQN
K->>C: NodeStageVolume
C->>OS: iscsiadm discovery/login
C->>OS: mkfs/mount staging path
K->>C: NodePublishVolume
C->>OS: bind mount to pod target
OS->>V: SCSI READ/WRITE/SYNC
Current alpha tests verify this path with a checksum-writing pod.
What Is Still Not Automated
- durable Kubernetes storage roots beyond alpha smoke paths
- multi-node scheduling and topology constraints
- failover while a pod remains mounted
- RF=3 production policy and quorum behavior
- operator-grade runtime reconciliation
- NVMe-oF frontend integration