Skip to main content

Module namespace

Module namespace 

Source
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:

  1. list every namespaced object in the Terminating namespace (across the typed served namespaced kinds — RESOURCE_CATALOG rows with namespaced == true) and DELETE each;
  2. set status.phase = "Terminating" so kubectl shows the phase;
  3. once the namespace is EMPTY of namespaced objects, clear the kubernetes finalizer via a typed Patch — which (per the store’s finalizer-release rule) empties metadata.finalizers on 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§

NamespaceController

Functions§

namespaced_kinds
The typed catalog-reflection surface: every served NAMESPACED kind, from RESOURCE_CATALOG where namespaced == true. The cascade iterates this mechanically — adding a namespaced kind to the catalog extends the cascade with no controller edit.