runtime

package
v0.0.0-...-9285160 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContainerRuntime

type ContainerRuntime interface {
	PullImage(ctx context.Context, imageRef string) error
	StartPlugin(ctx context.Context, plugin *models.Plugin, env map[string]string, diskPaths map[string]string) (containerID string, err error)
	StartCandidatePlugin(ctx context.Context, plugin *models.Plugin, env map[string]string, diskPaths map[string]string) (containerID string, err error)
	StopPlugin(ctx context.Context, containerID string) error
	// StopPluginPod stops and removes ALL containers belonging to a plugin pod
	// (api + sidecars), iterating over plugin.GetEffectiveContainers() and using
	// the deterministic container name. Safe to call when only some containers
	// exist; missing containers are treated as success.
	StopPluginPod(ctx context.Context, plugin *models.Plugin) error
	StartManagedContainer(ctx context.Context, mc *models.ManagedContainer, baseDomain string, diskMounts []ResolvedDiskMount) (containerID string, err error)
	HealthCheck(ctx context.Context, containerID string) (running bool, err error)
	// ResolveContainerID looks up the actual Docker container ID for a plugin
	// by its deterministic name (teamagentica-plugin-{pluginID}). Returns the
	// container ID and running state, or an error if no container exists.
	ResolveContainerID(ctx context.Context, pluginID string) (containerID string, running bool, err error)
	ContainerLogs(ctx context.Context, containerID string, tail int) (string, error)
	SelfContainerID() string
	UIContainerID(ctx context.Context) (string, error)
}

ContainerRuntime is the interface for managing plugin and workspace containers. Implementations include DockerRuntime, with future adapters for Podman, k8s, macOS Virtualization.framework, etc.

type DockerRuntime

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

DockerRuntime manages plugin containers via the Docker API.

func NewDockerRuntime

func NewDockerRuntime(networkName, dataDir string, certManager *certs.CertManager, rtCfg *runtimecfg.Config, baseDomain string) (*DockerRuntime, error)

NewDockerRuntime creates a Docker client from environment and ensures the network exists. Returns nil runtime (not an error) if Docker is unavailable, so the kernel can still start without Docker. The certManager parameter is optional; pass nil to disable mTLS cert injection.

func (*DockerRuntime) ContainerLogs

func (d *DockerRuntime) ContainerLogs(ctx context.Context, containerID string, tail int) (string, error)

ContainerLogs returns the last N lines of a container's logs.

func (*DockerRuntime) HealthCheck

func (d *DockerRuntime) HealthCheck(ctx context.Context, containerID string) (bool, error)

HealthCheck returns true if the container is in the "running" state.

func (*DockerRuntime) PullImage

func (d *DockerRuntime) PullImage(ctx context.Context, imageRef string) error

PullImage pulls a Docker image if it doesn't exist locally. For teamagentica-* images, it tries the self-hosted container registry first, falling back to the local daemon / Docker Hub.

func (*DockerRuntime) ResolveContainerID

func (d *DockerRuntime) ResolveContainerID(ctx context.Context, pluginID string) (string, bool, error)

ResolveContainerID looks up the actual container ID for a plugin by its deterministic name. This reconciles stale container IDs after kernel restarts where containers were recreated with new Docker IDs.

func (*DockerRuntime) SelfContainerID

func (d *DockerRuntime) SelfContainerID() string

SelfContainerID returns the Docker container ID of the kernel itself. Returns empty string if discovery failed.

func (*DockerRuntime) StartCandidatePlugin

func (d *DockerRuntime) StartCandidatePlugin(ctx context.Context, plugin *models.Plugin, env map[string]string, diskPaths map[string]string) (string, error)

StartCandidatePlugin starts a candidate container alongside the primary. Uses the same logic as StartPlugin but with a "-candidate" container name suffix so both containers can coexist on the same network.

func (*DockerRuntime) StartManagedContainer

func (d *DockerRuntime) StartManagedContainer(ctx context.Context, mc *models.ManagedContainer, baseDomain string, diskMounts []ResolvedDiskMount) (string, error)

StartManagedContainer creates and starts a container on behalf of a plugin. Unlike StartPlugin, managed containers have no mTLS or plugin SDK env vars — just volume mounts and docker-proxy labels for subdomain routing.

func (*DockerRuntime) StartPlugin

func (d *DockerRuntime) StartPlugin(ctx context.Context, plugin *models.Plugin, env map[string]string, diskPaths map[string]string) (string, error)

StartPlugin creates and starts the plugin's pod of containers. Returns the api container's Docker ID (kernel uses it as the canonical ContainerID for back-compat with single-container code paths). All container IDs are also persisted on the plugin via SetContainerIDs.

Multi-container plugins are described by plugin.GetEffectiveContainers(). Legacy single-container plugins synthesize a single api container from the top-level Image / DockerLabels / ExtraPorts fields, so this path handles both shapes uniformly.

TODO: K8s adapter — a teamagentica plugin maps 1:1 to a native pod, so the adapter should translate ContainerSpec[] into pod.spec.containers[] and the kernel-managed network membership into pod metadata only.

func (*DockerRuntime) StopPlugin

func (d *DockerRuntime) StopPlugin(ctx context.Context, containerID string) error

StopPlugin stops and removes a container but keeps its data volume. If the container no longer exists (already removed/crashed), this is treated as success — the container is already gone.

func (*DockerRuntime) StopPluginPod

func (d *DockerRuntime) StopPluginPod(ctx context.Context, plugin *models.Plugin) error

StopPluginPod stops every container in a plugin's pod (api + sidecars) in reverse declaration order so sidecars depending on the api shut down first. Containers that don't exist (already removed/crashed) are treated as success.

TODO: K8s adapter — pod deletion is a single API call.

func (*DockerRuntime) UIContainerID

func (d *DockerRuntime) UIContainerID(ctx context.Context) (string, error)

UIContainerID finds the web-dashboard container by well-known name. Checks for "teamagentica-web-dashboard-dev" (dev) and "teamagentica-web-dashboard" (prod).

type ResolvedDiskMount

type ResolvedDiskMount struct {
	HostPath string
	Target   string
	ReadOnly bool
}

ResolvedDiskMount is a disk mount with its host path already resolved via storage-disk.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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