Documentation
¶
Overview ¶
Package hardware probes host hardware compatibility attributes and evaluates sandbox runtime compatibility between workers and snapshots.
Index ¶
- Constants
- func ColdBootRuntime(status *ateapi.WorkerStatus) *ateapi.ActorSandboxRuntime
- func DecodeCPUFeatures(arch, value string) ([]string, error)
- func EncodeCPUFeatures(arch string, features []string) (string, error)
- func Matches(rt, snap *ateapi.ActorSandboxRuntime) bool
- func MatchesCompat(worker, snap *ateapi.VersionedSandboxCompat) bool
- func MatchingRuntime(status *ateapi.WorkerStatus, snap *ateapi.ActorSandboxRuntime) *ateapi.ActorSandboxRuntime
- func ProbeCPUIdentity() (vendor, model string, err error)
- func ProbeHost() *ateletpb.VersionedSandboxCompat
- func RuntimeFor(status *ateapi.WorkerStatus, snap *ateapi.ActorSandboxRuntime) *ateapi.ActorSandboxRuntime
- func SandboxClass(status *ateapi.WorkerStatus) string
- func WorkerMatches(status *ateapi.WorkerStatus, snap *ateapi.ActorSandboxRuntime) bool
- type Requirement
- func (r Requirement) Matches(rt *ateapi.ActorSandboxRuntime) bool
- func (r Requirement) MatchingRuntime(status *ateapi.WorkerStatus) *ateapi.ActorSandboxRuntime
- func (r Requirement) Runtime() *ateapi.ActorSandboxRuntime
- func (r Requirement) RuntimeFor(status *ateapi.WorkerStatus) *ateapi.ActorSandboxRuntime
- func (r Requirement) WorkerMatches(status *ateapi.WorkerStatus) bool
- func (r Requirement) WorkerRuntimeFor(status *ateapi.WorkerStatus) *ateapi.WorkerSandboxRuntime
Constants ¶
const ( // SchemaVersionV1 is the initial compatibility schema version. SchemaVersionV1 = "v1" // AttrArchitecture is the CPU architecture ("amd64", "arm64", etc.). AttrArchitecture = "architecture" // AttrSandboxBundleHash identifies the sandbox runtime bundle: a // sha256 over a SandboxConfig version's asset digests, computed by atelet. AttrSandboxBundleHash = "sandbox_bundle_hash" // AttrCPUFeatures is the set of CPU features `runsc cpu-features` reports // for a gVisor runtime, encoded by EncodeCPUFeatures as a hex bitmask over // the architecture's feature table. A snapshot's set must be a subset of // the worker's. AttrCPUFeatures = "cpu_features" // AttrCPUVendor identifies the host CPU vendor (e.g. "GenuineIntel", // "AuthenticAMD", or arm64 implementer "0x41") reported by microVM // runtimes. AttrCPUVendor = "cpu_vendor" // AttrCPUModel identifies the host CPU family/model (e.g. "6:143" on amd64 // or "0x0:0xd40:1" on arm64) reported by microVM runtimes. AttrCPUModel = "cpu_model" )
Variables ¶
This section is empty.
Functions ¶
func ColdBootRuntime ¶
func ColdBootRuntime(status *ateapi.WorkerStatus) *ateapi.ActorSandboxRuntime
ColdBootRuntime returns the runtime a fresh actor starts under on a worker with status: the DefaultRuntime of its class, as a stamp, or nil before the worker has registered.
func DecodeCPUFeatures ¶
DecodeCPUFeatures returns the feature names a cpu_features value encodes for arch, in bit order. A set bit with no name is an error: the hardware reserves it, so no encoder of this schema could have produced the value.
func EncodeCPUFeatures ¶
EncodeCPUFeatures encodes the feature names `runsc cpu-features` printed for arch as a cpu_features value. Blank names are skipped; duplicates and order do not matter. An unknown name is an error rather than a dropped bit: a snapshot encoded without a feature its sandbox used would match workers that lack it.
func Matches ¶
func Matches(rt, snap *ateapi.ActorSandboxRuntime) bool
Matches reports whether rt, the runtime an assignment records, can restore a snapshot stamped with snap, for one comparison; a caller holding one snap against many workers should prepare a Requirement once. A nil snap imposes no constraint.
func MatchesCompat ¶
func MatchesCompat(worker, snap *ateapi.VersionedSandboxCompat) bool
MatchesCompat reports whether worker can restore a snapshot stamped with snap, for one comparison. Unlike Matches, a nil snap is a stamp missing its identity and matches nothing.
func MatchingRuntime ¶
func MatchingRuntime(status *ateapi.WorkerStatus, snap *ateapi.ActorSandboxRuntime) *ateapi.ActorSandboxRuntime
MatchingRuntime is NewRequirement(snap).MatchingRuntime(status).
func ProbeCPUIdentity ¶
ProbeCPUIdentity reads /proc/cpuinfo for the host CPU's vendor and model: the AttrCPUVendor and AttrCPUModel values of a microVM runtime.
func ProbeHost ¶
func ProbeHost() *ateletpb.VersionedSandboxCompat
ProbeHost returns a minimal v1 VersionedSandboxCompat with the current host's architecture in atelet wire format, for synthetic workers in tests and benchmarks. Production workers report the attributes atelet writes to sandbox-runtimes.json instead.
func RuntimeFor ¶
func RuntimeFor(status *ateapi.WorkerStatus, snap *ateapi.ActorSandboxRuntime) *ateapi.ActorSandboxRuntime
RuntimeFor is NewRequirement(snap).RuntimeFor(status).
func SandboxClass ¶
func SandboxClass(status *ateapi.WorkerStatus) string
SandboxClass returns the sandbox class a worker with status registered, or "" before it has.
func WorkerMatches ¶
func WorkerMatches(status *ateapi.WorkerStatus, snap *ateapi.ActorSandboxRuntime) bool
WorkerMatches is NewRequirement(snap).WorkerMatches(status).
Types ¶
type Requirement ¶
type Requirement struct {
// contains filtered or unexported fields
}
Requirement is what a worker must run to restore a snapshot: the ActorSandboxRuntime the snapshot was stamped with, prepared for matching against many workers. The scheduler asks it once per candidate, so the snapshot's AttrCPUFeatures is parsed here, once, rather than on every comparison. The zero Requirement, like NewRequirement(nil), requires nothing.
func NewRequirement ¶
func NewRequirement(snap *ateapi.ActorSandboxRuntime) Requirement
NewRequirement prepares snap for matching. A nil snap requires nothing.
func (Requirement) Matches ¶
func (r Requirement) Matches(rt *ateapi.ActorSandboxRuntime) bool
Matches reports whether rt, the runtime an assignment records, can restore the snapshot. A requirement of nothing is met by any runtime. Otherwise the sandbox classes must be equal and the compat must match.
func (Requirement) MatchingRuntime ¶
func (r Requirement) MatchingRuntime(status *ateapi.WorkerStatus) *ateapi.ActorSandboxRuntime
MatchingRuntime returns the runtime from status that can restore the snapshot, as a stamp: the snapshot's class with the version of the runtime matchingRuntime finds, or nil when it finds none. A requirement of nothing returns ColdBootRuntime.
func (Requirement) Runtime ¶
func (r Requirement) Runtime() *ateapi.ActorSandboxRuntime
Runtime returns the ActorSandboxRuntime the requirement was prepared from, or nil when it requires nothing.
func (Requirement) RuntimeFor ¶
func (r Requirement) RuntimeFor(status *ateapi.WorkerStatus) *ateapi.ActorSandboxRuntime
RuntimeFor returns the runtime a worker with status runs an actor under whose snapshot is stamped with the required runtime: the matching runtime when it can restore the snapshot, else the ColdBootRuntime the guest boots fresh under. This is what an assignment records and what the actor's next checkpoint is stamped with.
func (Requirement) WorkerMatches ¶
func (r Requirement) WorkerMatches(status *ateapi.WorkerStatus) bool
WorkerMatches reports whether a worker with status can restore the snapshot. A requirement of nothing is met by any worker.
func (Requirement) WorkerRuntimeFor ¶ added in v1.0.0
func (r Requirement) WorkerRuntimeFor(status *ateapi.WorkerStatus) *ateapi.WorkerSandboxRuntime
WorkerRuntimeFor returns the worker's runtime that RuntimeFor stamps, as the worker reported it, or nil before the worker has registered.