Node removal ladder

Node removal ladder

How a node is drained, decommissioned, and deleted, one safe step at a time.

The removal ladder takes a node out of service in steps: drain it, check that it leads nothing, decommission it, and only then delete it. A pod is deleted only after its node leads no stream, its ledgers are Indexed, and its retirement is recorded for good. On embedded oxia, the node's copies of the metadata store must also have moved to other nodes. On Kubernetes the controller walks the ladder for every scale-down and every upgrade. On machines, an operator runs the same verbs with nova node drain and nova node decommission.

The ladder's state lives in the cluster resource's status, its roster, and every step can be asked again. A controller that restarts at any step resumes there.

Where it lives

CodeWhat it owns
operator/internal/constellation/ladder.goThe ladder for nodes run as a Deployment, with an external metadata store
operator/internal/constellation/embeddedexit.goThe exit step for embedded oxia's StatefulSets, its drain hold, and the force annotations
operator/internal/constellation/witness.go, reap.goThe witness node, and the retirement of nodes that died without a drain
operator/internal/constellation/reconciler.goPersisting the roster on every exit from a pass
internal/daemon/drain.goThe node's drain
internal/transport/grpc/admin/admin.goDecommission and its guard
internal/coord/decommission.goThe decommission itself: recover, gate, hand off the residue, declare

The verbs a node serves

  • Drain. The node refuses new leaderships, quiesces its auditor, and stops dealing queue ranges. After --drain-session-grace (30 s) it hands its streams to other nodes. A drain does not survive a restart, and nova node drain --stop reverses it until the node begins to exit.
  • The terminate gate. A node is drained when it is draining and leads nothing. Its admin overview reports drained and its leader count, and the gate passes on drained with 0 leaderships.
  • Decommission. It retires a node's identity, its star (named by its StarID), for good:
    1. Guard. Unless forced, a target that is alive must be drained and lead nothing, or the call is refused with FailedPrecondition. A registered target whose admin plane does not answer within 5 seconds is refused the same way. A target absent from the registry passes: it is a corpse.
    2. Recover. For a drained target, it recovers the target's unindexed ledgers directly. The recovery duty would wait on a live star's open head; a drained star never appends again, so it can be recovered now.
    3. Gate. It refuses with ErrStarActive while any ledger of the star is unindexed. Over gRPC this refusal arrives as INTERNAL, carrying that error's text.
    4. Hand off. It arms the star's star-reclaim marker, which deletes the star's ledger records and leftover WAL keys later.
    5. Declare. It writes the durable record. From then on the registry refuses the star and its mint counter refuses new ledgers.
    6. Leave embedded oxia. It asks oxia to remove the star's data server. Until oxia has moved the star's shard copies away, the call answers STILL_DRAINING, and the pod must keep running. nova node decommission --wait asks again for up to 15 minutes.
internal/coord/decommission.go
if len(open) > 0 && order.Drained && d.Recoverer != nil {
	if err := d.Recoverer.RecoverLedgers(ctx, order.Star, open); err != nil {
		return fmt.Errorf("recovering star %v ahead of its decommission: %w", order.Star, err)
	}
	// Recovery is evidence, not permission: the gate re-reads.
	open, err = d.Ledgers.Unindexed(ctx, order.Star)
	// ...
}
if len(open) > 0 {
	return fmt.Errorf("star %v holds %d unindexed ledgers: %w", order.Star, len(open), ErrStarActive)
}

How the controller removes nodes

drain verb held GateOpen drained and leading 0 held DecommissionRefused or Draining decommission answered done pod deleted, entry dropped pod gone or unreachable decommission through a witness Draining Gated Decommissioned Deleted Corpse

Each pass moves at most one node by at most one step. One departure at a time keeps the published load figures honest between decisions.

  1. Pick the node. The controller picks by state. A departure already under way resumes first. Otherwise it takes the last node whose image or template the spec no longer names, which is an upgrade's surplus. Otherwise it takes the last roster entry.
  2. Drain. The controller calls the node's own drain verb. It sends it again every pass, because a restart clears a drain.
  3. Check the gate. The controller reads the node's overview. If the node is not yet drained with 0 leaderships, it holds with GateOpen.
  4. Decommission. It calls the node's decommission verb for the node's own star ID.
  5. Delete. It marks the entry Decommissioned, deletes the pod, and drops the entry. A replacement, if the fleet grows again, gets a new star ID.

Each call has a 10-second budget. A call past its budget counts as a held step, and the next pass asks again. Passes run every 5 seconds while a ladder is in progress.

Through a witness

A node whose pod is gone, or that stands but does not answer, cannot drain. The controller then works through a witness: the first roster entry that is not departing and whose pod is ready. It reads the witness's overview. If the star is absent there, the controller decommissions it through the witness with no drain verified. Its ledgers are then recovered by the recovery duty, under the rule for a dead star. If the star still appears in the overview, the controller holds and waits for its session to lapse. Without a ready witness, it holds with NoWitness, or with Unreachable when the pod stands but does not answer.

