executioncontroller

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 64 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package executioncontroller implements the authenticated provider gRPC boundary.

Index

Constants

View Source
const (
	CapabilityFilesystem        = "filesystem"
	CapabilityForegroundCommand = "foreground-command"
)

Capabilities a template revision can declare.

Variables

View Source
var ExecutionEnvironmentGVR = schema.GroupVersionResource{Group: "execution.mecatl.dev", Version: "v1alpha1", Resource: "executionenvironments"}

ExecutionEnvironmentGVR identifies the private execution-environment CRD.

Functions

func CanonicalTemplateRevision added in v0.0.48

func CanonicalTemplateRevision(spec ProfileSpec) (string, error)

CanonicalTemplateRevision returns the v1 identity of the execution recipe. Admission policy and display metadata are deliberately outside ProfileSpec. Capability order and an absent capability list do not change the revision. Call LoadTemplates to validate the complete definition before publishing it.

func TLSConfig

func TLSConfig(server tls.Certificate, clientCAs *x509.CertPool) *tls.Config

TLSConfig returns the provider's TLS 1.3 mutual-authentication policy.

Types

type Allocation

type Allocation struct {
	Environment                  executionenv.EnvironmentRef
	Epoch, GrantGeneration       uint64
	OwnerHash, BindingID, Client string
	Ready                        bool
	AdmittedCapabilities         []string
}

Allocation is an exact environment allocation and authorization binding.

type ClientPolicy

type ClientPolicy struct {
	MayAttestOwner, Administrator bool
	AdministratorFor              []string
	ExecutionTemplates            []string
}

ClientPolicy defines capabilities assigned to an authenticated provider client.

type ExecutorDialer added in v0.0.52

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

ExecutorDialer connects to executor servers by pinned Pod UID and certificate fingerprint, presenting the provider's projected platform client certificate.

func NewExecutorDialer added in v0.0.52

func NewExecutorDialer(
	kube kubernetes.Interface, namespace, clientDirectory, clientURI string,
) *ExecutorDialer

NewExecutorDialer constructs a dialer reading tls.crt and tls.key from clientDirectory.

func (*ExecutorDialer) CheckClientCertificate added in v0.0.52

func (d *ExecutorDialer) CheckClientCertificate() error

CheckClientCertificate reports whether the projected client certificate is currently valid for client authentication and names the configured URI.

func (*ExecutorDialer) Dial added in v0.0.52

func (d *ExecutorDialer) Dial(ctx context.Context, pin ExecutorPin, port int) (*tls.Conn, error)

Dial resolves the pinned Pod and completes a mutual TLS handshake with it.

func (*ExecutorDialer) Resolve added in v0.0.52

func (d *ExecutorDialer) Resolve(ctx context.Context, pin ExecutorPin) (string, error)

Resolve returns the IP of the executor Pod only while it is the pinned incarnation.

func (*ExecutorDialer) TLSConfig added in v0.0.52

func (d *ExecutorDialer) TLSConfig(pin ExecutorPin) *tls.Config

TLSConfig accepts only the pinned server certificate; CA validation is replaced by the pin.

type ExecutorPin added in v0.0.52

type ExecutorPin struct {
	PodName     string
	PodUID      string
	Fingerprint string
}

ExecutorPin is the server identity the provider accepts from one executor Pod.

func ExecutorPinFromEnvironment added in v0.0.52

func ExecutorPinFromEnvironment(env *unstructured.Unstructured) (ExecutorPin, error)

ExecutorPinFromEnvironment returns the pin recorded for env's current executor Pod.

type ExecutorTransport

type ExecutorTransport interface {
	Execute(context.Context, string, executionenv.ExecutorRequest) (executionenv.ExecutorResponse, error)
}

ExecutorTransport dispatches one request to a fixed workload helper.

type ExecutorTrust added in v0.0.52

type ExecutorTrust struct {
	CASecret        string
	CAKey           string
	ClientConfigMap string
}

ExecutorTrust names the sources executor Pods mount to authenticate the provider's client certificate: a CA bundle key in a Secret and a ConfigMap holding the provider's URI SAN under client-uri.

type Handler

