Expand description
NamespaceController — namespace-cascade (Background) deletion.
The Viggy/controllers-not-runbooks realization of Kubernetes’
namespace teardown: deleting a Namespace does NOT synchronously remove
its contents in-request. Instead the namespace goes Terminating (the
finalizer gate in engenho-store::state::apply_delete stamps a
deletionTimestamp because the namespace carries the kubernetes
finalizer) and THIS controller drives the background sweep:
- list every namespaced object in the Terminating namespace
(across the typed served namespaced kinds —
RESOURCE_CATALOGrows withnamespaced == true) and DELETE each; - set
status.phase = "Terminating"so kubectl shows the phase; - once the namespace is EMPTY of namespaced objects, clear the
kubernetesfinalizer via a typedPatch— which (per the store’s finalizer-release rule) emptiesmetadata.finalizerson a deletionTimestamp-bearing object and so the namespace itself is GC-removed.
§Why a raw Controller (not OwnedChildrenReconciler)
Like crate::gc::GcController, the cascade has NO single parent kind
and does a CROSS-KIND sweep — it is “out of family” for the
single-parent owned-children reconciler. It implements the raw
Controller trait directly, modeled on GcController.
§Finalizer-awareness all the way down
Each child delete is a normal ResourceCommand::Delete. If a CHILD
object itself bears finalizers, the store’s gate gives IT the
Terminating treatment (deletionTimestamp set, kept until its
finalizers clear) — so the cascade is finalizer-aware end to end. A
child already Terminating is not deleted again (I3): it waits on its
finalizers, and a second delete is the store’s NoOp. The controller
re-ticks (WatchDriver fallback) until the namespace is actually empty.
§Scope
Cascade covers every namespaced kind served right now: the built-in
RESOURCE_CATALOG rows plus every served version of every stored
CustomResourceDefinition (ServedKinds, the garbage collector’s
RESTMapper), rebuilt each tick.
§Where the kubernetes finalizer lives
The apiserver births a Namespace with kubernetes in spec.finalizers,
as upstream does, and the store holds a deleted Namespace Terminating on
that list (engenho_store::ApplySemantics::V2). A Namespace stored
before then may carry it in metadata.finalizers; both are honoured and
both are cleared.
Structs§
Functions§
- namespaced_
kinds - The typed catalog-reflection surface: every served NAMESPACED kind,
from
RESOURCE_CATALOGwherenamespaced == true. The cascade iterates this mechanically — adding a namespaced kind to the catalog extends the cascade with no controller edit.