Documentation
¶
Overview ¶
Package ocicachegc performs mark-and-sweep garbage collection of the shared OCI cache at data_dir/system/oci-cache.
The cache stores content-addressed blobs under blobs/sha256/ and an index.json that references one or more manifests. Blobs are written whenever an image is pulled or pushed and are never removed by the normal code paths, so without a GC the cache grows unbounded.
The collector walks index.json and every manifest (or manifest index) reachable from it to build the set of "live" blob digests, then deletes any blob that is not live. Blobs whose mtime is within MinBlobAge are always kept; this is the grace period used to avoid racing with concurrent pulls, which write layer blobs before updating index.json.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector garbage-collects the shared OCI cache.
func NewCollector ¶
func NewCollector(p *paths.Paths, interval, minBlobAge time.Duration, roots RootsProvider, logger *slog.Logger, meter metric.Meter, tracer trace.Tracer) (*Collector, error)
NewCollector creates a collector. minBlobAge is the minimum age a blob must have before it becomes eligible for deletion; it protects blobs that are currently being written by a concurrent pull or push. roots may be nil; when non-nil it is consulted on every sweep for additional manifest digests to mark live.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the OTel instruments for the OCI cache collector.
type RootsProvider ¶
type RootsProvider interface {
LiveCacheManifestDigests() []string
}
RootsProvider returns extra manifest digests (in "sha256:<hex>" form) that should be treated as live alongside everything reachable from index.json. Used for blobs the registry tracks in memory but does not root in the OCI layout (e.g. BuildKit cache exports under cache/*).