type Handler struct {
	executionv1.UnimplementedExecutionProviderServiceServer
	// contains filtered or unexported fields
}

Handler is the authenticated private execution-provider gRPC service.

func NewHandler

func NewHandler(cfg HandlerConfig, b Backend) *Handler

NewHandler constructs the authenticated private gRPC service.

func (*Handler) AbortReference

func (*Handler) AcquireRun

AcquireRun takes environment-wide execution ownership.

func (*Handler) AttachEnvironment

AttachEnvironment exactly reattaches to a durable reference.

func (*Handler) CancelCommand

CancelCommand authorizes then reports the detached API as unsupported.

func (*Handler) CancelReferenceDelete

func (h *Handler) CancelReferenceDelete(ctx context.Context, q *executionv1.ReferenceMutationRequest) (*emptypb.Empty, error)

func (*Handler) CommandStatus

CommandStatus authorizes then reports the detached API as unsupported.

func (*Handler) CommitReference

func (*Handler) ConfirmReferenceDelete

func (h *Handler) ConfirmReferenceDelete(ctx context.Context, q *executionv1.ReferenceMutationRequest) (*emptypb.Empty, error)

func (*Handler) DeleteRetiredEnvironment

func (h *Handler) DeleteRetiredEnvironment(ctx context.Context, q *executionv1.DeleteRetiredEnvironmentRequest) (*emptypb.Empty, error)

func (*Handler) EnsureTemplate added in v0.0.48

EnsureTemplate allocates a caller-authorized exact template revision.

func (*Handler) Files

Files executes one bounded and authorized filesystem operation.

func (*Handler) ListExecutionTemplates added in v0.0.48

ListExecutionTemplates returns the caller's allowed selectable template catalog.

func (*Handler) PrepareReferenceDelete

func (h *Handler) PrepareReferenceDelete(ctx context.Context, q *executionv1.ReferenceMutationRequest) (*emptypb.Empty, error)

func (*Handler) RecoverEnvironment

func (h *Handler) RecoverEnvironment(ctx context.Context, q *executionv1.RecoverEnvironmentRequest) (*emptypb.Empty, error)

func (*Handler) ReleaseReference

func (h *Handler) ReleaseReference(ctx context.Context, q *executionv1.ReleaseReferenceRequest) (*emptypb.Empty, error)

ReleaseReference releases one authorized durable binding reference.

func (*Handler) ReleaseRun

func (*Handler) ReplaceExecutor

func (h *Handler) ReplaceExecutor(ctx context.Context, q *executionv1.ReplaceExecutorRequest) (*emptypb.Empty, error)

func (*Handler) RetireEnvironment

func (h *Handler) RetireEnvironment(ctx context.Context, q *executionv1.RetireEnvironmentRequest) (*emptypb.Empty, error)

RetireEnvironment starts exact, proof-producing executor retirement while retaining the PVC.

func (*Handler) StartCommand

StartCommand executes one authorized foreground command.

func (*Handler) ValidateTemplate added in v0.0.48

ValidateTemplate resolves a caller-authorized exact template revision.

type HandlerConfig

type HandlerConfig struct {
	Clients     map[string]ClientPolicy
	Ready       func() bool
	Security    *SecurityManager
	Diagnostics port.Diagnostics
}

HandlerConfig configures authenticated client policy.

type PodExecutor

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

PodExecutor invokes the fixed helper in an already-selected executor Pod.

func NewPodExecutor

func NewPodExecutor(config *rest.Config, kube kubernetes.Interface, namespace string) *PodExecutor

NewPodExecutor constructs a namespace-scoped Pod executor transport.

func (*PodExecutor) Execute

Execute runs one bounded helper request in pod.

type Profile

type Profile struct {
	Name, Digest                  string
	MaxFileBytes, MaxCommandBytes int64
	MaxCommandDuration            time.Duration
	Capabilities                  []string
}

Profile is the externally visible immutable execution profile.

type ProfileSpec