The embedded oxia exit

With embedded oxia, nodes run as one StatefulSet per zone, and each pod's volume holds its share of the metadata store. A scale-down removes the highest ordinal of the first set that stands above its share of the spec:

  1. Walk it out. Drain, gate, and decommission, as above. Decommission holds with Draining while oxia moves the star's shard copies, and the message names the replicas left.
  2. Mark its claims. Each of the ordinal's volume claims gets the annotation nova.dev/departed. The mark lands before the shrink, so a pass that dies after it knows this ordinal left.
  3. Shrink the set by one.
  4. Delete the marked claims of ordinals the set no longer has. A set never grows back onto an ordinal whose marked claim still stands, or the new pod would start on the departed star's data.

A drain past 15 minutes is stalled. The controller holds with DrainStalled, raises one Warning event, and never deletes the pod on its own: the shards not yet moved would each run a copy short. NovaOxiaDrainStalled fires at the same point.

A person can override the hold with the annotation nova.dev/force-departure on the cluster resource, set to the departing pod's UID (kubectl get pod <pod> -o jsonpath='{.metadata.uid}'). The force also takes a dead pod out through a witness. It is refused when the departure would leave some shard without a majority of its copies, because another member of that shard is down, unless nova.dev/force-departure-below-quorum names the same UID. An annotation that names any other pod is refused and removed. Each forced departure raises a ForcedDeparture Warning event, and each refusal a ForceRefused one. The controller removes the annotations once the departure they forced is done.

Nodes that die without a drain

A pod that is simply gone is recreated under its own star ID. A corpse is a pod that stands but is not ready while its star is absent from the overview, as seen through a live witness. The controller marks it on the roster and waits for serving.reapAfter (10 minutes by default). After that it asks the decommission verb each pass, and the recovery gate refuses until the fleet has absorbed the loss. At most one star retires per pass. Without a live witness, the controller cannot confirm the absence and does nothing, so a dark fleet never triggers a wave of decommissions.

The roster

The roster is the controller's node list with each node's removal state. The controller writes it on every exit from a pass: a step held, a plan refused, or an error. It also adopts any pod it finds that the roster lacks. A restarted controller therefore resumes from the saved state. Every step is safe to repeat: the drain is sent again, the gate is judged fresh, and decommission converges.

Crash points

Crash afterState left behindWhat the next pass does
The drain callA draining node; the roster says DrainingSends the drain again and judges the gate
Part of decommission's recoverySome ledgers IndexedDecommission resumes each walk from its checkpoint
The star-reclaim marker, before the declarationA marker for a star not yet retiredThe declaration is asked again; the reclaim duty acts only on a retired star
The declaration, before oxia's drain finishesA retired star; the pod still holds shard copiesAsks again; holds Draining until oxia releases the data server
The claims' mark, before the shrinkMarked claims; the set unchangedFinds the mark and shrinks without asking again
The shrink, before the claims' deletionMarked claims of a removed ordinalDeletes them; the set will not grow back meanwhile

Bounds and signals

BoundValue
Ladder pass while a departure runsEvery 5 s
One call on a node's admin plane10 s
The guard's health probe5 s
Drain stall15 minutes
Corpse wait (serving.reapAfter)10 minutes
nova node decommission --waitUp to 15 minutes

The condition DepartureHeld=True names the step that is holding: Unreachable, GateOpen, DecommissionRefused, Draining, DrainStalled, or NoWitness. Its message carries the node's own words, and its transition time says when the departure first held. DepartureHeld=False with reason Advancing means the last step moved. On the node, novad: drain ordered; refusing new leadership, novad: decommission ordered, and novad: star decommissioned mark the edges.

Tests

  • operator/internal/constellation: TestLadderWalksAStarOut, TestLadderHoldsAnOpenGate, TestLadderHoldsARefusedDecommission, TestLadderHoldsACallPastItsDeadline, TestLadderRetiresAVanishedVictimAsACorpse, TestLadderRetiresAnUnreachableAbsentVictimThroughAWitness, TestAnEmbeddedScaleDownShrinksOnlyOnceOxiaDrainedTheStar, TestAnEmbeddedExitThatDiesBeforeTheShrinkResumes, TestTheExitRungMarksThenDeletesTheDepartedOrdinalsClaim, TestAScaleUpWaitsForTheDepartedClaimToGo, TestAStalledDrainHoldsAndNeverDeletesThePod, TestAForceThatWouldBreakAShardsMajorityIsRefused, TestReapNeedsALiveWitness.
  • tlaplus/Membership.tla models drain, decommission, and the ring, with must-fail configurations such as Membership.mustfail-drained.cfg and Membership.mustfail-declare.cfg.

See also

On this page