Help us shape the future of Go! Take the 2026 Go Developer Survey

execution

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package execution owns agent-backed machine management, independently of the desktop/display grant and the existing serial/SSH/container exec bridges.

Index

Constants

This section is empty.

Variables

View Source
var ErrAdmissionDenied = errors.New("execution admission denied")

ErrAdmissionDenied is returned when an execution may not proceed. In every case the caller must treat it as fail-closed and must not start a process.

Functions

func CurrentEpoch

func CurrentEpoch(ws *unstructured.Unstructured, vmUID string) (uint64, error)

CurrentEpoch reads controller-owned status, bound to the current VM UID. A monotonic spec minimum may request revocation but never supplies authority. Missing status (including an old CRD pruning it), malformed state, and a request not yet acknowledged by the controller all deny admission.

Types

type AdmissionRequest

type AdmissionRequest struct {
	ExecutionID         string
	RecordingID         string
	ActorID             string
	Operation           storage.Operation
	Namespace           string
	WorkspaceName       string
	WorkspaceUID        string
	WorkspaceGeneration int64
	GrantVersion        string
	OSIdentity          string
	Elevated            bool
}

AdmissionRequest is the off-guest, already-authorized description of one execution. The caller must have authenticated the actor and checked the controller-owned grants BEFORE calling Admit; the service only enforces storage readiness, durability and recording.

type ReplayAuthorizer

type ReplayAuthorizer interface {
	AuthorizeReplay(ctx context.Context, actorID string, rec storage.ExecutionRecord) error
}

ReplayAuthorizer decides whether a principal may replay a recording. It must re-check workspace.execution.recordings.read against the record's namespace and workspace on every call; it must never trust a previously-admitted execution ID as authority on its own.

type S3Config

type S3Config struct {
	Endpoint       string
	Region         string
	Bucket         string
	ForcePathStyle bool
	CreateBucket   bool
	CAFile         string
	AccessKey      string `json:"-"`
	SecretKey      string `json:"-"`
}

func (S3Config) String

func (c S3Config) String() string

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the execution admission and recording coordinator. A zero-value or disabled store can never admit work, and a persistent store that is not Ready is never treated as permission to run.

func NewService

func NewService(store storage.Store) *Service

NewService builds the coordinator. A nil store disables admission entirely (every Admit fails closed with ErrAdmissionDenied). Replay is denied until a ReplayAuthorizer is supplied via WithReplayAuthorizer.

func (*Service) Admit

func (s *Service) Admit(ctx context.Context, req AdmissionRequest) (*Session, error)

Admit durably records the admission before any process is created, opens the mandatory recording, and returns a session for streaming output and audit. The returned error always wraps ErrAdmissionDenied so callers cannot mistake a failure for permission to run.

func (*Service) Close

func (s *Service) Close() error

Close releases the backing store, if any.

func (*Service) Durability

func (s *Service) Durability() storage.Durability

func (*Service) Get

Get returns the stored admission record and its last known outcome. It fails closed when storage is disabled or unready.

func (*Service) List

List returns admission records matching the filter. The caller must scope the filter to what the actor is allowed to see before calling; this method only enforces storage readiness.

func (*Service) Mode

func (s *Service) Mode() string

Mode and Durability describe the active store, or disabled when unset.

func (*Service) Ready

func (s *Service) Ready(ctx context.Context) error

Ready reports whether the backing store can admit work. It is safe to call on a nil-store service and returns the store error otherwise.

func (*Service) RecordingStatus

func (s *Service) RecordingStatus(ctx context.Context) (mode string, durable bool, available bool)

RecordingStatus reports whether the store can admit and replay recordings right now. It never returns an error; callers use it for capability display.

func (*Service) Replay

func (s *Service) Replay(ctx context.Context, actorID, executionID string) (storage.Reader, storage.ExecutionRecord, error)

Replay authorizes, verifies, and audits access before returning any recording.

func (*Service) ReplayRecording

func (s *Service) ReplayRecording(ctx context.Context, actorID, executionID string) (storage.Reader, storage.ExecutionRecord, error)

ReplayRecording authorizes and opens the finalized recording bound to executionID, mirroring Replay but keyed by the execution the caller saw.

func (*Service) WithReplayAuthorizer

func (s *Service) WithReplayAuthorizer(a ReplayAuthorizer) *Service

WithReplayAuthorizer installs the replay policy and returns the service.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session serializes recording and lifecycle operations for one admission.

func (*Session) Abort

func (s *Session) Abort(ctx context.Context, reason string) error

Abort preserves partial evidence and marks the execution failed. The caller must terminate any running process; this coordinator never owns a process.

func (*Session) AppendChunk