type ProfileSpec struct {
	Image                   string              `yaml:"image"`
	StorageClass            string              `yaml:"storageClass"`
	StorageSize             string              `yaml:"storageSize"`
	CPURequest              string              `yaml:"cpuRequest"`
	MemoryRequest           string              `yaml:"memoryRequest"`
	CPULimit                string              `yaml:"cpuLimit"`
	MemoryLimit             string              `yaml:"memoryLimit"`
	EphemeralStorageRequest string              `yaml:"ephemeralStorageRequest"`
	EphemeralStorageLimit   string              `yaml:"ephemeralStorageLimit"`
	TmpSizeLimit            string              `yaml:"tmpSizeLimit"`
	RuntimeClassName        string              `yaml:"runtimeClassName"`
	ImagePullSecrets        []string            `yaml:"imagePullSecrets,omitempty"`
	NodeSelector            map[string]string   `yaml:"nodeSelector,omitempty"`
	Tolerations             []corev1.Toleration `yaml:"tolerations,omitempty"`
	MaxFileBytes            int64               `yaml:"maxFileBytes"`
	MaxCommandBytes         int64               `yaml:"maxCommandBytes"`
	MaxCommandDuration      time.Duration       `yaml:"maxCommandDuration"`
	// Capabilities is the maximum set; absent means every capability.
	Capabilities []string `yaml:"capabilities,omitempty" json:"capabilities"`
}

ProfileSpec defines immutable image, storage, resource, and operation bounds.

type Profiles

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

Profiles is a validated immutable profile registry.

func LoadTemplates added in v0.0.48

func LoadTemplates(path string) (*Profiles, error)

LoadTemplates rejects unknown fields and any revision not matching its v1 canonical execution digest. Display and policy edits do not change revisions.

func (*Profiles) DefaultRevision added in v0.0.48

func (p *Profiles) DefaultRevision(id string) string

DefaultRevision returns the exact operator-pinned revision for an ID.

func (*Profiles) WithExecutorServiceAccount

func (p *Profiles) WithExecutorServiceAccount(name string) *Profiles

WithExecutorServiceAccount sets the chart-owned identity for Pod construction and validation.

func (*Profiles) WithExecutorTrust added in v0.0.52

func (p *Profiles) WithExecutorTrust(trust ExecutorTrust) *Profiles

WithExecutorTrust sets the provider trust sources mounted into executor Pods.

type RPCLimiter

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

RPCLimiter bounds active unary RPCs globally and per authorized client.

func NewRPCLimiter

func NewRPCLimiter(security *SecurityManager, globalMax, clientMax int) (*RPCLimiter, error)

NewRPCLimiter constructs a limiter whose client map is bounded by the security allowlist.

func (*RPCLimiter) UnaryInterceptor

