Documentation
¶
Overview ¶
Package register registers a worker process with the control plane through the node-local atelet: it acquires an epoch, registers once with that epoch, its pod IPs and its compute capacity, then reports the sandbox runtimes of its pool. It also provides file-watching helpers shared by worker binaries.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromFiles ¶
func FromFiles(actors int) *ateletpb.WorkerResources
FromFiles combines the downward API compute limits with the worker's own actor limit.
A limit that is missing or unparseable is reported as zero, which the control plane reads as none: better to place nothing on a worker that cannot say what it has than to invent a number for it.
TODO: Watch the projected files and report changes. For now we do not support in-place Pod vertical scaling (IPPR); capacity is read once at startup. NOTE: Please do not implement this yet. IPPR needs more general consideration.
func ParsePodIPs ¶
ParsePodIPs splits the comma-separated pod IPs the downward API exposes for status.podIPs.
func Report ¶
func Report(ctx context.Context, cfg ReportConfig, epoch *Epoch) error
Report registers this worker process with the node-local atelet, stores the epoch it registered with in epoch, then keeps its sandbox runtimes reported until ctx ends: it reads its sandbox runtimes file at startup and again whenever atelet rewrites it.
It returns early on a configuration error, which no retry would fix, and when the control plane refuses this process's epoch, which means another worker process has registered since: this one must stop serving.
Retrying is what makes registration durable: atelet only accepts once the control plane has recorded it, and the Worker record may not exist yet when a worker first comes up. Nothing else reports this, so giving up would leave the Worker holding no capacity and hosting nothing.
func WatchFilePath ¶
WatchFilePath signals on the returned channel whenever the file at path is created, written, or replaced, or when the underlying watcher reports an error (such as an event queue overflow) so the caller can re-read the file. It watches path's parent directory, which must exist, so atomic file replacements via rename are detected even when the file itself does not exist yet at startup.
If fsnotify cannot watch the parent directory (for example, when the host UID's fs.inotify.max_user_instances budget is exhausted), WatchFilePath logs a warning and falls back to signaling periodically at watchPollInterval until ctx ends. The returned channel is closed when ctx ends.
Types ¶
type CrashReporter ¶
type CrashReporter struct {
// contains filtered or unexported fields
}
CrashReporter tells the control plane, through the node-local atelet, that the sandbox of an actor this ateworker hosts died on its own.
func NewCrashReporter ¶
func NewCrashReporter(cfg ReportConfig) (*CrashReporter, error)
NewCrashReporter loads the ateworker's credentials once, at startup. Only the connection fields of cfg are used.
func (*CrashReporter) ReportCrashed ¶
func (r *CrashReporter) ReportCrashed(ctx context.Context, actor resources.ActorAttribution, message string) error
ReportCrashed reports that actor's sandbox died, retrying until the control plane answers or ctx ends. A crash stays true, so unlike a suspend request it is worth retrying for as long as the caller allows. A refusal, the actor having moved on or an operation in flight owning it, is an answer and is logged rather than returned.
type Epoch ¶
type Epoch struct {
// contains filtered or unexported fields
}
Epoch is the epoch this worker process registered with. A worker process takes no workloads until it has registered, and reports this epoch with each one it starts, so the control plane can tell which process ran it.
func (*Epoch) Registered ¶
Registered is a readiness check that fails until this worker process has registered. The pod is then not Ready, so the Worker takes no placements while a restarted worker process has yet to register.
type ReportConfig ¶
type ReportConfig struct {
SocketPath string
CredentialBundlePath string
TrustBundlePath string
// AteletSPIFFEID is the identity the node-local atelet must present. It
// names atelet's namespace, not this worker's, so it is configured rather
// than derived from the downward API.
AteletSPIFFEID string
// Actors is how many actors this worker will host at once.
Actors int
// PodIPs are the worker pod's IPs, from the downward API.
PodIPs []string
// SandboxClass is the class this worker implements ("gvisor", "microvm").
SandboxClass string
// RuntimesFile is the sandbox runtimes file atelet keeps for this worker
// (nodepath.WorkerSandboxRuntimesPath).
RuntimesFile string
}
ReportConfig configures how a worker reaches the node-local atelet and what it registers with.