gc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 9 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

This section is empty.

Types

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
	Interval time.Duration
	Logger   *slog.Logger
}

Deps configures a Collector. Store is 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.

Jump to

Keyboard shortcuts

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