func (s *Session) AppendChunk(ctx context.Context, plaintext []byte) error

AppendChunk encrypts and stores the next contiguous recording chunk. Plaintext ordering is preserved; a gap is impossible because indices are session-owned.

func (*Session) Audit

func (s *Session) Audit(ctx context.Context, kind string, detail map[string]string) error

Audit appends a non-sensitive audit event for this execution.

func (*Session) Finish

func (s *Session) Finish(ctx context.Context, outcome storage.ExecutionOutcome) error

Finish finalizes the recording and writes the terminal outcome. If finalizing the recording fails the outcome is marked recording_lost; the execution is still finalized so the state never silently stays running.

func (*Session) Record

func (s *Session) Record() storage.ExecutionRecord

Record returns a copy of the admission record bound to this session.

func (*Session) Start

func (s *Session) Start(ctx context.Context) error

Start marks the process as running. It is idempotent.

type StorageConfig

type StorageConfig struct {
	Mode               StorageMode
	RecordingRetention time.Duration
	MetadataRetention  time.Duration
	EphemeralDir       string
	EphemeralMaxBytes  int64
	DatabaseURL        string `json:"-"`
	S3                 S3Config
	KeyID              string
	// contains filtered or unexported fields
}

StorageConfig contains resolved deployment configuration, not runtime storage health. A valid configuration alone must never enable execution admission.

func StorageConfigFromEnv

func StorageConfigFromEnv() (StorageConfig, error)

func (StorageConfig) Persistent

func (c StorageConfig) Persistent() bool

func (StorageConfig) RecordingKey

func (c StorageConfig) RecordingKey() []byte

RecordingKey returns a copy of the recording encryption key for storage engines. The result is secret material; never log it.

func (StorageConfig) StorageOptions

func (c StorageConfig) StorageOptions() storage.Options

StorageOptions translates the validated deployment configuration into the decoupled storage options. It never enables admission on its own: callers must Open the store and require Ready before permitting execution.

func (StorageConfig) String

func (c StorageConfig) String() string

String prevents accidental credential/key disclosure through ordinary logging.

type StorageMode

type StorageMode string
const (
	StorageDisabled  StorageMode = "disabled"
	StorageEphemeral StorageMode = "ephemeral"
	StorageExternal  StorageMode = "external"
	StorageBundled   StorageMode = "bundled"
)

Directories

Path Synopsis
Package enrollment implements one-use, CSR-bound management bootstrap issuance.
Package enrollment implements one-use, CSR-bound management bootstrap issuance.
Package grants defines the independently verifiable management-v1 grant envelope.
Package grants defines the independently verifiable management-v1 grant envelope.
Package management wires the opt-in management issuer and trusted bootstrap importer.
Package management wires the opt-in management issuer and trusted bootstrap importer.
Package pki defines management-only certificate identities and mutual TLS.
Package pki defines management-only certificate identities and mutual TLS.
Package qga implements the server side of the approved QGA pod-exec pilot transport (`qga-pod-exec/v1`): a Kubernetes-authenticated pod exec into the current KubeVirt virt-launcher, driving the fixed installed runner through the QEMU guest agent.
Package qga implements the server side of the approved QGA pod-exec pilot transport (`qga-pod-exec/v1`): a Kubernetes-authenticated pod exec into the current KubeVirt virt-launcher, driving the fixed installed runner through the QEMU guest agent.
Package storage implements the durable-and-ephemeral execution store: a searchable metadata/audit layer (PostgreSQL in persistent modes, bounded in-memory in ephemeral mode) plus an encrypted, hash-chained recording chunk store (S3-compatible in persistent modes, bounded encrypted temp files in ephemeral mode).
Package storage implements the durable-and-ephemeral execution store: a searchable metadata/audit layer (PostgreSQL in persistent modes, bounded in-memory in ephemeral mode) plus an encrypted, hash-chained recording chunk store (S3-compatible in persistent modes, bounded encrypted temp files in ephemeral mode).
Package updates verifies publisher-authenticated agent-update manifests, authenticated machine inventory reports and the write-ahead upgrade journal, plus bounded payload streams.
Package updates verifies publisher-authenticated agent-update manifests, authenticated machine inventory reports and the write-ahead upgrade journal, plus bounded payload streams.
Package upgrades implements durable off-guest agent-upgrade admission: an exclusive per-VM reservation, idempotent start, safe cancellation, explicit rollback admission and the recording/audit evidence trail.
Package upgrades implements durable off-guest agent-upgrade admission: an exclusive per-VM reservation, idempotent start, safe cancellation, explicit rollback admission and the recording/audit evidence trail.

Jump to

Keyboard shortcuts

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