containerd

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBuildKitAddr = "unix:///run/buildkit/buildkitd.sock"

DefaultBuildKitAddr is the buildkitd control socket the bootstrap installs.

Variables

This section is empty.

Functions

func IsParkedContainerLabels

func IsParkedContainerLabels(labels map[string]string) bool

IsParkedContainerLabels reports warm-pool park inventory for ListManaged.

func IsParkedSandboxID

func IsParkedSandboxID(id string) bool

IsParkedSandboxID reports park-<hex> slot ids.

func PublishEngineTag

func PublishEngineTag(engine string)

PublishEngineTag stamps the host engine into expvar for operator dashboards.

Types

type BuildKitBuilder

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

BuildKitBuilder builds images for the containerd engine by shelling out to `buildctl` against a local buildkitd whose containerd worker writes into the aerolvm namespace. It satisfies the same ImageBuilder seam as the dockerd build path (BuildImage(ctx, docker.BuildImageRequest)), so the v1/daytona build handlers work unchanged once the engine-gate is lifted.

buildctl is used instead of the moby/buildkit Go client to avoid pulling buildkit's large dependency tree into the daemon; buildctl ships alongside buildkitd from the same release.

func NewBuildKitBuilder

func NewBuildKitBuilder(addr, buildctlPath string, logger *slog.Logger) *BuildKitBuilder

NewBuildKitBuilder returns a builder targeting addr (default DefaultBuildKitAddr). buildctlPath defaults to "buildctl" on PATH.

func (*BuildKitBuilder) BuildImage

func (b *BuildKitBuilder) BuildImage(ctx context.Context, req docker.BuildImageRequest) error

BuildImage builds req.DockerfileContent (+ optional context tar) into an image tagged req.Tag, exported and unpacked into the containerd image store so a later create can run it directly.

type Client

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

Client wraps a namespaced containerd connection.

func Connect

func Connect(socket, namespace string) (*Client, error)

Connect dials the system containerd socket and scopes to namespace.

func NewTestClient

func NewTestClient(namespace string, tr clientTransport) *Client

NewTestClient wires a fake or stub transport for unit tests.

func (*Client) Close

func (c *Client) Close() error

func (*Client) ContentStore

func (c *Client) ContentStore() content.Store

ContentStore exposes the backing content store for image config reads.

func (*Client) GetImage

func (c *Client) GetImage(ctx context.Context, ref string) (cntr.Image, error)

func (*Client) ListContainers

func (c *Client) ListContainers(ctx context.Context, filters ...string) ([]cntr.Container, error)

func (*Client) LoadContainer

func (c *Client) LoadContainer(ctx context.Context, id string) (cntr.Container, error)

func (*Client) Namespace

func (c *Client) Namespace() string

func (*Client) NewContainer

func (c *Client) NewContainer(ctx context.Context, id string, opts ...cntr.NewContainerOpts) (cntr.Container, error)

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) PullImage

func (c *Client) PullImage(ctx context.Context, ref string, opts ...cntr.RemoteOpt) (cntr.Image, error)

func (*Client) Raw

func (c *Client) Raw() *cntr.Client

func (*Client) SubscribeEvents

func (c *Client) SubscribeEvents(ctx context.Context, filters ...string) (<-chan *events.Envelope, <-chan error)

type Config

type Config struct {
	Socket             string
	Namespace          string
	ToolboxBinaryPath  string
	ToolboxMountPath   string
	ToolboxPort        int
	Privileged         bool
	ResourceLimitsOff  bool
	DefaultRuntime     string
	WaitTimeout        time.Duration
	ToolboxWaitTimeout time.Duration
	ReadyEnabled       bool
	ReadyDir           string
	ReadinessPollInit  time.Duration
	ReadinessPollMax   time.Duration
	PullMaxConcurrent  int
	PullFailureBackoff time.Duration
	HTTPClientTimeout  time.Duration
	LogDir             string
	RunDir             string
	NativeNetnsPool    bool
}

Config holds containerd-driver settings projected from daemon config.

func FromDaemonConfig

func FromDaemonConfig(cfg config.Config) Config

FromDaemonConfig maps internal config into driver-local settings.

