regmaint

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package regmaint keeps the private registry tidy (§5.10): it applies repository lifecycle policies and then runs registry garbage collection, on a schedule or on demand, and logs every run.

Index

Constants

View Source
const (
	OutcomeDeleted = "deleted"
	OutcomeFailed  = "failed"
	OutcomeInUse   = "in-use"
	// OutcomeSkipped: the repository was left alone (Reason says why).
	OutcomeSkipped = "skipped"
	// OutcomeSummary: what the rules did across one repository.
	OutcomeSummary = "summary"
)

Outcomes of an expired image, plus the notes a run records per repository.

View Source
const DefaultRepo = "*"

DefaultRepo names the default policy, applied to every repository that has no policy of its own.

View Source
const TopicRun = "registry.gc"

TopicRun carries a store.GCRun whenever a run starts or finishes.

Variables

View Source
var (
	// ErrBusy means a run is already in progress.
	ErrBusy = errors.New("a registry cleanup is already running")
	// ErrNoRegistry means the registry system task is not running.
	ErrNoRegistry = errors.New("the registry is not running on the controller node")
	// ErrSwitching means the registry is switching storage.
	ErrSwitching = errors.New("the registry is switching storage")
)

Functions

This section is empty.

Types

type ErrInvalid

type ErrInvalid struct{ Err error }

ErrInvalid wraps validation errors.

func (ErrInvalid) Error

func (e ErrInvalid) Error() string

type Expired

type Expired struct {
	Repository string   `json:"repository"`
	Tag        string   `json:"tag"`
	Tags       []string `json:"tags"`
	Digest     string   `json:"digest"`
	SizeBytes  int64    `json:"sizeBytes"`
	Reason     string   `json:"reason"`
	// Outcome is deleted, failed (Error says why) or in-use (the rules
	// selected the image but a service runs or can roll back to it).
	Outcome string `json:"outcome"`
	Error   string `json:"error,omitempty"`
}

Expired is one image a run deleted.

type Manager

type Manager struct {

	// RegistryHosts are the hostnames task definitions may use for the
	// private registry besides "@registry/".
	RegistryHosts func() []string
	// Every is the time between scheduled runs.
	Every time.Duration
	// StorageSize measures the registry's storage (nil = the local volume).
	StorageSize func(ctx context.Context) (int64, error)
	// contains filtered or unexported fields
}

func New

func New(st *store.Store, b *registry.Browser, sys *system.Manager, ex *execrelay.Relay, wl *workload.Manager, bus *events.Bus, log *slog.Logger) *Manager

func (*Manager) Acquire added in v0.1.9

func (m *Manager) Acquire() error

Acquire takes the registry maintenance lock for a storage switch (Phase 19): cleanups and switches never overlap. Release frees it.

func (*Manager) DiskSize added in v0.1.9

func (m *Manager) DiskSize(ctx context.Context) (int64, error)

DiskSize is the size of the registry's local volume.

func (*Manager) Execute added in v0.1.9

func (m *Manager) Execute(ctx context.Context, cmd []string) ([]byte, int, error)

Execute runs a command in the registry container and returns its output.

func (*Manager) GetPolicy

func (m *Manager) GetPolicy(ctx context.Context, repo string) (Policy, error)

func (*Manager) ImageAvailable

func (m *Manager) ImageAvailable(ctx context.Context, image string) (bool, error)

ImageAvailable reports whether a service image can still be pulled: images outside the private registry are assumed to be.

func (*Manager) InvalidateUsage added in v0.3.1

func (m *Manager) InvalidateUsage()

InvalidateUsage drops the kept measurement: images were deleted.

func (*Manager) Preview

func (m *Manager) Preview(ctx context.Context, repo string, rules []registry.Rule) (Preview, error)

Preview evaluates rules against a repository's images without deleting.

func (*Manager) Release added in v0.1.9

func (m *Manager) Release()

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run starts scheduled runs until ctx ends.

func (*Manager) Running

func (m *Manager) Running() bool

Running reports whether a run is in progress.

func (*Manager) SetPolicy

func (m *Manager) SetPolicy(ctx context.Context, repo string, rules []registry.Rule, actor string) (Policy, error)

func (*Manager) SetReadOnly added in v0.1.9

func (m *Manager) SetReadOnly(ctx context.Context, ro bool) error

SetReadOnly switches the registry in or out of read-only maintenance mode and waits until it runs again.

func (*Manager) Start

func (m *Manager) Start(trigger string) (store.GCRun, error)

Start begins a run in the background.

func (*Manager) Usage added in v0.3.1

func (m *Manager) Usage(ctx context.Context, refresh bool) (Usage, error)

Usage walks the registry and measures its storage. Results are kept for a minute, so several dashboards do not repeat the walk; refresh forces one.

func (*Manager) WaitRestarted added in v0.1.9

func (m *Manager) WaitRestarted(ctx context.Context, old string) error

WaitRestarted waits until the registry runs in a container other than old.

type Policy

type Policy struct {
	Repository string          `json:"repository"`
	Rules      []registry.Rule `json:"rules"`
	UpdatedAt  time.Time       `json:"updatedAt"`
}

Policy is a repository's lifecycle policy.

type Preview added in v0.3.1

type Preview struct {
	Images []registry.Decision `json:"images"`
	// Expire counts the images that would be deleted.
	Expire int `json:"expire"`
	// FreesBytes estimates what their deletion frees: layers no kept image
	// shares.
	FreesBytes int64 `json:"freesBytes"`
}

Preview is a dry run of rules against a repository's images.

type Usage added in v0.3.1

type Usage struct {
	registry.Usage
	// StorageBytes is the size of the registry's storage as the machine
	// measures it; nil when it cannot be measured now.
	StorageBytes *int64 `json:"storageBytes"`
	// UnreferencedBytes is what no tag reaches (untagged manifests and
	// orphaned layers) and the next cleanup frees; nil with StorageBytes.
	UnreferencedBytes *int64    `json:"unreferencedBytes"`
	MeasuredAt        time.Time `json:"measuredAt"`
}

Usage is what the registry's storage holds, split by repository.

Jump to

Keyboard shortcuts

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