Documentation
¶
Index ¶
- Constants
- Variables
- func ActorSPIFFEID(r ActorRef) *url.URL
- func AddToAllocated(total *ateapi.WorkerResources, assignment *ateapi.ActorAssignment, sign int64) *ateapi.WorkerResources
- func CPUMemory(cpuMilli, memoryBytes int64) *ateapi.Resources
- func Covers(have, want *ateapi.Resources) bool
- func DeepEqual[T any](a, b T) bool
- func Free(capacity, allocated *ateapi.WorkerResources) *ateapi.Resources
- func IsValidResourceName(name string) bool
- func NetworkPolicyName(wpName string) string
- func NewSnapshotName() string
- func SumAllocated(assignments []*ateapi.ActorAssignment) *ateapi.WorkerResources
- func ToAPIError(errs field.ErrorList) error
- func ToGRPCStatusError(errs field.ErrorList) error
- func ToInternalError(errs field.ErrorList) error
- func ValidateActorDirs(actorDirs *ateworkerpb.ActorDirs, fldPath *field.Path) field.ErrorList
- func ValidateCSIMap(fldPath *field.Path, m map[string]string) field.ErrorList
- func ValidateCapabilities(fldPath *field.Path, caps []string, allowAll bool) field.ErrorList
- func ValidateEnvVarName(fldPath *field.Path, name string) field.ErrorList
- func ValidateHTTPGetPath(fldPath *field.Path, p string) field.ErrorList
- func ValidateHostPort(fldPath *field.Path, value string) field.ErrorList
- func ValidateIP(ip string, fldPath *field.Path) field.ErrorList
- func ValidateMountPath(fldPath *field.Path, p string) field.ErrorList
- func ValidateNestedMountPaths(fldPath *field.Path, paths []string) field.ErrorList
- func ValidateNestedMountPathsAt(paths []string, at func(i int) *field.Path) field.ErrorList
- func ValidatePinnedImage(fldPath *field.Path, value string) field.ErrorList
- func ValidateProjectedPath(fldPath *field.Path, p string) field.ErrorList
- func ValidateResourceName(name string, fldPath *field.Path) field.ErrorList
- func ValidateRuntimeAssetPath(root, p string, fldPath *field.Path) field.ErrorList
- func ValidateSandboxAssetsDir(actorUID, dir string, fldPath *field.Path) field.ErrorList
- func ValidateSandboxClass(fldPath *field.Path, value string) field.ErrorList
- func ValidateSnapshotFidelity(fidelity ateworkerpb.SnapshotFidelity, ...) field.ErrorList
- func ValidateSnapshotFileNames(files []string) error
- func ValidateSnapshotLocation(location string) error
- func ValidateStorageVolumeID(fldPath *field.Path, id string) field.ErrorList
- func ValidateUUID(uuid string, fldPath *field.Path) field.ErrorList
- func ValidateVolumeType(fldPath *field.Path, volumeType string) field.ErrorList
- func ValidateWorkerPodUID(workerPodUID string) error
- func WorkerForActorSPIFFEID(r ActorRef) *url.URL
- type ActorAttribution
- type ActorRef
- func ActorRefFromActor(a *ateapi.Actor) ActorRef
- func ActorRefFromActorSPIFFEID(id string) (ActorRef, error)
- func ActorRefFromActorSPIFFEURL(u *url.URL) (ActorRef, error)
- func ActorRefFromObjectRef(ref *ateapi.ObjectRef) ActorRef
- func ActorRefFromWorkerForActorSPIFFEID(id string) (ActorRef, error)
- func ActorRefFromWorkerForActorSPIFFEURL(u *url.URL) (ActorRef, error)
- type ActorTemplateRef
- type Resource
- type ResourceRef
- type SnapshotOwner
- type SnapshotURI
- func (u SnapshotURI) Atespace() string
- func (u SnapshotURI) IsZero() bool
- func (u SnapshotURI) Location() string
- func (u SnapshotURI) Name() string
- func (u SnapshotURI) ObjectURI(name string) (string, error)
- func (u SnapshotURI) OwnedBy(o SnapshotOwner) bool
- func (u SnapshotURI) Owner() SnapshotOwner
- func (u SnapshotURI) OwnerPrefix() StoragePrefix
- func (u SnapshotURI) Prefix() StoragePrefix
- func (u SnapshotURI) String() string
- type StoragePrefix
- type TagRef
Constants ¶
const ActorSPIFFETrustDomain = "substrate-actor.local"
ActorSPIFFETrustDomain is the trust domain of the SPIFFE ID an actor's certificate carries as its URI SAN.
TODO(identity): Must be configurable per-install, so that each install can set it to a unique value.
const FSCheckpointSubdir = "fs"
FSCheckpointSubdir is the subdirectory under the checkpoint directory where durable-dir filesystem checkpoint files are stored.
const ( // ResourceNameRegexPattern is the regular expression pattern for a valid // Substrate resource name. ResourceNameRegexPattern = `[a-z0-9]([-a-z0-9]*[a-z0-9])?` )
const RootfsCheckpointSubdir = "rootfs"
RootfsCheckpointSubdir is the subdirectory under the checkpoint directory where container rootfs filesystem checkpoint files are stored.
const SingletonName = "default"
SingletonName is the name of every singleton subresource, such as an Actor's EgressPolicy.
Variables ¶
var TransferStates = []ateapi.ActorState{ ateapi.ActorState_ACTOR_STATE_RESUMING, ateapi.ActorState_ACTOR_STATE_RUNNING, ateapi.ActorState_ACTOR_STATE_SUSPENDING, ateapi.ActorState_ACTOR_STATE_SUSPENDED, }
TransferStates are the states in which a node may be moving the actor's snapshot between itself and object storage:
- RESUMING: a resume fetches the snapshot.
- RUNNING: the actor keeps the credentials its resume minted.
- SUSPENDING: a suspend uploads the snapshot.
- SUSPENDED: a background upload of a local snapshot runs.
In every other state no node acts for the actor, so no node may hold a credential for its snapshots. The mint's host check and the objectstore plugin's credential exchange both refuse the other states, and read the list here so they cannot disagree.
Functions ¶
func ActorSPIFFEID ¶
ActorSPIFFEID returns "spiffe://substrate-actor.local/actor/<atespace>/<name>", which ateapi mints into the actor certificate's URI SAN.
func AddToAllocated ¶
func AddToAllocated(total *ateapi.WorkerResources, assignment *ateapi.ActorAssignment, sign int64) *ateapi.WorkerResources
AddToAllocated adjusts allocation by an assignment; sign is 1 or -1. It returns nil when allocation reaches zero.
func CPUMemory ¶
CPUMemory returns the Resources for cpuMilli and memoryBytes, or nil when both are zero, so an emptied total compares equal to an absent one.
func Covers ¶
Covers reports whether have leaves room for want in every dimension. A dimension want leaves at zero asks for nothing.
func DeepEqual ¶
DeepEqual compares two values of any type, using proto.Equal if both are proto messages, and reflect.DeepEqual otherwise. Declarative validation's generated code reaches it through each generating package's ateDeepEqual.
func Free ¶
func Free(capacity, allocated *ateapi.WorkerResources) *ateapi.Resources
Free is what a Worker has left after what its Actors hold. It goes negative once a Worker is overcommitted.
func IsValidResourceName ¶
IsValidResourceName reports whether name is a valid Substrate resource name (a DNS-1123 label; see ValidateResourceName for the rules). Use this for internal, non-proto checks where a plain predicate is wanted; to validate a proto request field with structured field-path errors, use ValidateResourceName. Empty is not a valid name.
func NetworkPolicyName ¶
NetworkPolicyName returns the NetworkPolicy name for a WorkerPool. It keeps the whole pool name, so each pool gets its own policy. The policy also uses the pool name as its ate.dev/worker-pool label value, which Kubernetes caps at 63 characters, so the result never needs truncating.
func NewSnapshotName ¶
func NewSnapshotName() string
NewSnapshotName returns a unique name for a new snapshot, durable or node-local.
func SumAllocated ¶
func SumAllocated(assignments []*ateapi.ActorAssignment) *ateapi.WorkerResources
SumAllocated is what a set of assignments takes from a Worker, or nil for none. Rebuilds the total rather than adjusting it, which is what the checks holding AddToAllocated to the assignments it counts compare against.
func ToAPIError ¶
ToAPIError turns validation errors into the InvalidArgument error an RPC handler responds with, or nil if errs is empty.
func ToGRPCStatusError ¶
ToGRPCStatusError turns validation errors into the InvalidArgument error an RPC handler responds with. Callers check len(errs) > 0 first.
TODO: Delete once atelet's WorkerSupport server returns apierrors, and use ToAPIError instead.
func ToInternalError ¶
ToInternalError turns validation errors on an object the server built, such as the final value about to be stored, into an Internal error. Callers check len(errs) > 0 first.
func ValidateActorDirs ¶
ValidateActorDirs checks that every directory atelet passes to the worker is absolute and clean. Presence is enforced by the tags on the message; it backs the ateworkerpb.ActorDirs custom validation hook.
func ValidateCSIMap ¶
ValidateCSIMap bounds a map a CSI driver produced (a volume or publish context) at csiMapMaxBytes, counting keys and values. The entries are the driver's own and are not validated further.
func ValidateCapabilities ¶
ValidateCapabilities checks each capability name. "ALL" is accepted only when allowAll is set, which is the case for drop but not add.
func ValidateEnvVarName ¶
ValidateEnvVarName checks an environment variable name.
func ValidateHTTPGetPath ¶
ValidateHTTPGetPath checks a wakeup probe's HTTP path.
func ValidateHostPort ¶
ValidateHostPort requires "host:port", where host is an IP address or a DNS subdomain name (a trailing dot, marking it fully qualified, is allowed) and port is a number in 1..65535.
func ValidateIP ¶
ValidateIP checks that the given string is a valid IP address, is not an IPv4-mapped IPv6 address, and is in canonical form.
func ValidateMountPath ¶
ValidateMountPath requires a clean absolute Unix path that starts with '/', is not '/', and contains no ':', '.' or '..' segments, '//', trailing '/', or control characters.
func ValidateNestedMountPaths ¶
ValidateNestedMountPaths rejects mount paths that nest under or over one another: volumes cannot mount onto other volumes. paths[i] is reported at fldPath[i].mount_path. Identical paths are left to the list-key uniqueness check.
func ValidateNestedMountPathsAt ¶
ValidateNestedMountPathsAt is ValidateNestedMountPaths for paths gathered from more than one list: at(i) is where paths[i] is reported.
func ValidatePinnedImage ¶
ValidatePinnedImage requires a well-formed OCI image reference pinned by digest (e.g. "name@sha256:..."): changing the image content under a fixed reference invalidates snapshots. It parses with the same grammar the container runtimes use, so a malformed digest is rejected rather than treated as pinned.
func ValidateProjectedPath ¶
ValidateProjectedPath applies volumepath.ValidateProjected to a file path projected into a system-info volume. atelet re-checks it before writing to the host.
func ValidateResourceName ¶
ValidateResourceName checks that a string conforms to Agent Substrate's rules for a resource name, which is a subset of the rules for an RFC-1123 DNS label. This does not check for zero-length strings, which callers may want to handle differently (e.g., by returning a "required" error).
func ValidateRuntimeAssetPath ¶
ValidateRuntimeAssetPath ensures p is a regular file under root, with no symlinks worker runs these as root, so they must be assets atelet fetched into root
func ValidateSandboxAssetsDir ¶
ValidateSandboxAssetsDir requires dir, the sandbox_assets_dir a request names, to be the actor's own, nodepath.ActorSandboxAssetsDir(actorUID), so a request cannot point a worker at binaries staged for another actor or anywhere else on the node. The actor UID is checked first: it becomes a path element, and must be a plain label rather than a traversal.
func ValidateSandboxClass ¶
ValidateSandboxClass requires one of the sandboxclass values. An empty value is left to the required tag.
func ValidateSnapshotFidelity ¶
func ValidateSnapshotFidelity(fidelity ateworkerpb.SnapshotFidelity, supported []ateworkerpb.SnapshotFidelity, fldPath *field.Path) field.ErrorList
ValidateSnapshotFidelity rejects a checkpoint or restore request whose fidelity the calling sandbox runtime cannot serve. Each runtime passes the levels it implements; anything else, including an unset fidelity, is refused before the request touches the guest.
func ValidateSnapshotFileNames ¶
ValidateSnapshotFileNames requires each name to be a distinct plain file name in the checkpoint directory or its "fs" or "rootfs" subdirectories. Actual file access must still use os.Root so symlinks cannot escape that directory.
func ValidateSnapshotLocation ¶
ValidateSnapshotLocation ensures an ActorTemplate's snapshotConfig.storageLocation is a well-formed URI with a bucket, so a bad location fails fast instead of deep inside an object-storage call. It deliberately does not restrict the scheme: the storage layer only uses the host (bucket) and path, and which schemes are acceptable is a storage-backend policy, not a per-RPC one.
This validates the base that many snapshots share, not any one snapshot's URI; SnapshotURI is the type for the latter, and it applies this check when it is built.
func ValidateStorageVolumeID ¶
ValidateStorageVolumeID rejects control characters (U+0000-U+0008, U+000B, U+000C, U+000E-U+001F, U+007F-U+009F) in an external volume's storage ID.
func ValidateUUID ¶
ValidateUUID verifies that the specified value is a valid UUID (RFC 4122).
- must be 36 characters long
- must be in the normalized form `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
- must use only lowercase hexadecimal characters
func ValidateVolumeType ¶
ValidateVolumeType allows an optional "substrate.io/" prefix, followed by a valid DNS-1123 subdomain.
func ValidateWorkerPodUID ¶
ValidateWorkerPodUID rejects a worker pod UID that could escape the host path built from it: the worker control socket (.../workers/<uid>/worker.sock). Kubernetes pod UIDs are UUIDs, which are valid DNS-1123 labels, so a label check accepts every legitimate value while rejecting separators and "..".
func WorkerForActorSPIFFEID ¶
WorkerForActorSPIFFEID returns "spiffe://substrate-actor.local/worker-for-actor/<atespace>/<name>", which ateapi mints into the actor certificate's URI SAN.
Types ¶
type ActorAttribution ¶
type ActorAttribution struct {
Ref ActorRef
UID string
TemplateAtespace string
TemplateName string
}
ActorAttribution is what telemetry about an actor is attributed to: an ActorRef plus the two things a ref does not carry, the server-assigned uid and the template the actor was built from. Shared by ateattr, actorlog, and worker's usage sampling so those producers cannot drift apart.
Unrelated to the credential sense of "actor identity" elsewhere in the repo (ateapi's ActorIdentity service, substratex509) — nothing here is a secret or is presented as proof of anything.
func ActorAttributionFromActor ¶
func ActorAttributionFromActor(a *ateapi.Actor) ActorAttribution
ActorAttributionFromActor builds the attribution for a loaded Actor. Nil-safe; a nil Actor yields zero-valued fields.
type ActorRef ¶
type ActorRef = ResourceRef[*ateapi.Actor]
ActorRef identifies an actor by the (atespace, name).
func ActorRefFromActor ¶
ActorRefFromActor returns the reference addressing the given actor.
func ActorRefFromActorSPIFFEID ¶
ActorRefFromActorSPIFFEID parses an ID built by ActorSPIFFEID.
func ActorRefFromObjectRef ¶
ActorRefFromObjectRef converts a wire reference to an ActorRef.
func ActorRefFromWorkerForActorSPIFFEID ¶
ActorRefFromWorkerForActorSPIFFEID parses an ID built by WorkerForActorSPIFFEID.
type ActorTemplateRef ¶
type ActorTemplateRef = ResourceRef[*ateapi.ActorTemplate]
ActorTemplateRef identifies an ActorTemplate by the (atespace, name).
func ActorTemplateRefFromActorTemplate ¶
func ActorTemplateRefFromActorTemplate(t *ateapi.ActorTemplate) ActorTemplateRef
ActorTemplateRefFromActorTemplate returns the reference addressing the given template.
func ActorTemplateRefFromObjectRef ¶
func ActorTemplateRefFromObjectRef(ref *ateapi.ObjectRef) ActorTemplateRef
ActorTemplateRefFromObjectRef converts a wire reference to an ActorTemplateRef.
type Resource ¶
type Resource interface {
GetMetadata() *ateapi.ResourceMetadata
}
Resource is any Atespaced resource message carrying the common metadata.
type ResourceRef ¶
type ResourceRef[R Resource] struct { // Atespace is the isolation boundary the resource was created into. Required. Atespace string // Name is the resource's name, unique within Atespace. Required. Name string }
ResourceRef identifies an Atespaced resource by the (atespace, name).
func (ResourceRef[R]) LogValue ¶
func (r ResourceRef[R]) LogValue() slog.Value
LogValue implements slog.LogValuer so that slog.Any("template", ref) records the two components as a group ("template.atespace", "template.name") rather than flattening them into one opaque string.
func (ResourceRef[R]) String ¶
func (r ResourceRef[R]) String() string
func (ResourceRef[R]) ToObjectRef ¶
func (r ResourceRef[R]) ToObjectRef() *ateapi.ObjectRef
ToObjectRef converts the reference to its wire form.
type SnapshotOwner ¶
type SnapshotOwner struct {
// contains filtered or unexported fields
}
SnapshotOwner is the resource whose objects a snapshot's prefix holds: the Actor that took it, or the Tag that copied it. Deletion is expressed as "collect everything under my own prefix", so an owner cannot name another's objects, and a borrowed snapshot is recognized by the URI alone rather than by a flag the two have to keep in sync.
func ActorSnapshotOwner ¶
func ActorSnapshotOwner(atespace, actorUID string) SnapshotOwner
ActorSnapshotOwner returns the owner of the snapshots an Actor takes. It is keyed on the UID rather than the name so that an Actor recreated under the same name never inherits its predecessor's objects.
func TagSnapshotOwner ¶
func TagSnapshotOwner(atespace, tagUID string) SnapshotOwner
TagSnapshotOwner returns the owner of the one snapshot a Tag holds. It is keyed on the UID so a recreated tag never inherits its predecessor's objects.
func (SnapshotOwner) Atespace ¶
func (o SnapshotOwner) Atespace() string
Atespace returns the atespace the owner belongs to.
func (SnapshotOwner) IsZero ¶
func (o SnapshotOwner) IsZero() bool
IsZero reports whether o is the zero SnapshotOwner.
func (SnapshotOwner) Prefix ¶
func (o SnapshotOwner) Prefix(location string) (StoragePrefix, error)
Prefix returns the prefix holding every object this owner's snapshots are made of, under an ActorTemplate's snapshotConfig.location.
func (SnapshotOwner) String ¶
func (o SnapshotOwner) String() string
type SnapshotURI ¶
type SnapshotURI struct {
// contains filtered or unexported fields
}
SnapshotURI is where one external snapshot's objects live in object storage: an ActorTemplate's snapshotConfig.location, plus the prefix of the resource that owns the snapshot.
gs://bucket/root location
gs://bucket/root/atespaces/team-a/actors/<uid> an Actor's prefix
gs://bucket/root/atespaces/team-a/actors/<uid>/snapshots/<name> one of its snapshots
gs://bucket/root/atespaces/team-a/tags/<uid> a tag's prefix, and
its only snapshot
func NewActorSnapshotURI ¶
func NewActorSnapshotURI(location, atespace, actorUID, name string) (SnapshotURI, error)
NewActorSnapshotURI returns the URI of a snapshot an Actor took, stored under an ActorTemplate's snapshotConfig.location.
func NewTagSnapshotURI ¶
func NewTagSnapshotURI(location, atespace, tagUID string) (SnapshotURI, error)
NewTagSnapshotURI returns the URI of the snapshot a Tag owns, stored under an ActorTemplate's snapshotConfig.location. The tag's prefix and its snapshot's are the same: a tag holds exactly one snapshot.
func ParseSnapshotURI ¶
func ParseSnapshotURI(uri string) (SnapshotURI, error)
ParseSnapshotURI parses a given snapshot URI.
func (SnapshotURI) Atespace ¶
func (u SnapshotURI) Atespace() string
Atespace returns the atespace of the resource that owns the snapshot.
func (SnapshotURI) IsZero ¶
func (u SnapshotURI) IsZero() bool
IsZero reports whether u is the zero SnapshotURI.
func (SnapshotURI) Location ¶
func (u SnapshotURI) Location() string
Location returns the ActorTemplate snapshotConfig.location this snapshot is stored under.
func (SnapshotURI) Name ¶
func (u SnapshotURI) Name() string
Name returns the snapshot's resource name.
func (SnapshotURI) ObjectURI ¶
func (u SnapshotURI) ObjectURI(name string) (string, error)
ObjectURI returns the address of a single object stored within the snapshot.
func (SnapshotURI) OwnedBy ¶
func (u SnapshotURI) OwnedBy(o SnapshotOwner) bool
OwnedBy reports whether the snapshot is owned by o. A collector asks this before deleting: an Actor whose snapshot came from a tag does not own it, and releasing it would break every other Actor cloned from that tag.
func (SnapshotURI) Owner ¶
func (u SnapshotURI) Owner() SnapshotOwner
Owner returns the resource whose prefix the snapshot lives under.
func (SnapshotURI) OwnerPrefix ¶
func (u SnapshotURI) OwnerPrefix() StoragePrefix
OwnerPrefix returns the prefix of the resource that owns the snapshot, holding this snapshot and every other that owner wrote. Collecting an owner takes only a URI it recorded, with no need to resolve its ActorTemplate for the storage location.
func (SnapshotURI) Prefix ¶
func (u SnapshotURI) Prefix() StoragePrefix
Prefix returns the prefix holding this one snapshot's objects.
func (SnapshotURI) String ¶
func (u SnapshotURI) String() string
type StoragePrefix ¶
type StoragePrefix struct {
// contains filtered or unexported fields
}
StoragePrefix is a validated object-storage prefix: a scheme, a bucket and a path, with no query, fragment or userinfo. Every object below this prefix has a name starting with its path, so deleting the prefix collects all of them.
func ParseStoragePrefix ¶
func ParseStoragePrefix(uri string) (StoragePrefix, error)
ParseStoragePrefix parses a storage prefix received as a string, such as a snapshot URI or an owner's prefix. It rejects a bare bucket, so a prefix can never name every object in a bucket.
func (StoragePrefix) IsZero ¶
func (p StoragePrefix) IsZero() bool
IsZero reports whether p is empty
func (StoragePrefix) String ¶
func (p StoragePrefix) String() string
type TagRef ¶
type TagRef = ResourceRef[*ateapi.Tag]
TagRef identifies a Tag by the (atespace, name).
func TagRefFromObjectRef ¶
TagRefFromObjectRef converts an ObjectRef to a TagRef.
func TagRefFromTag ¶
TagRefFromTag returns the reference addressing the given tag.