Skip to main content

Module pdb

Module pdb 

Source
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 (reuses crate::selector::matches_labels + crate::selector::selector_match_labels — the same selector logic the EndpointsController uses; no fork).
  • expectedPods = matched pods.
  • currentHealthy = matched pods that are Ready (status.conditions Ready=True).
  • desiredHealthy is resolved from the minAvailable / maxUnavailable IntOrString (mutually exclusive; int → that number, "N%" → ceil(N/100 × expectedPods)):
    • minAvailable set ⇒ desiredHealthy = resolve(minAvailable).
    • maxUnavailable set ⇒ desiredHealthy = expectedPods − resolve(maxUnavailable).
    • neither set ⇒ default minAvailable semantics (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.
PodDisruptionBudgetController
PodDisruptionBudget controller.

Constants§

DISRUPTED_POD_TTL
How long an eviction’s status.disruptedPods entry keeps its pod out of the healthy count — upstream’s DeletionTimeout.

Functions§

counts_healthy
Whether pod counts as healthy for a budget: Ready, not being deleted, and not named in the budget’s status.disruptedPods within the last DISRUPTED_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 pdb budgets pod: 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.