node

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package node implements the language-independent node execution contract.

Index

Constants

View Source
const BindingsAnnotation = "brewlet.sh/runtime-bindings"
View Source
const RevocationsAnnotation = "brewlet.sh/runtime-revocations"

Variables

This section is empty.

Functions

func AcquireCacheGuard

func AcquireCacheGuard(ctx context.Context, root string, exclusive bool) (io.Closer, error)

func CheckFileCapabilities

func CheckFileCapabilities(path string) error

func CheckProcess

func CheckProcess(p *specs.Process) error

func InRoot

func InRoot(root, name string) (string, error)

InRoot resolves container-absolute symlinks against root, never the host /.

func MergeProcess

func MergeProcess(p *specs.Process, m Metadata) error

MergeProcess preserves CRI argv/cwd and applies only the runtime environment precedence, synthesized HOME, and mandatory non-root restrictions.

func RewriteExec

func RewriteExec(p *specs.Process, state InitialState) error

RewriteExec deliberately ignores CRI's independently synthesized environment and credentials; the durable initial state is the execution authority.

func ValidateFilesystem

func ValidateFilesystem(spec *specs.Spec, metadata Metadata, root string) error

func ValidateID

func ValidateID(id string) error

func ValidateMountDestinations

func ValidateMountDestinations(destinations []string) error

func ValidateRoot

func ValidateRoot(root string, m *Metadata) error

func ValidateVolumeMountPaths

func ValidateVolumeMountPaths(paths []string) error

Mount locations are administrator-owned data/configuration zones, not runtime discovery. Keeping them immutable within an inventory epoch binds the policy to every installed generation and lease.

func ValidateWorkloadMount

func ValidateWorkloadMount(destination string, readOnly bool, allowed []string) error

Types

type ApplicationIdentity

type ApplicationIdentity struct {
	Reference      string           `json:"reference"`
	RootDigest     string           `json:"rootDigest"`
	ManifestDigest string           `json:"manifestDigest"`
	ConfigDigest   string           `json:"configDigest"`
	Platform       ocispec.Platform `json:"platform"`
}

func (ApplicationIdentity) Validate

func (a ApplicationIdentity) Validate() error

type Authorization

type Authorization struct {
	ID                string    `json:"id"`
	InventoryUID      string    `json:"inventoryUID"`
	Generation        int64     `json:"generation"`
	Digest            string    `json:"digest"`
	ProfileUID        string    `json:"profileUID"`
	ProfileGeneration int64     `json:"profileGeneration"`
	ExpiresAt         time.Time `json:"expiresAt"`
	Revoked           bool      `json:"revoked"`
	Install           string    `json:"install"`
	State             string    `json:"state"`
}

type Barrier

type Barrier struct {
	ID           string `json:"id"`
	InventoryUID string `json:"inventoryUID"`
	Generation   int64  `json:"generation"`
}

func ParseBarrier

func ParseBarrier(raw, id string) (*Barrier, error)

type BindingObservation

type BindingObservation struct {
	NodeUID           string           `json:"nodeUID"`
	ProfileUID        string           `json:"profileUID"`
	ProfileGeneration int64            `json:"profileGeneration"`
	ObservedAt        time.Time        `json:"observedAt"`
	Complete          bool             `json:"complete"`
	Bindings          []RuntimeBinding `json:"bindings"`
}

type Error

type Error struct{ Reason, Detail string }

func (*Error) Error

func (e *Error) Error() string

type Evidence

type Evidence interface {
	Gone(context.Context, Lease) (bool, error)
}

Evidence must establish absence of tasks, execs AND mounts, including other mount namespaces. An error or incomplete evidence always retains the lease.

type EvidenceRequest

type EvidenceRequest struct {
	AllRuntime bool   `json:"allRuntime"`
	Lease      Lease  `json:"lease"`
	Path       string `json:"path,omitempty"`
}

type EvidenceResponse

