fiberd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package fiberd is fiberd as a library: the flags, the wiring of verifier, runtime, ledger, pressure ladder, admin socket and RPC server, and the fixed startup order (epoch++ -> reconcile -> open RPC). cmd/fiberd is this package plus the home its -home flag picks, standalone or kubernetes. Control planes are separate projects that drive that binary. Nothing here knows which home it runs under beyond the home.Home interface and the optional interfaces below.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(c *Config, newHome HomeFactory) error

Run is fiberd. It returns when the RPC server stops, on SIGINT or SIGTERM. With -drain-timeout set, a SIGTERM drains first, for up to that long.

func RunContext

func RunContext(ctx context.Context, c *Config, newHome HomeFactory) error

RunContext is Run that also stops when ctx ends. A binary that owns its process's lifetime, and a test, stop fiberd through ctx.

func Standalone

func Standalone(c *Config, jwks *grant.Cache) (home.Home, error)

Standalone is the factory cmd/fiberd uses.

Types

type API

type API struct {
	Listen string // -listen
	HTTP   string // -http
	TLS    TLS
}

API is where fiberd serves and how callers prove who they are.

type Audit

type Audit struct{ Key string } // -audit-key

Audit is the audit spool's signing key.

type Cloudhv

type Cloudhv struct {
	VMM         string // -cloudhv-vmm
	Kernel      string // -cloudhv-kernel
	Rootfs      string // -cloudhv-rootfs
	MemoryMiB   uint64 // -cloudhv-memory-mib
	RestoreMode string // -cloudhv-restore-mode
}

Cloudhv is what the cloudhv backend needs, the VMM and the guest's images that hack/cloudhv/build.sh makes.

type Config

type Config struct {
	Node     Node
	API      API
	Trust    Trust
	Runtime  Runtime
	Endpoint Endpoint
	Handoff  Handoff
	Registry Registry
	Audit    Audit
	// Timing paces the loops. It is not a flag in a release build. Tests
	// and embedding binaries set it, and the testhooks build binds flags
	// on it.
	Timing Timing
	// Ready, when set, is told the bound addresses once every listener
	// is open. A binary or a test that listens on ":0" learns its ports
	// from it. http and handoff are nil when off.
	Ready func(grpc, http, handoff net.Addr)
	// contains filtered or unexported fields
}

Config is every flag fiberd takes, grouped by concern. Bind registers them.

func (*Config) AdminSocket

func (c *Config) AdminSocket() string

AdminSocket is the admin unix socket, <state>/private/admin.sock.

func (*Config) Bind

func (c *Config) Bind(fs *flag.FlagSet)

Bind registers fiberd's flags on fs. A binary adds its own (a home's) beside them.

func (*Config) Family

func (c *Config) Family() (endpoint.Family, error)

Family is the parsed -endpoint-family.

func (*Config) Healthz

func (c *Config) Healthz(ctx context.Context) error

Healthz asks the admin socket for /healthz. It returns nil on a 200 and otherwise an error with the status and the body, as when the audit spool is poisoned. A liveness probe gates on it, since a 503 here means fiberd needs a restart.

func (*Config) LoadDeltaKeys

func (c *Config) LoadDeltaKeys() (artifact.Keys, error)

LoadDeltaKeys reads -delta-key, -delta-trust and -delta-seal-key. A missing key is generated under -state on first use, and no other home trusts or opens with it until it is shared. Without a delta registry nothing is signed, and the seal key is read only when -delta-seal-key names one, since it also opens the author images of templates a home pulls with -registry.

func (*Config) NarrowCaps

func (c *Config) NarrowCaps() error

NarrowCaps re-executes fiberd with only what its runtime needs in its capability bounding set, unless -all-caps.

func (*Config) PrepareMounts

func (c *Config) PrepareMounts() error

PrepareMounts makes the cgroup mount and the CRIU sysctls writable where a container left them read-only, for every runtime but the stub, which touches neither. A binary calls it before NarrowCaps. The remount needs CAP_SYS_ADMIN, which a narrowed set may lack, and mounts survive the re-exec. It is a no-op when the mounts are already writable. Sysctls that stayed read-only are a warning, since fibers still get the warm tier without them. Anything else keeps fiberd from starting.

func (*Config) PrivateDir

func (c *Config) PrivateDir() string

PrivateDir is where fiberd keeps what no fiber may read, such as its keys, ledger snapshot, deny-list, epoch, audit spool and admin socket. It is <state>/private, mode 0700, hidden from every fiber with its own mount namespace. Fibers run as fiberd's uid, so file modes alone would not stop them. Templates and deltas stay directly under -state, where fibers and CRIU need them.

func (*Config) Readyz

func (c *Config) Readyz(ctx context.Context) error

Readyz asks the admin socket for /readyz. It answers like Healthz, and also returns an error while fiberd drains, when /readyz answers 503 with "draining": true. A readiness probe gates on it, so traffic stops before the fibers park.