type Driver

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

Driver implements runtime.ContainerRuntime against a local containerd.

func New

func New(cfg Config, rules *netrules.Manager, logger *slog.Logger) *Driver

New constructs a Driver. The containerd connection is lazy — Ping and Create establish it on first use so unit tests can inject a fake client.

func (*Driver) ApplyEgressPolicy

func (d *Driver) ApplyEgressPolicy(containerIP string, allowCIDRs, denyCIDRs []string) error

func (*Driver) ApplyNetworkBlockAll

func (d *Driver) ApplyNetworkBlockAll(containerIP string) error

func (*Driver) ApplyNetworkBlockIngress

func (d *Driver) ApplyNetworkBlockIngress(containerIP string) error

func (*Driver) ClearEgressPolicy

func (d *Driver) ClearEgressPolicy(containerIP string, allowCIDRs, denyCIDRs []string) error

func (*Driver) ClearNetworkBlockEgress

func (d *Driver) ClearNetworkBlockEgress(containerIP string) error

func (*Driver) ClearNetworkBlockIngress

func (d *Driver) ClearNetworkBlockIngress(containerIP string) error

func (*Driver) ClearNetworkRules

func (d *Driver) ClearNetworkRules(containerIP string) error

func (*Driver) ContainerPID

func (d *Driver) ContainerPID(ctx context.Context, containerRef string) (int, error)

ContainerPID returns the init PID for a running task. "Not running here" (no container / no task) is (0, nil) so the events mux can fall through to the other engine; genuine lookup failures propagate so netstats diagnostics aren't silently swallowed.

func (*Driver) Create

func (d *Driver) Create(ctx context.Context, req models.CreateSandboxRequest, sandboxID, toolboxToken string, hostMounts []mounts.ContainerBind) (*models.SandboxRuntimeState, error)

Create provisions and starts a managed task in the aerolvm namespace.

func (*Driver) CreateSnapshot

func (d *Driver) CreateSnapshot(ctx context.Context, containerRef, imageRef string) (string, error)

CreateSnapshot commits a running task filesystem into a new image in the aerolvm namespace (plans/containerd-engine.md Phase 3).

func (*Driver) Destroy

func (d *Driver) Destroy(ctx context.Context, sandbox *models.Sandbox) error

func (*Driver) ImageExists

func (d *Driver) ImageExists(ctx context.Context, imageRef string) (bool, error)

ImageExists reports whether imageRef resolves to a local image in the containerd store WITHOUT pulling. Used by the build handlers' cache short-circuit (a freshly built tag) and mirrors ensureImage's local-ref resolution (exact ref first, then :latest for a tagless local ref) so a tag committed as "name:latest" is recognised when referenced as "name".

func (*Driver) Inspect

func (d *Driver) Inspect(ctx context.Context, containerRef string) (*models.SandboxRuntimeState, error)

func (*Driver) ListManaged

func (d *Driver) ListManaged(ctx context.Context) (map[string]*models.SandboxRuntimeState, error)

func (*Driver) Ping

func (d *Driver) Ping(ctx context.Context) error

Ping verifies containerd is reachable.

func (*Driver) PurgeParkedContainers

func (d *Driver) PurgeParkedContainers(ctx context.Context) (int, error)

PurgeParkedContainers destroys park-labeled containers left from a prior run.

func (*Driver) PushAllowedPorts

func (d *Driver) PushAllowedPorts(ctx context.Context, containerIP, toolboxToken string, ports []int) error

func (*Driver) RemoveImage

func (d *Driver) RemoveImage(ctx context.Context, imageRef string) error

func (*Driver) Resize

func (d *Driver) Resize(ctx context.Context, containerRef string, req models.ResizeSandboxRequest) error

func (*Driver) SetClient

func (d *Driver) SetClient(c *Client)

func (*Driver) SetNetnsHandoff

func (d *Driver) SetNetnsHandoff(h NetnsHandoff)

SetNetnsHandoff wires the native netns pool (Phase 2). Nil disables it.

func (*Driver) SetWarmPool

func (d *Driver) SetWarmPool(p WarmPool)

