Skip to main content

reconcile_replicas

Function reconcile_replicas 

Source
pub(crate) fn reconcile_replicas(
    state: &ClusterState,
    contributions: &[(&'static str, Vec<DesiredReplica>)],
) -> Vec<Decision>
Expand description

The pure multiset union/diff kernel for one cluster: given each strategy’s desired replica slots and the actual replicas, match slots to replicas by shape and emit the creates and drops that close the gap.

Semantics:

  • The desired set is the multiset union of every strategy’s slots: a given shape is desired max over strategies (not the sum), since a replica of that shape satisfies every strategy that wants one. This is what makes a replica survive iff some strategy desires its shape.
  • For each shape, if actual count < desired count we create the difference; if actual count > desired count we drop the difference, picking specific excess replicas. A replica of a shape no strategy desires is dropped.
  • Creates carry the names of the strategies that desired the shape. Drops carry no attribution, because a drop happens exactly when no strategy desires the replica.