edgelet

package
v1.0.0-rc.11 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: EPL-2.0 Imports: 45 Imported by: 0

Documentation

Overview

Package edgelet implements the ContainerEngine interface using the embedded containerd runtime. It communicates directly with the in-process containerd via the containerd Go client (not the Docker SDK), connecting to the private socket at /run/edgelet/containerd.sock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine implements engine.ContainerEngine using the embedded containerd.

func New

func New(logDir string) *Engine

New returns an uninitialised iofog engine. logDir is the directory to write per-container log files to.

func (*Engine) AreMicroserviceAndContainerEqual

func (e *Engine) AreMicroserviceAndContainerEqual(containerID string, ms *models.Microservice, registry *models.Registry) bool

AreMicroserviceAndContainerEqual returns true if the running container's configuration matches the desired microservice spec. It compares:

  1. Image name
  2. Environment variables (set equality)
  3. Port mappings (from persisted label vs desired) — skipped for host-network mode
  4. Network mode (host vs bridge)

func (*Engine) Close

func (e *Engine) Close() error

Close releases the containerd and CRI clients.

func (*Engine) CreateContainer

func (e *Engine) CreateContainer(ms *models.Microservice, hostname string) (string, error)

CreateContainer creates the container via CRI: RunPodSandbox (CNI managed by containerd) then CreateContainer. It does NOT start the container — that is deferred to StartContainer.

func (*Engine) CreateExecSession

func (e *Engine) CreateExecSession(containerID string, runtimeExecID string, cmd []string) (string, error)

CreateExecSession validates the container, builds the exec process spec, and stores it as a pending exec. runtimeExecID must be unique per container (e.g. {cid[:12]}-exec-{session[:8]}). The process is NOT started yet — call StartExecSession to attach I/O and launch.

func (*Engine) DeleteImage

func (e *Engine) DeleteImage(_ context.Context, nameOrID string) error

DeleteImage removes an image from the iofog containerd namespace by name or digest.

func (*Engine) EnsureNetwork

func (e *Engine) EnsureNetwork(_ string) error

func (*Engine) ExecWithExitCode

func (e *Engine) ExecWithExitCode(containerID string, cmd []string, timeout time.Duration) (int, error)

ExecWithExitCode runs a command in the container and returns the exit code. Used for healthcheck execution. Returns (exitCode, error). On timeout, kills the process and returns (-1, context.DeadlineExceeded).

func (*Engine) FindLocalImage

func (e *Engine) FindLocalImage(imageRef, registryURL string, fromCache bool) (bool, error)

func (*Engine) GetAllContainers

func (e *Engine) GetAllContainers() ([]engine.Container, error)

func (*Engine) GetContainer

func (e *Engine) GetContainer(microserviceUUID string) (*engine.Container, error)

func (*Engine) GetContainerByID

func (e *Engine) GetContainerByID(containerID string) (*engine.Container, error)

func (*Engine) GetContainerIPAddress

func (e *Engine) GetContainerIPAddress(containerID string) (string, error)

GetContainerIPAddress returns the container's IP from the in-memory state map, falling back to the persisted label for recovery after an agent restart.

func (*Engine) GetContainerMicroserviceUUID

func (e *Engine) GetContainerMicroserviceUUID(cont engine.Container) string

func (*Engine) GetContainerName

func (e *Engine) GetContainerName(cont engine.Container) string

func (*Engine) GetContainerSandboxID

func (e *Engine) GetContainerSandboxID(containerID string) (string, error)

func (*Engine) GetContainerStartedAt

func (e *Engine) GetContainerStartedAt(containerID string) (int64, error)

GetContainerStartedAt returns the Unix-millisecond timestamp when the container was last started, from the in-memory state or the persisted label.

func (*Engine) GetContainerStats

func (e *Engine) GetContainerStats(containerID string) (*engine.ContainerStats, error)

GetContainerStats returns live CPU and memory usage for the container. It uses a two-sample approach for CPU percentage: the first call returns 0% CPU while storing the baseline; subsequent calls compute the delta.

func (*Engine) GetContainerStatus

func (e *Engine) GetContainerStatus(containerID, _ string) (*models.MicroserviceStatus, error)

func (*Engine) GetExecSessionExitCode

func (e *Engine) GetExecSessionExitCode(execID string) (int, error)

GetExecSessionExitCode reports the exit code for a completed exec process.

