Documentation
¶
Overview ¶
Package volume keeps the directories Functions own (ADR-0262): one leaf per volume under a root, with a hard size from a Limiter, a booking in one in-process allocator, and a meta file beside each leaf, outside every mount.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCapacity = errors.New("VolumeCapacity") ErrBudget = errors.New("VolumeBudget") ErrNotOwned = errors.New("StoreNotOwned") )
Sentinels the reconciler maps to reasons (ADR-0262 Decisions 5 and 7).
Functions ¶
Types ¶
type ID ¶
type ID struct {
Namespace v1.NamespaceName
Function v1.ObjectName
Name v1.ObjectName
Worker string // "" for a local volume
}
ID names one volume: a Function's local volume, or with Worker set one worker's emptyDir.
type Info ¶
type Info struct {
ID ID
Owner v1.UID // "" ⇒ retained: no Function holds it
SizeBytes int64
Deletion v1.DeletionPolicy
}
Info is a volume as its meta records it.
type Limiter ¶
type Limiter interface {
// Limit sets dir's project id and a hard limit of sizeBytes.
Limit(dir string, project uint32, sizeBytes int64) error
// Enforced reports whether Limit is a kernel limit.
Enforced() bool
}
Limiter gives a leaf its hard size. A Limiter that does not enforce lets the manager measure instead.
type Manager ¶
type Manager interface {
// Book records sizeBytes for id under the allocator's lock, with no leaf; VolumeCapacity or VolumeBudget
// (fault.Conflict) when it does not fit, Invalid when id is booked or stored with another size. Idempotent for
// the same id and size.
Book(ctx context.Context, id ID, sizeBytes int64) error
// Reserve creates or checks id's leaf and sets its quota against its booking (booking it first when it has
// none); StoreNotOwned when the meta names another UID. deletion is recorded for the delete path.
Reserve(ctx context.Context, id ID, owner v1.UID, sizeBytes int64, deletion v1.DeletionPolicy) (hostPath string, err error)
// Adopt stamps owner on a retained local volume; "" retains it; Conflict while another live Function holds it.
Adopt(ctx context.Context, id ID, owner v1.UID) error
Release(ctx context.Context, id ID) error // removes the leaf and frees its booking
Retained(ctx context.Context) ([]ID, error) // local volumes with no owner
List(ctx context.Context) ([]Info, error) // every volume with a leaf, local and emptyDir
Tar(ctx context.Context, id ID) (io.ReadCloser, error) // the backup member stream
Untar(ctx context.Context, id ID, r io.Reader) error // Conflict when the leaf is not empty
Empty(ctx context.Context, id ID) (bool, error) // the leaf holds no entry; NotFound with no leaf
Clear(ctx context.Context, id ID) error // removes the leaf's entries, after a failed load
}
Manager manages the volumes of one daemon (ADR-0262 Contracts).
type Options ¶
type Options struct {
Root string // where the leaves and metas live; created 0700
Limiter Limiter
CapacityBytes int64 // 0 ⇒ no capacity check (funcdctl dev)
// Budget returns a namespace's volume budget in bytes, 0 for none.
Budget func(ctx context.Context, ns v1.NamespaceName) (int64, error)
// Holder returns the UID of the stored Function a volume's path names, or false when none is stored.
Holder func(ctx context.Context, ns v1.NamespaceName, fn v1.ObjectName) (v1.UID, bool, error)
// UID and GID own each leaf (the runtime images run as root, the zero value).
UID, GID int
// BookingTTL drops a booking no Reserve backed (an apply refused after its admission); default 1 minute.
BookingTTL time.Duration
// MeasureInterval paces the measurement of an unenforced Limiter; default 30 s.
MeasureInterval time.Duration
Logger *slog.Logger
Clock func() time.Time
}
Options configure a manager.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package quotafs is the volume Limiter of the containerd runtime (ADR-0262 Decision 3): one preallocated ext4 image with project quotas, loop-mounted at the volume root, and a hard block limit per leaf.
|
Package quotafs is the volume Limiter of the containerd runtime (ADR-0262 Decision 3): one preallocated ext4 image with project quotas, loop-mounted at the volume root, and a hard block limit per leaf. |
Click to show internal directories.
Click to hide internal directories.