nodeexec

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrStaleFence means a request came from an older leader term.
	ErrStaleFence = errors.New("stale leader fence")
	// ErrFenceConflict means two leader IDs claimed the same term.
	ErrFenceConflict = errors.New("conflicting leader fence")
	// ErrPersistence means durable state could not be read or written.
	ErrPersistence = errors.New("agent state persistence failed")
	// ErrExecution means a validated Compose plan failed to execute.
	ErrExecution = errors.New("compose execution failed")
)
View Source
var ErrStoppedAssignmentUnsupported = errors.New("STOPPED assignments are unsupported")

ErrStoppedAssignmentUnsupported means STOPPED is outside this executor's approved Compose command surface.

Functions

func CommandsToProto

func CommandsToProto(commands []Command) []*deployv1.Command

CommandsToProto returns isolated wire commands for a plan or snapshot.

Types

type Command

type Command struct {
	Argv []string `json:"argv"`
}

Command is a directly executed argv vector. It is never interpreted by a shell.

type ComposeInvocation

type ComposeInvocation struct {
	Argv      []string
	Directory string
}

ComposeInvocation is a direct Docker Compose process invocation.

type DockerComposeRunner

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

DockerComposeRunner invokes the Docker CLI directly, constrained to one resolved workspace root.

func NewDockerComposeRunner

func NewDockerComposeRunner(
	launcher proc.ILauncher,
	dockerBin, workspace, revisionRoot string,
	revisionLimits *deployv1.RevisionLimits,
	dryRun bool,
	options ...DockerComposeRunnerOption,
) (*DockerComposeRunner, error)

NewDockerComposeRunner validates the workspace and, outside dry-run mode, verifies that the Docker CLI is available. Every child process, Git and Compose alike, starts through launcher.

func NewDockerComposeRunnerWithSourceSync

func NewDockerComposeRunnerWithSourceSync(
	launcher proc.ILauncher,
	dockerBin, workspace, revisionRoot string,
	revisionLimits *deployv1.RevisionLimits,
	sourceSync *deployv1.SourceSync,
	logger *telemetry.JSONLLogger,
	dryRun bool,
	options ...DockerComposeRunnerOption,
) (*DockerComposeRunner, error)

NewDockerComposeRunnerWithSourceSync is NewDockerComposeRunner with an optional read-only Git remote used to acquire approved commits.

func (*DockerComposeRunner) DryRun

func (r *DockerComposeRunner) DryRun() bool

DryRun reports whether command execution is disabled.

func (*DockerComposeRunner) Execute

func (r *DockerComposeRunner) Execute(ctx context.Context, plan Plan) error

Execute validates the internally generated plan, runs `docker compose config --quiet`, and only then runs the convergence command. Dry-run mode performs the same read-only Compose validation but never reaches the mutating command.

func (*DockerComposeRunner) Plan

func (r *DockerComposeRunner) Plan(ctx context.Context, assignment *deployv1.Assignment) (Plan, error)

Plan returns the exact approved Compose command plan for one running assignment. STOPPED fails closed because its required Compose mutation is outside the executor's approved command surface.

func (*DockerComposeRunner) Workspace

func (r *DockerComposeRunner) Workspace() string

Workspace returns the canonical workspace path.

type DockerComposeRunnerOption

type DockerComposeRunnerOption func(dependencies *dockerComposeRunnerDependencies)

DockerComposeRunnerOption replaces an owned process-boundary dependency.

func WithComposeProcessExecutor

func WithComposeProcessExecutor(executor IComposeProcessExecutor) DockerComposeRunnerOption

WithComposeProcessExecutor supplies the Docker Compose process boundary. It is primarily useful when embedding the runner or testing command policy.

type FileStore

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

FileStore atomically and durably stores one JSON state record.

func NewFileStore

func NewFileStore(path string) *FileStore

NewFileStore constructs a file-backed state store.

func (*FileStore) Load

func (s *FileStore) Load() (Snapshot, bool, error)

Load reads the current state, reporting ok=false when it does not exist.

func (*FileStore) Save

func (s *FileStore) Save(snapshot Snapshot) error

Save writes state through a same-directory temporary file, fsync, rename, and directory fsync. A crash cannot expose a partially written fence.

type IComposeProcessExecutor

type IComposeProcessExecutor interface {
	Resolve(executable string) (string, error)
	Run(ctx context.Context, invocation ComposeInvocation) (string, error)
}

IComposeProcessExecutor is the operating-system process boundary for Docker Compose. DockerComposeRunner owns command policy; implementations only resolve and execute the complete invocation they receive.

type IExecutor

type IExecutor interface {
	Plan(ctx context.Context, assignment *deployv1.Assignment) (Plan, error)
	Execute(ctx context.Context, plan Plan) error
	DryRun() bool
	Workspace() string
}

IExecutor validates, plans, and executes a Compose reconciliation.

type IStore

type IStore interface {
	Load() (Snapshot, bool, error)
	Save(snapshot Snapshot) error
}

IStore persists a reconciliation snapshot.

type MemoryStore

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

MemoryStore is a concurrent in-memory store used by tests and embedders.

func (*MemoryStore) Load

func (s *MemoryStore) Load() (Snapshot, bool, error)

func (*MemoryStore) Save

func (s *MemoryStore) Save(snapshot Snapshot) error

type Plan

type Plan struct {
	Commands []Command `json:"commands"`
}

Plan is a validated preflight plus convergence command.

type Reconciler

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

Reconciler serializes node mutations, fences leaders, and persists state.

func NewReconciler

func NewReconciler(store IStore, executor IExecutor) (*Reconciler, error)

NewReconciler restores durable state before accepting requests.

func (*Reconciler) DryRun

func (r *Reconciler) DryRun() bool

DryRun reports the executor mode.

func (*Reconciler) Reconcile

Reconcile validates and applies one request. The highest new fence is saved before any Docker command is allowed to run.

func (*Reconciler) Snapshot

func (r *Reconciler) Snapshot() Snapshot

Snapshot returns an isolated copy of current in-memory state.

func (*Reconciler) Workspace

func (r *Reconciler) Workspace() string

Workspace returns the executor's canonical workspace.

type Snapshot

type Snapshot struct {
	Fence      *deployv1.Fence
	Assignment *deployv1.Assignment
	Commands   []Command
	UpdatedAt  time.Time
}

Snapshot is the node-local durable reconciliation record.

Directories

Path Synopsis
Package client is deploy's transport to one node agent.
Package client is deploy's transport to one node agent.

Jump to

Keyboard shortcuts

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