Documentation
¶
Overview ¶
Package gc is the owner garbage collector (ADR-0170): it deletes every object whose controller OwnerReference names an owner that no longer exists, or exists under another UID. It runs beside the controller in background mode: a watch on each owner kind collects a deleted owner's children soon after the delete, and a periodic sweep over every child kind catches what a crash or a dropped watch missed.
Index ¶
Constants ¶
const DefaultInterval = 5 * time.Minute
DefaultInterval is the sweep period when Deps.Interval is 0 (config controller.gcSweepInterval).
Variables ¶
This section is empty.
Functions ¶
func DeleteBucket ¶ added in v0.9.0
DeleteBucket purges b's objects, deletes b at its resourceVersion, then purges its prefix again at once unless a Bucket of that name exists again, so an object written in between does not reach a later Bucket of the same name (ADR-0199 Decision 7). A Bucket already gone is purged the same way; a Conflict is returned with its kind.
func InUse ¶ added in v0.9.0
func InUse(ctx context.Context, s store.Store, obj v1.Object, skip func(v1.Object) bool) (v1.ObjectRef, bool, error)
InUse returns the first object in obj's namespace that still uses obj and that skip does not skip (nil skips none), as the deletion protections bind it (ADR-0199 Decision 6): a Function another Function links to (ADR-0064), a KVStore a Function's spec.kv names (ADR-0073), a Bucket a Function's or CatalogService's spec.blob, an EventSource's spec.blob.bucket, a Route's spec.rules[].backend.static.bucket or a Site's spec.bucket.name names (ADR-0080), a ConfigMap a Function's or CatalogService's spec.config names (ADR-0213 Decision 5), a SQLDatabase a Function's spec.sql names (ADR-0236). Nothing uses an object of another kind.
Types ¶
type BucketPurger ¶ added in v0.9.0
type BucketPurger interface {
// Purge deletes every object; it is idempotent.
Purge(ctx context.Context, ns v1.NamespaceName, bucket v1.ObjectName) error
}
BucketPurger deletes every object of a Bucket's substrate prefix (ADR-0199 Decision 7).
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector deletes dead-owned children. Its passes are stateless and may run concurrently.
func (*Collector) CollectNamespace ¶
CollectNamespace runs one pass over every child kind in ns (empty ns is every namespace). List errors are returned joined. Safe beside Run.
type Deps ¶
type Deps struct {
Store store.Store
Purger BucketPurger
Interval time.Duration
Logger *slog.Logger
}
Deps configures a Collector. Store and Purger are required; Interval 0 ⇒ DefaultInterval, < 0 ⇒ fault.Invalid.
type Pair ¶
Pair is an owner kind and a child kind a reconciler stamps with a controller OwnerReference.
func Pairs ¶
func Pairs() []Pair
Pairs is every pair a reconciler stamps. Revision is last: one sweep collects a Function, then its Revisions. The App pairs are one per App section kind (ADR-0199 Decision 7, ADR-0222 Decision 2), users before stores, with (App, ConfigMap) after (App, Bucket) (ADR-0213 Decision 5), then (App, AppRevision) (ADR-0200 Decision 8) and the hook calls of an AppRevision (ADR-0214).