type EvidenceResponse struct {
	Gone  bool   `json:"gone"`
	Error string `json:"error,omitempty"`
}

type InitialState

type InitialState struct {
	Application  ApplicationIdentity `json:"application"`
	Lease        Lease               `json:"lease"`
	Process      specs.Process       `json:"process"`
	LayerRoots   []string            `json:"layerRoots,omitempty"`
	ContentRoots []string            `json:"contentRoots,omitempty"`
}

type Lease

type Lease struct {
	TaskMounts *TaskMounts `json:"taskMounts,omitempty"`
	TaskID     string      `json:"taskID"`
	Namespace  string      `json:"namespace"`
	Metadata   Metadata    `json:"runtime"`
	AcquiredAt time.Time   `json:"acquiredAt"`
}

type LinuxEvidence

type LinuxEvidence struct {
	Client      *client.Client
	Proc        string
	RuntimeRoot string
}

LinuxEvidence requires a complete host procfs. Containerized hosts are not silently treated as initial host PID/user namespaces.

func (LinuxEvidence) Gone

func (e LinuxEvidence) Gone(ctx context.Context, l Lease) (bool, error)

func (LinuxEvidence) MountsGone

func (e LinuxEvidence) MountsGone(ctx context.Context, root string) (bool, error)

func (LinuxEvidence) RuntimeGone

func (e LinuxEvidence) RuntimeGone(ctx context.Context) (bool, error)

type Metadata

type Metadata struct {
	ID               string            `json:"id"`
	InventoryUID     string            `json:"inventoryUID"`
	Generation       int64             `json:"generation"`
	SourceDigest     string            `json:"sourceDigest"`
	ManifestDigest   string            `json:"manifestDigest"`
	Platform         ocispec.Platform  `json:"platform"`
	Env              []string          `json:"env"`
	UID              uint32            `json:"uid"`
	GID              uint32            `json:"gid"`
	VolumeMountPaths []string          `json:"volumeMountPaths,omitempty"`
	Home             string            `json:"home"`
	Homes            map[uint32]string `json:"homes"`
	ValidatedAt      time.Time         `json:"validatedAt"`
}

func (Metadata) Validate

func (m Metadata) Validate() error

type MountEvidence

type MountEvidence interface {
	MountsGone(context.Context, string) (bool, error)
}

type RevocationReceipt

type RevocationReceipt struct {
	InventoryUID           string    `json:"inventoryUID"`
	Generation             int64     `json:"generation"`
	Digest                 string    `json:"digest"`
	ProfileUID             string    `json:"profileUID"`
	ProfileGeneration      int64     `json:"profileGeneration"`
	NodeUID                string    `json:"nodeUID"`
	RevokedAt              time.Time `json:"revokedAt"`
	AuthorizationExpiresAt time.Time `json:"authorizationExpiresAt"`
	RootsCleaned           bool      `json:"rootsCleaned"`
}

type RuntimeBinding

type RuntimeBinding struct {
	Application         *ApplicationIdentity `json:"application,omitempty"`
	ContainerID         string               `json:"containerID"`
	ContainerdNamespace string               `json:"containerdNamespace"`
	PodUID              string               `json:"podUID"`
	PodName             string               `json:"podName"`
	PodNamespace        string               `json:"podNamespace"`
	ContainerName       string               `json:"containerName"`
	ID                  string               `json:"id"`
	InventoryUID        string               `json:"inventoryUID"`
	Generation          int64                `json:"generation"`
	Digest              string               `json:"digest"`
	State               string               `json:"state"`
}

type Store

type Store struct {
	Root string
	// contains filtered or unexported fields
}

func NewStore

func NewStore(root string) *Store

func (*Store) AcquireTaskGuard

func (s *Store) AcquireTaskGuard(ctx context.Context, task string) (io.Closer, error)

AcquireTaskGuard excludes recovery while Create can still publish mounts or delegate a task. The lock is outside .tasks so removing a lease cannot split it. Fixed stripes bound persistent lock files; a collision only delays a caller.

