image

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Keep is the minimum amount of the most recent images that we want to keep
	// in the underlying registry, per repository, at all times. This number must
	// be smaller than the amount of images that we fetch in Handler.search.
	Keep = 10

	// Drop is the maximum amount of older images that we want to cleanup at once,
	// while respecting the minimum amount of images to keep at all times.
	Drop = 5
)
View Source
const (
	// Sha represents the set of prefixes matching image tags in the form of
	// hexadecimal commit hashes, e.g. 1cd6...6863.
	Sha prefix = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f"

	// Tag represents the prefix matching image tags in the form of semver
	// versioned release tags, e.g. v0.2.2.
	Tag prefix = "v"
)
View Source
const (
	Alloy      repository = "alloy"
	Kayron     repository = "kayron"
	Server     repository = "server"
	Specta     repository = "specta"
	SplitsLite repository = "splits-lite"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Aws aws.Config
	Env envvar.Env
	Log logger.Interface
	Pre prefix
	Rep repository
}

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler implements handler.Cooler as a cleanup job for container images. A single handler is responsible for cleaning up a single specific combination of container repository and image tag prefixes, e.g. kayron:v*.

func New

func New(c Config) *Handler

func (*Handler) Active added in v0.4.0

func (h *Handler) Active() bool

Active defines this worker handler to always be executed.

func (*Handler) Cooler

func (h *Handler) Cooler() time.Duration

Cooler is configured to return a dynamically adjusted wait duration for this worker handler to sleep before running again. The introduced jitter has the purpose of spreading out the same type of work across time, so that we ease the load on our dependency APIs, here ECR, and effectively try to prevent rate limits. E.g. a jitter of 1% applied to 1h results in execution variation of +-36s.

func (*Handler) Ensure

func (h *Handler) Ensure() error

Ensure implements the following algorithm to manage registry bloat.

K    threshold amount of tagged images to keep
D    threshold amount of tagged images to drop

fetch e.g. 100 tagged images

create a list with tag prefixes, e.g. sha or tag

if <= K, break
sort by date, oldest first
create list of up to D items, never going beyond K
for each D item
    fetch digests

batch delete collected digests

Jump to

Keyboard shortcuts

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