func (*Engine) GetExecSessionStatus

func (e *Engine) GetExecSessionStatus(execID string) (bool, error)

GetExecSessionStatus reports whether the exec process for execID is still running.

func (*Engine) GetRunningContainers

func (e *Engine) GetRunningContainers() ([]engine.Container, error)

func (*Engine) Init

func (e *Engine) Init(cfg engine.EngineConfig) error

Init connects to the embedded containerd socket, initializes CNI, and recovers per-container state from existing container labels.

func (*Engine) InspectContainerRaw

func (e *Engine) InspectContainerRaw(containerID string) (map[string]any, error)

func (*Engine) KillContainer

func (e *Engine) KillContainer(containerID string) error

KillContainer forcefully terminates the container task.

func (*Engine) ListImages

func (e *Engine) ListImages(_ context.Context) ([]engine.ImageInfo, error)

ListImages returns all images available in the iofog containerd namespace.

func (*Engine) LoadImageFromPath

func (e *Engine) LoadImageFromPath(_ context.Context, archivePath string) ([]engine.LoadedImage, error)

func (*Engine) PruneContainers

func (e *Engine) PruneContainers(_ context.Context) (*engine.ContainerPruneReport, error)

func (*Engine) PruneDangling

func (e *Engine) PruneDangling(_ context.Context) (*engine.ImagePruneReport, error)

PruneDangling removes images with no active containers referencing them and no tags, docker system prune --filter dangling=true semantics.

func (*Engine) PruneImages

func (e *Engine) PruneImages() error

PruneImages deletes images that are not referenced by any existing container.

func (*Engine) PruneVolumes

func (e *Engine) PruneVolumes(_ context.Context) (*engine.VolumePruneReport, error)

func (*Engine) PullImage

func (e *Engine) PullImage(imageRef string, registry *models.Registry, opts *engine.PullImageOptions) error

func (*Engine) RemoveContainer

func (e *Engine) RemoveContainer(containerID string, _ bool) error

RemoveContainer stops and removes the container via CRI, then tears down the pod sandbox. CRI handles CNI teardown in the correct order (StopPodSandbox triggers CNI DEL).

func (*Engine) RemoveImage

func (e *Engine) RemoveImage(imageRef string) error

func (*Engine) RemoveNamedVolume

func (e *Engine) RemoveNamedVolume(_ context.Context, name string) error

func (*Engine) ResizeExecSession

func (e *Engine) ResizeExecSession(execID string, cols, rows uint32) error

ResizeExecSession resizes a running tty exec process.

func (*Engine) StartContainer

func (e *Engine) StartContainer(containerID string) error

StartContainer starts the container via CRI. CRI manages logs; we only record start time.

func (*Engine) StartExecSession

func (e *Engine) StartExecSession(execID string, stdin io.Reader, stdout, stderr io.Writer) error

StartExecSession looks up the pending exec registered by CreateExecSession, wires stdin/stdout/stderr pipes to the container, and starts the process. Blocks until the process exits so the caller only fires OnComplete() when the shell actually ends.

func (*Engine) StopContainer

func (e *Engine) StopContainer(containerID string) error

StopContainer stops the container via CRI (SIGTERM, then SIGKILL after timeout).

func (*Engine) StopExecSession

func (e *Engine) StopExecSession(execID string) error

StopExecSession kills the running exec process, waits for exit, and deregisters it from containerd.

func (*Engine) SweepOrphanExecSessions

func (e *Engine) SweepOrphanExecSessions(containerID string, keepRuntimeExecIDs map[string]struct{}) error

SweepOrphanExecSessions stops interactive exec processes tracked for containerID that are not in keepRuntimeExecIDs.

func (*Engine) TailContainerLogs

func (e *Engine) TailContainerLogs(containerID, sessionID, microserviceUUID string, handler engine.LogTailHandler, cfg *engine.TailConfig) error

TailContainerLogs streams log lines from the CRI container log file. Containerd CRI writes both stdout and stderr to a single file (0.log) with CRI format: "timestamp stream flag message". We parse and dispatch by stream. Falls back to stdout.log/stderr.log if 0.log is absent.

Directories

Path Synopsis
Package cri provides a CRI client wrapper for the iofog engine.
Package cri provides a CRI client wrapper for the iofog engine.

Jump to

Keyboard shortcuts

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