func (*Config) WorkspaceDir

func (c *Config) WorkspaceDir() string

WorkspaceDir is where fibers' workspaces live, -workspace-dir or <state>/workspaces.

type DeltaKeys

type DeltaKeys struct{ Sign, Trust, Seal string } // -delta-key, -delta-trust, -delta-seal-key

DeltaKeys sign, trust and seal published deltas.

type Endpoint

type Endpoint struct{ Family, Host string } // -endpoint-family, -endpoint-host

Endpoint is the address family fibers are served on.

type EndpointHoster

type EndpointHoster interface{ EndpointHost() string }

EndpointHoster knows the one address its fibers share (a Pod IP, a node address); it fills -endpoint-host when that is empty.

type Engine

type Engine struct {
	Command   string // -engine
	UID       uint   // -engine-uid
	MemoryMax uint64 // -engine-memory-max
}

Engine is the device engine fiberd starts for each grant with a device budget. The host runtime's backends share it.

type Gvisor

type Gvisor struct {
	Rootfs          string // -gvisor-rootfs
	TemplatesOnDisk bool   // -gvisor-templates-on-disk
}

Gvisor, Runc and Hyperlight are what only that backend needs.

type Handoff

type Handoff struct{ Listen, Key string } // -handoff-listen, -handoff-key

Handoff is the TLS listener for HANDOFF-mode grants.

type Helpers

type Helpers struct{ CRIU, Runsc string }

Helpers name the criu and runsc binaries. Empty finds each in pkg/sys/helper's fixed directories. No flag sets them, so a test or a program embedding fiberd names its own.

type HomeFactory

type HomeFactory func(c *Config, jwks *grant.Cache) (home.Home, error)

HomeFactory builds the home once the key cache exists. jwks is nil unless -verifier=jwks. The standalone home polls it for liveness.

type Hyperlight

type Hyperlight struct{ Helper, Guest string } // -hyperlight-helper, -hyperlight-guest

Gvisor, Runc and Hyperlight are what only that backend needs.

type Node

type Node struct {
	ID         string        // -node-id
	StateDir   string        // -state
	CgroupRoot string        // -cgroup-root
	GrantsDir  string        // -grants-dir
	StaleTTL   time.Duration // -stale-ttl
	Devices    []string      // -devices
	AllCaps    bool          // -all-caps
	// DrainTimeout is how long a SIGTERM may spend parking named sessions
	// and ending anonymous fibers before fiberd stops. Zero, the default,
	// stops at once, so the drain is opt-in.
	DrainTimeout time.Duration // -drain-timeout
}

Node is this home's identity and what it owns on the host.

type OwnGranter

type OwnGranter interface{ OwnGrant() ([]byte, bool) }

OwnGranter holds a grant of its own (the Pod's grant file). Clone admits that token on the home's UID, never the one presented.

type Registry

type Registry struct {
	Templates string // -registry
	Deltas    string // -delta-registry
	Keys      DeltaKeys
}

Registry is where templates come from and where deltas go. A repository starting with http:// is reached over plain HTTP.

type Runc

type Runc struct{ Rootfs, UsernsPool string } // -runc-rootfs, -userns-pool

Gvisor, Runc and Hyperlight are what only that backend needs.

type Runtime

type Runtime struct {
	Name         string            // -runtime
	StubTier     string            // -runtime-tier
	Templates    map[string]string // -template
	Parity       string            // -parity
	GrantCeiling uint64            // -grant-ceiling
	FiberHide    []string          // -fiber-hide
	WorkspaceDir string            // -workspace-dir
	Engine       Engine
	Gvisor       Gvisor
	Runc         Runc
	Hyperlight   Hyperlight
	Cloudhv      Cloudhv
	Helpers      Helpers
}

Runtime picks the backend and what every backend shares.

type ScopeLoser

type ScopeLoser interface {
	OnScopeLost(func(ctx context.Context, reason string))
}

ScopeLoser can lose its scope while running and wants to say so; Run wires the callback to fiberd's epoch bump.

type SelfAdmitter

type SelfAdmitter interface{ SelfAdmitUID() string }

SelfAdmitter knows the one grant UID it may self-admit on Clone (a Pod UID). An empty answer admits any verified grant naming the home.

type TLS

type TLS struct {
	Cert, Key, ClientCA string // -tls-cert, -tls-key, -client-ca
	InsecurePlaintext   bool   // -insecure-plaintext
}

TLS is the API's transport.

type Timing

type Timing struct{ StatusEvery, PressureEvery time.Duration }

Timing paces the W sampler, the Watch stream and the pressure ladder. Zero means one second. A negative PressureEvery turns the ladder off.

type Trust

type Trust struct {
	Verifier     string        // -verifier
	Issuer       string        // -issuer
	JWKSMaxStale time.Duration // -jwks-max-stale
	MaxLease     time.Duration // -max-lease
}

Trust is how grants are verified.

Jump to

Keyboard shortcuts

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