SetWarmPool wires the containerd warm pool (Phase 3). Nil disables it.

func (*Driver) Start

func (d *Driver) Start(ctx context.Context, containerRef string) (*models.SandboxRuntimeState, error)

func (*Driver) Stop

func (d *Driver) Stop(ctx context.Context, containerRef string) error

func (*Driver) StreamEvents

func (d *Driver) StreamEvents(ctx context.Context, out chan<- docker.DockerEvent) error

StreamEvents subscribes to containerd task lifecycle events for managed workloads and normalizes them into docker.DockerEvent for the service event monitor.

type ImageBuilder

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

ImageBuilder is the full image-builder surface the v1 / daytona build handlers require for the containerd engine. It composes the buildctl-backed BuildImage with the driver's containerd-native image operations (ImageExists / RemoveImage) and the registry pusher, so it is a drop-in for the same seam the dockerd path satisfies with *pkg/docker.Client.

func NewImageBuilder

func NewImageBuilder(driver *Driver, build *BuildKitBuilder) *ImageBuilder

NewImageBuilder wires a containerd image builder from a driver (image store + registry push) and a buildkit builder (Dockerfile compile).

func (*ImageBuilder) BuildImage

func (b *ImageBuilder) BuildImage(ctx context.Context, req docker.BuildImageRequest) error

func (*ImageBuilder) ImageExists

func (b *ImageBuilder) ImageExists(ctx context.Context, imageRef string) (bool, error)

func (*ImageBuilder) PushImage

func (b *ImageBuilder) PushImage(ctx context.Context, req docker.PushImageRequest) (string, error)

func (*ImageBuilder) RefreshTag

func (b *ImageBuilder) RefreshTag(ctx context.Context, fullRef string) error

RefreshTag is a no-op on containerd. The dockerd builder bumps Metadata.LastTagTime so its built-image janitor doesn't GC a cache-hit tag; containerd's built-image lifecycle is snapshot/lease-driven, not tag-time metadata, so there is nothing to refresh.

func (*ImageBuilder) RemoveImage

func (b *ImageBuilder) RemoveImage(ctx context.Context, imageRef string) error

type NetnsHandoff

type NetnsHandoff interface {
	Provision(ctx context.Context, sandboxID string) (netnsPath, containerIP string, err error)
	Release(ctx context.Context, sandboxID string) error
	// ReassignOwner moves adopted slot ownership from a park slot id to the
	// real sandbox id after warm adopt (rename-free).
	ReassignOwner(ctx context.Context, fromSandboxID, toSandboxID string) error
}

NetnsHandoff provisions a prepaid network namespace for containerd creates. When nil, the driver uses containerd's default network namespace (host/default).

type PoolSpawner

type PoolSpawner struct {
	Driver *Driver
}

PoolSpawner implements containerdpool.Spawner against the containerd driver.

func (*PoolSpawner) DestroyParked

func (p *PoolSpawner) DestroyParked(ctx context.Context, slot *containerdpool.ParkedSlot) error

func (*PoolSpawner) Park

type RegistryPusher

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

RegistryPusher pushes local aerolvm-namespace images to a remote registry (AOCR snapshot path). Implements service.SnapshotPushDocker so the existing SnapshotPusher / reconciler work unchanged under SB_CONTAINER_ENGINE=containerd.

func NewRegistryPusher

func NewRegistryPusher(d *Driver) *RegistryPusher

NewRegistryPusher returns a SnapshotPushDocker backed by the containerd driver.

func (*RegistryPusher) PushImage

func (p *RegistryPusher) PushImage(ctx context.Context, req docker.PushImageRequest) (string, error)

PushImage tags SourceTag as DestRef in the aerolvm namespace and pushes it.

type WarmPool

type WarmPool interface {
	HasReady(key containerdpool.Key) bool
	Acquire(ctx context.Context, key containerdpool.Key, imageID string) (*containerdpool.ParkedSlot, error)
	NoteMiss(key containerdpool.Key)
	ReleasePark(slotID string)
}

WarmPool is the Phase 3 park/adopt seam. Nil disables warm acquisition.

Jump to

Keyboard shortcuts

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