func (l *RPCLimiter) UnaryInterceptor(ctx context.Context, req any, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryInterceptor authenticates against current policy before reserving capacity.

type Reconciler

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

Reconciler maintains executor Pods and retained workspace PVCs.

func NewReconciler

func NewReconciler(d dynamic.Interface, k kubernetes.Interface, namespace string, p *Profiles) *Reconciler

NewReconciler constructs a reconciler for one namespace.

func (*Reconciler) Initialize

func (r *Reconciler) Initialize(ctx context.Context) error

Initialize synchronizes informer caches before the provider may expose mutating APIs. Startup never mutates operation ownership: another replica may still be its live holder.

func (*Reconciler) ReadinessReason

func (r *Reconciler) ReadinessReason() string

ReadinessReason returns a bounded operator-facing reason class.

func (*Reconciler) Ready

func (r *Reconciler) Ready() bool

Ready reports whether startup fencing, profile preflight, and informer synchronization completed.

func (*Reconciler) Reconcile

func (r *Reconciler) Reconcile(ctx context.Context, name string) error

Reconcile converges one ExecutionEnvironment and its runtime resources.

func (*Reconciler) Run

func (r *Reconciler) Run(ctx context.Context) error

Run initializes the reconciler and blocks until shutdown.

func (*Reconciler) WithDiagnostics added in v0.0.52

func (r *Reconciler) WithDiagnostics(d port.Diagnostics) *Reconciler

WithDiagnostics sets the sink for executor certificate lifecycle records.

type SecurityManager

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

SecurityManager reloads one immutable, versioned security snapshot from projected files and binds its generation to a durable ConfigMap high-water mark.

func NewSecurityManager

func NewSecurityManager(manifestPath, keyDirectory, namespace, configMap string, kube kubernetes.Interface) *SecurityManager

NewSecurityManager constructs a fail-closed security material reloader.

func (*SecurityManager) CheckReady

func (m *SecurityManager) CheckReady(ctx context.Context) bool

CheckReady verifies that the loaded snapshot still matches durable authority.

func (*SecurityManager) Ready

func (m *SecurityManager) Ready() bool

Ready reports whether the current snapshot is authoritative and unexpired.

func (*SecurityManager) Reload

func (m *SecurityManager) Reload(ctx context.Context) error

Reload atomically validates and publishes a complete security snapshot.

func (*SecurityManager) Run

func (m *SecurityManager) Run(ctx context.Context, interval time.Duration)

Run periodically reloads security material until ctx is cancelled.

func (*SecurityManager) TLSConfig

func (m *SecurityManager) TLSConfig() *tls.Config

TLSConfig returns a dynamic TLS configuration backed by the current snapshot.

type Store

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

Store persists authorization and fencing state in ExecutionEnvironment status.

func NewStore

func NewStore(client dynamic.Interface, namespace string, profiles *Profiles, executor ExecutorTransport) *Store

NewStore constructs a namespace-scoped execution state store.

func (*Store) AbortReference

func (s *Store) AbortReference(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding, operation string) error

func (*Store) AcquireRun

func (s *Store) AcquireRun(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding, runID, operationID string, ttl time.Duration) (executionenv.RunClaim, error)

func (*Store) Attach

func (s *Store) Attach(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding string) (Allocation, error)

Attach adds a binding reference only to the exact healthy environment.

func (*Store) CancelCommand

CancelCommand refuses cancellation without an attached foreground control stream.

func (*Store) CancelReferenceDelete

func (s *Store) CancelReferenceDelete(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding, operation string) error

func (*Store) CatalogTemplates added in v0.0.48

func (s *Store) CatalogTemplates() []*executionv1.TemplateCatalogItem

CatalogTemplates returns all selectable template revisions.

func (*Store) CommandStatus

CommandStatus reports that foreground-only commands have no detached status API.

func (*Store) CommitReference

func (s *Store) CommitReference(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding, operation string) error

func (*Store) ConfirmReferenceDelete

func (s *Store) ConfirmReferenceDelete(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding, operation string) error

func (*Store) DeleteRetiredEnvironment

func (s *Store) DeleteRetiredEnvironment(ctx context.Context, q adminLifecycleRequest) error

DeleteRetiredEnvironment starts exact deletion of an explicitly retained workspace.

func (*Store) EnsurePendingOwnedRevision added in v0.0.48

func (s *Store) EnsurePendingOwnedRevision(
	ctx context.Context,
	client string,
	expectedOwnerHash string,
	owner executionenv.Owner,
	binding string,
	id string,
	revision string,
	fp string,
	operationID string,
	capabilities []string,
) (Allocation, error)

EnsurePendingOwnedRevision binds an exact eligible definition and admits the requested capabilities against it. Repeated requests for the final binding ID must supply the same revision, fingerprint, and admitted capability set.

func (*Store) File

File performs one claimed and fenced filesystem operation.

func (*Store) FindReferenceIntent

func (s *Store) FindReferenceIntent(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding string) (executionenv.ReferenceIntent, error)

func (*Store) ListReferenceIntents

func (s *Store) ListReferenceIntents(ctx context.Context, client, owner string, limit int) ([]executionenv.ReferenceIntent, error)

func (*Store) ListReferenceIntentsForClient

func (s *Store) ListReferenceIntentsForClient(ctx context.Context, client string, limit int) ([]executionenv.ReferenceIntent, error)

func (*Store) PrepareReferenceDelete

func (s *Store) PrepareReferenceDelete(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding, operation string) error

func (*Store) RecoverEnvironment

func (s *Store) RecoverEnvironment(ctx context.Context, q adminLifecycleRequest) error

RecoverEnvironment clears uncertainty only after built-in exact terminal verification.

func (*Store) ReleaseReference

func (s *Store) ReleaseReference(ctx context.Context, ref executionenv.EnvironmentRef, client, owner, binding string) error

ReleaseReference removes one binding reference without deleting the environment.

func (*Store) ReleaseRun

func (s *Store) ReleaseRun(ctx context.Context, ref executionenv.EnvironmentRef, client, owner string, req executionenv.RunClaimRequest) error

func (*Store) RenewRun

func (*Store) ReplaceExecutor

func (s *Store) ReplaceExecutor(ctx context.Context, q adminLifecycleRequest) error

ReplaceExecutor starts an exact, crash-recoverable executor replacement.

func (*Store) ReserveSuccessor

func (s *Store) ReserveSuccessor(
	ctx context.Context,
	ref executionenv.EnvironmentRef,
	client string,
	owner string,
	source string,
	destination string,
	operation string,
) ([]string, error)

ReserveSuccessor returns the shared environment's admitted capabilities.

func (*Store) RetireExact

func (s *Store) RetireExact(ctx context.Context, q adminLifecycleRequest) error

RetireExact starts exact executor retirement while retaining its workspace.

func (*Store) RevokeEnvironment

func (s *Store) RevokeEnvironment(ctx context.Context, q adminLifecycleRequest, expected uint64) (uint64, error)

RevokeEnvironment atomically invalidates every issued grant without claiming that an already-dispatched executor operation has stopped.

func (*Store) StartCommand

StartCommand performs one claimed foreground command through terminal receipt.

func (*Store) ValidateRunClaim

func (s *Store) ValidateRunClaim(ctx context.Context, client, owner string, rc executionenv.RequestContext) error

ValidateRunClaim checks the durable run, binding, client and current policy before dispatch.

func (*Store) ValidateTemplate added in v0.0.48

func (s *Store) ValidateTemplate(_ context.Context, id, revision string) (Profile, error)

ValidateTemplate resolves one exact selectable template revision.

func (*Store) WithKubeClient

func (s *Store) WithKubeClient(kube kubernetes.Interface) *Store

WithKubeClient enables provider-owned executor and retained-volume lifecycle operations.

func (*Store) WithSecurityManager added in v0.0.48

func (s *Store) WithSecurityManager(security *SecurityManager) *Store

WithSecurityManager fences active work when its client loses current policy authority.

type TemplateDefinition added in v0.0.48

type TemplateDefinition struct {
	Default         string                      `yaml:"default"`
	MaxEnvironments int                         `yaml:"maxEnvironments"`
	Revisions       map[string]TemplateRevision `yaml:"revisions"`
}

TemplateDefinition is the operator-owned template and revision declaration.

type TemplateDisplay added in v0.0.48

type TemplateDisplay struct {
	Name        string                       `yaml:"name,omitempty" json:"name,omitempty"`
	Description string                       `yaml:"description,omitempty" json:"description,omitempty"`
	Extensions  map[string]map[string]string `yaml:"extensions,omitempty" json:"extensions,omitempty"`
}

TemplateDisplay is inert operator-authored data, never injected into prompts. Extensions are bounded, versioned, namespaced string maps for client display.

type TemplatePolicy added in v0.0.48

type TemplatePolicy struct {
	Deprecated bool
	Revoked    bool
}

TemplatePolicy describes whether a revision remains selectable or retained only.

type TemplateRevision added in v0.0.48

type TemplateRevision struct {
	Execution  ProfileSpec     `yaml:"execution"`
	Deprecated bool            `yaml:"deprecated,omitempty"`
	Revoked    bool            `yaml:"revoked,omitempty"`
	Display    TemplateDisplay `yaml:"display,omitempty"`
}

TemplateRevision is one immutable execution definition and its lifecycle policy.

type TemplatesFile added in v0.0.48

type TemplatesFile struct {
	Templates map[string]TemplateDefinition `yaml:"templates"`
}

TemplatesFile is the single operator-owned execution definition source. A published revision must remain in this file while any allocation retains it.

Jump to

Keyboard shortcuts

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