Expand description
R19 — PodDisruptionBudget controller.
Tracks per-pod-set disruption budgets. The substrate’s
voluntary-eviction path (the /eviction subresource — a SEPARATE
later brick) consults the budget’s status.disruptionsAllowed
before allowing a voluntary pod delete; this controller maintains
that status (the number it reads) so the gate has live state.
§Reconcile rule
For each policy/v1 PodDisruptionBudget:
- Find pods in the PDB’s namespace matching
spec.selector(reusescrate::selector::matches_labels+crate::selector::selector_match_labels— the same selector logic theEndpointsControlleruses; no fork). expectedPods= matched pods.currentHealthy= matched pods that are Ready (status.conditionsReady=True).desiredHealthyis resolved from theminAvailable/maxUnavailableIntOrString(mutually exclusive; int → that number,"N%"→ceil(N/100 × expectedPods)):minAvailableset ⇒desiredHealthy = resolve(minAvailable).maxUnavailableset ⇒desiredHealthy = expectedPods − resolve(maxUnavailable).- neither set ⇒ default
minAvailablesemantics (desiredHealthy = 0).
disruptionsAllowed = max(0, currentHealthy − desiredHealthy).observedGeneration = metadata.generation.
Decisions stay idempotent — the status patch only fires when one of the five computed numbers changes (no churn on a steady re-tick).
Structs§
- PdbStatus
- The five status numbers a PDB reconcile computes. Carrying them in one typed struct keeps the “compute” step (pure, unit-testable) and the “did anything change?” comparison (idempotency) honest — a new status field can’t be silently dropped from the comparison.
- PodDisruption
Budget Controller PodDisruptionBudgetcontroller.
Constants§
- DISRUPTED_
POD_ TTL - How long an eviction’s
status.disruptedPodsentry keeps its pod out of the healthy count — upstream’sDeletionTimeout.
Functions§
- counts_
healthy - Whether
podcounts as healthy for a budget: Ready, not being deleted, and not named in the budget’sstatus.disruptedPodswithin the lastDISRUPTED_POD_TTL(evicted, not gone yet). Upstream’s disruption controller counts the same way, so a pod an eviction just took is not counted back before it disappears, and a later pod reusing its name is. - pdb_
selects - Whether
pdbbudgetspod: same namespace is the caller’s to ensure; this is the selector test the controller counts with, so the eviction subresource and the controller can never disagree about which pods a budget covers. A PDB with no selector covers nothing.