func (*Store) AcquireWriter

func (s *Store) AcquireWriter(ctx context.Context) (io.Closer, error)

func (*Store) Authorizations

func (s *Store) Authorizations() ([]Authorization, error)

func (*Store) Check

func (s *Store) Check() error

func (*Store) Collect

func (s *Store) Collect(ctx context.Context, id string, grace time.Duration, evidence Evidence, fence func(context.Context) error) error

Collect is deliberately conservative: every durable lease survives restart, and complete cross-namespace task/mount evidence is mandatory even when the lease directory is empty. Unknown or malformed records prevent deletion.

func (*Store) Current

func (s *Store) Current(ctx context.Context, id string) (Metadata, string, error)

Current reads installed metadata without acquiring a task lease. It is used only by the fenced provisioner, not as an alternate Create authority.

func (*Store) IdleUninstall

func (s *Store) IdleUninstall(ctx context.Context, id string, ttl time.Duration, evidence Evidence, fence func(context.Context) error) (bool, error)

func (*Store) Initialize

func (s *Store) Initialize() error

func (*Store) Leases

func (s *Store) Leases() ([]Lease, error)

func (*Store) LoadInitial

func (s *Store) LoadInitial(task string) (InitialState, error)

func (*Store) Publish

func (s *Store) Publish(ctx context.Context, staging string, m Metadata, fence func(context.Context) error) error

Publish installs an already extracted, validated staging directory containing rootfs. The caller must hold the exclusive provisioner writer lock and must perform its fresh cluster fence immediately before this call.

func (*Store) Recover

func (s *Store) Recover(ctx context.Context, evidence Evidence) error

Recover reconciles durable leases rather than resetting reference counts at shim/provisioner restart. Uncertainty is an error, never permission to collect.

func (*Store) Release

func (s *Store) Release(ctx context.Context, task string, evidence Evidence) error

func (*Store) RemoveRequest

func (s *Store) RemoveRequest(id string) error

func (*Store) Requests

func (s *Store) Requests() ([]string, error)

func (*Store) Resolve

func (s *Store) Resolve(ctx context.Context, id, namespace, task string, barrier *Barrier, wait time.Duration) (Lease, string, error)

Resolve leases current under the same cross-process lock as publication and collection. Only an uninstalled OnDemand entry creates an empty request.

func (*Store) ResolveTask

func (s *Store) ResolveTask(ctx context.Context, id, namespace, task string, barrier *Barrier, wait time.Duration, mounts TaskMounts) (Lease, string, error)

func (*Store) Retire

func (s *Store) Retire(ctx context.Context, id, profile string, evidence Evidence, fence func(context.Context) error) error

Retire removes only this profile's revoked inventory, and only after complete task/exec/mount evidence. It never treats an absent current pointer as proof that the runtime has no consumers.

func (*Store) RetireRevoked

func (s *Store) RetireRevoked(ctx context.Context, id, profile string, evidence Evidence, fence func(context.Context) error) error

RetireRevoked keeps the authorization tombstone so new starts still report RuntimeImageRevoked after the approved resource's roots have drained.

func (*Store) Revoke

func (s *Store) Revoke(ctx context.Context, id, profile string) error

func (*Store) SaveInitial

func (s *Store) SaveInitial(state InitialState) error

func (*Store) ValidateLease

func (s *Store) ValidateLease(ctx context.Context, l Lease) error

func (*Store) WriteAuthorization

func (s *Store) WriteAuthorization(ctx context.Context, a Authorization) error

type TaskMounts

type TaskMounts struct {
	Bundle string `json:"bundle"`
	Upper  string `json:"upper"`
	Work   string `json:"work"`
}

TaskMounts records protected containerd mount provenance before a lease can outlive Create. Shared runtime/cache lowers cannot identify a particular task.

func (TaskMounts) Validate

func (m TaskMounts) Validate(namespace, task string) error

Jump to

Keyboard shortcuts

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