gc

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

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

func DeleteBucket(ctx context.Context, s store.Store, p BucketPurger, b *v1.Bucket) error

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). 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 New

func New(d Deps) (*Collector, error)

New builds a Collector.

func (*Collector) CollectNamespace

func (c *Collector) CollectNamespace(ctx context.Context, ns v1.NamespaceName) error

CollectNamespace runs one pass over every child kind in ns (empty ns is every namespace). List errors are returned joined. Safe beside Run.

func (*Collector) Run

func (c *Collector) Run(ctx context.Context) error

Run watches every owner kind and collects until ctx ends. It sweeps once after the watches open, then collects the children of each deleted owner, runs requested sweeps and sweeps every interval. It errors only when a start watch cannot open.

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

type Pair struct{ Owner, Child v1.Kind }

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).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL