Documentation
¶
Index ¶
- Constants
- func IsParkedContainerLabels(labels map[string]string) bool
- func IsParkedSandboxID(id string) bool
- func PublishEngineTag(engine string)
- type BuildKitBuilder
- type Client
- func (c *Client) Close() error
- func (c *Client) ContentStore() content.Store
- func (c *Client) GetImage(ctx context.Context, ref string) (cntr.Image, error)
- func (c *Client) ListContainers(ctx context.Context, filters ...string) ([]cntr.Container, error)
- func (c *Client) LoadContainer(ctx context.Context, id string) (cntr.Container, error)
- func (c *Client) Namespace() string
- func (c *Client) NewContainer(ctx context.Context, id string, opts ...cntr.NewContainerOpts) (cntr.Container, error)
- func (c *Client) Ping(ctx context.Context) error
- func (c *Client) PullImage(ctx context.Context, ref string, opts ...cntr.RemoteOpt) (cntr.Image, error)
- func (c *Client) Raw() *cntr.Client
- func (c *Client) SubscribeEvents(ctx context.Context, filters ...string) (<-chan *events.Envelope, <-chan error)
- type Config
- type Driver
- func (d *Driver) ApplyEgressHold(containerIP string) error
- func (d *Driver) ApplyEgressPolicy(containerIP string, allowCIDRs, denyCIDRs []string) error
- func (d *Driver) ApplyNetworkBlockAll(containerIP string) error
- func (d *Driver) ApplyNetworkBlockAllReport(containerIP string) (bool, error)
- func (d *Driver) ApplyNetworkBlockIngress(containerIP string) error
- func (d *Driver) ClearEgressHold(containerIP string) error
- func (d *Driver) ClearEgressPolicy(containerIP string, allowCIDRs, denyCIDRs []string) error
- func (d *Driver) ClearNetworkBlockEgress(containerIP string) error
- func (d *Driver) ClearNetworkBlockIngress(containerIP string) error
- func (d *Driver) ClearNetworkRules(containerIP string) error
- func (d *Driver) ConfigureAOCRPullAuth(hosts []string, clusterID, patPath string)
- func (d *Driver) ContainerPID(ctx context.Context, containerRef string) (int, error)
- func (d *Driver) Create(ctx context.Context, req models.CreateSandboxRequest, ...) (*models.SandboxRuntimeState, error)
- func (d *Driver) CreateSnapshot(ctx context.Context, containerRef, imageRef string) (string, error)
- func (d *Driver) Destroy(ctx context.Context, sandbox *models.Sandbox) error
- func (d *Driver) ExportImageArchive(ctx context.Context, imageRef string, w io.Writer) (bool, error)
- func (d *Driver) Freeze(ctx context.Context, containerRef string) error
- func (d *Driver) ImageExists(ctx context.Context, imageRef string) (bool, error)
- func (d *Driver) ImportRootfsImage(ctx context.Context, imageRef string, rootfs io.Reader) (string, error)
- func (d *Driver) Inspect(ctx context.Context, containerRef string) (*models.SandboxRuntimeState, error)
- func (d *Driver) ListManaged(ctx context.Context) (map[string]*models.SandboxRuntimeState, error)
- func (d *Driver) NetRulesEnabled() bool
- func (d *Driver) Ping(ctx context.Context) error
- func (d *Driver) PoolImageID(ctx context.Context, ref string) (string, error)
- func (d *Driver) PurgeParkedContainers(ctx context.Context) (int, error)
- func (d *Driver) PushAllowedPorts(ctx context.Context, containerIP, toolboxToken string, ports []int) error
- func (d *Driver) ReassertEgressFloor(context.Context) (bool, error)
- func (d *Driver) ReassertNodeGuard(context.Context) (bool, error)
- func (d *Driver) RemoveImage(ctx context.Context, imageRef string) error
- func (d *Driver) Resize(ctx context.Context, containerRef string, req models.ResizeSandboxRequest) error
- func (d *Driver) SandboxContainerExists(ctx context.Context, sandboxID string) (bool, error)
- func (d *Driver) SetClient(c *Client)
- func (d *Driver) SetEgressFloor(_ context.Context, cidrs []netip.Prefix) error
- func (d *Driver) SetNetnsHandoff(h NetnsHandoff)
- func (d *Driver) SetNodeGuard(_ context.Context, allow []netrules.NodePort) error
- func (d *Driver) SetWarmPool(p WarmPool)
- func (d *Driver) Start(ctx context.Context, containerRef string) (*models.SandboxRuntimeState, error)
- func (d *Driver) StartWithIdentity(ctx context.Context, containerRef, sandboxID, toolboxToken string) (*models.SandboxRuntimeState, error)
- func (d *Driver) StartWithIdentityEnv(ctx context.Context, containerRef, sandboxID, toolboxToken string, ...) (*models.SandboxRuntimeState, error)
- func (d *Driver) Stop(ctx context.Context, containerRef string) error
- func (d *Driver) StreamEvents(ctx context.Context, out chan<- docker.DockerEvent) error
- func (d *Driver) Thaw(ctx context.Context, containerRef string) error
- func (d *Driver) WritableLayerBytes(ctx context.Context, containerRef string) (int64, error)
- type ImageBuilder
- func (b *ImageBuilder) BuildImage(ctx context.Context, req docker.BuildImageRequest) error
- func (b *ImageBuilder) ImageExists(ctx context.Context, imageRef string) (bool, error)
- func (b *ImageBuilder) PushImage(ctx context.Context, req docker.PushImageRequest) (string, error)
- func (b *ImageBuilder) RefreshTag(ctx context.Context, fullRef string) error
- func (b *ImageBuilder) RemoveImage(ctx context.Context, imageRef string) error
- type NetnsHandoff
- type PoolSpawner
- type RegistryPusher
- type WarmPool
Constants ¶
const DefaultBuildKitAddr = "unix:///run/buildkit/buildkitd.sock"
DefaultBuildKitAddr is the buildkitd control socket the bootstrap installs.
Variables ¶
This section is empty.
Functions ¶
func IsParkedContainerLabels ¶
IsParkedContainerLabels reports warm-pool park inventory for ListManaged. A park never carries a sandbox id; an adopt sets one. Requiring its absence keeps a sandbox adopted by an older build, whose adopt left the park label on (see adoptParked), from being drained or listed as park inventory.
func IsParkedSandboxID ¶
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 NewTestClient ¶
NewTestClient wires a fake or stub transport for unit tests.
func (*Client) ContentStore ¶
ContentStore exposes the backing content store for image config reads.
func (*Client) ListContainers ¶
func (*Client) LoadContainer ¶
func (*Client) NewContainer ¶
type Config ¶
type Config struct {
Socket string
Namespace string
ToolboxBinaryPath string
ToolboxMountPath string
ToolboxPort int
Privileged bool
ResourceLimitsOff bool
PidsLimit int64
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 ¶
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 ¶
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) ApplyEgressHold ¶ added in v0.6.6
ApplyEgressHold installs the fail-closed hold DROP (CEO D16).
func (*Driver) ApplyEgressPolicy ¶
func (*Driver) ApplyNetworkBlockAll ¶
func (*Driver) ApplyNetworkBlockAllReport ¶
ApplyNetworkBlockAllReport implements runtime.NetworkBlockReporter. See the docker client's copy for why reconcile needs the inserted flag.
func (*Driver) ApplyNetworkBlockIngress ¶
func (*Driver) ClearEgressHold ¶ added in v0.6.6
ClearEgressHold lifts the hold after a successful gateway attach.
func (*Driver) ClearEgressPolicy ¶
func (*Driver) ClearNetworkBlockEgress ¶
func (*Driver) ClearNetworkBlockIngress ¶
func (*Driver) ClearNetworkRules ¶
func (*Driver) ConfigureAOCRPullAuth ¶ added in v0.6.5
ConfigureAOCRPullAuth installs the node-local cluster-PAT pull credential, with the same signature and no-op rules as docker.Client.ConfigureAOCRPullAuth so the daemon wires both engines through one helper.
Why containerd needs it at all: a cross-node create-from-snapshot hands the driver an AOCR ref (`<aocr>/cluster/<id>/snapshots/<name>:...`) with no caller credential, and AOCR rejects anonymous pulls of `cluster/<id>/*`. dockerd got this back-fill in pullImageDedup; without it a containerd node fails every such create with "failed to fetch anonymous token: 401".
Must be called before the driver serves creates or the warm pool refills: the field is read without a lock on the pull path.
func (*Driver) ContainerPID ¶
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 ¶
CreateSnapshot commits a running task filesystem into a new image in the aerolvm namespace (plans/containerd-engine.md Phase 3).
func (*Driver) Destroy ¶
Destroy removes the sandbox in the order that keeps it shut and its address clean: the workload is killed first; then the destroy's runtime.AddressObserver (the egress gateway detach) is told; then the address's rules are cleared, while the netns slot is still held (a rule cleared after the slot is free could be the next owner's); and the slot goes back to the pool last. It used to clear the rules and free the slot first and kill the task last, so a destroyed sandbox briefly ran without its rules and its address could be handed on while the gateway still held state for it. A failed container removal still lets the address go (the netns teardown cuts the workload's network) and is returned.
func (*Driver) ExportImageArchive ¶ added in v0.6.12
func (d *Driver) ExportImageArchive(ctx context.Context, imageRef string, w io.Writer) (bool, error)
ExportImageArchive writes the local image imageRef to w as an OCI archive (skopeo's oci-archive: transport reads it). ok is false, with nothing written, when the namespace has no such image.
func (*Driver) Freeze ¶ added in v0.6.12
Freeze pauses the sandbox's task with the cgroup freezer (task.Pause), memory intact, for the cluster ownership fence (runtime.Freezer). The sandbox row is not touched, and the event mapper already ignores TaskPaused/TaskResumed, so nothing downstream reads the freeze as a stop.
Idempotent: a task that is already paused (or pausing), not running, or absent has nothing executing, so there is nothing to do.
func (*Driver) ImageExists ¶
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) ImportRootfsImage ¶ added in v0.6.12
func (d *Driver) ImportRootfsImage(ctx context.Context, imageRef string, rootfs io.Reader) (string, error)
ImportRootfsImage makes rootfs, a tar of a filesystem tree, the single layer of a new image imageRef, unpacked so a container can run it, and returns the image ID (its manifest digest). An image already under that name is repointed at the new one.
func (*Driver) Inspect ¶
func (d *Driver) Inspect(ctx context.Context, containerRef string) (*models.SandboxRuntimeState, error)
Inspect reports what containerd knows about one container. An error wrapping sbruntime.ErrInstanceNotFound means containerd answered NotFound for the container; reconcile deletes the sandbox's row on that and only that. Any other error means containerd could not answer, and says nothing about the sandbox.
A container that exists always yields a state. Stopped when it has no task or its task has exited — a task that died and is still there (runsc crashed under a fork bomb: exit status unavailable) is a stopped sandbox, not a missing one. Started when its task runs, with the address sandboxAddress finds: the netns probe, else the address recorded at create. A running gVisor sandbox always needs the record (its probe can't succeed), and one created before the record existed, or whose netns is gone, has neither: it is still Started, with ContainerIP empty. An unreadable address used to fail Inspect, ListManaged then skipped the container, and reconcile deleted the live sandbox's row and cluster placement. Callers that need the address check for an empty one: Create and Start keep requiring it (runtimeStateAfterStart), the start event and runningAt treat empty as "no change", and reconcile keeps the row's address.
func (*Driver) ListManaged ¶
func (*Driver) NetRulesEnabled ¶ added in v0.6.9
NetRulesEnabled reports whether the AEROLVM-USER rules are live. A nil or disabled manager (network rules off, or not Linux) makes every rule method here a no-op.
func (*Driver) PoolImageID ¶ added in v0.6.12
PoolImageID is the digest a ref names in containerd's image store now, for the warm pool's image-change check (plans/agent-sandbox-feature- parity.md W3). It tries the same local names ensureImage tries before it pulls (the exact ref, ":latest" for a tagless one, the registry-normalized form) and never pulls: a missing image is an error, so the pool keeps what it had. The answer is in the form parkContainer records.
func (*Driver) PurgeParkedContainers ¶
PurgeParkedContainers destroys park-labeled containers left from a prior run.
func (*Driver) PushAllowedPorts ¶
func (*Driver) ReassertEgressFloor ¶ added in v0.6.9
ReassertEgressFloor puts the floor back if something removed it.
func (*Driver) ReassertNodeGuard ¶ added in v0.6.9
ReassertNodeGuard puts the guard back if something removed it.
func (*Driver) RemoveImage ¶
func (*Driver) SandboxContainerExists ¶ added in v0.6.9
SandboxContainerExists reports whether sandboxID still has a containerd container on this node, running or stopped. It is the netns pool's ownership test at boot: a slot belongs to its sandbox for as long as the container exists, because the container's spec pins the slot's netns path and a later Start rejoins it. Unlike Inspect it never fails on a healthy sandbox: Inspect also reads the IP out of the netns, which a gVisor sandbox does not expose there. A warm-adopted sandbox keeps its park container id, so a miss by id falls back to the sandbox-id label. Any error other than NotFound is returned, and the caller must treat it as "still owned".
func (*Driver) SetEgressFloor ¶ added in v0.6.6
SetEgressFloor installs the operator's node-wide deny floor for the CNI bridge subnet (§5.10 PC-2).
func (*Driver) SetNetnsHandoff ¶
func (d *Driver) SetNetnsHandoff(h NetnsHandoff)
SetNetnsHandoff wires the native netns pool (Phase 2). Nil disables it.
func (*Driver) SetNodeGuard ¶ added in v0.6.9
SetNodeGuard default-denies the CNI bridge subnet from the node itself, except allow (netrules ChainAerolvmNode).
func (*Driver) SetWarmPool ¶
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)
Start starts a stopped sandbox's container again. A container adopted from the warm pool cannot be started this way: its spec still carries the pool's env, so its toolboxd would boot parked and serve nothing; the service starts every containerd sandbox through StartWithIdentity.
func (*Driver) StartWithIdentity ¶ added in v0.6.9
func (d *Driver) StartWithIdentity(ctx context.Context, containerRef, sandboxID, toolboxToken string) (*models.SandboxRuntimeState, error)
StartWithIdentity implements runtime.IdentityStarter. A container adopted from the warm pool keeps the pool's env for life (SB_POOL_PARKED=1, its slot's bootstrap token and park nonce, the bind of its slot's park socket) because adoption relabels the container and leaves its spec alone. Every start re-creates the task from that spec, so its toolboxd boots parked, holds the user's command back and answers only /health until it is adopted again. This listens on the slot's socket before the task starts, takes the parked hello and adopts it with the sandbox's own ID and token, exactly as the create did. Any other container starts as Start does. A container adopted with env can't be started this way: it needs StartWithIdentityEnv, which re-sends the env.
func (*Driver) StartWithIdentityEnv ¶ added in v0.6.12
func (d *Driver) StartWithIdentityEnv(ctx context.Context, containerRef, sandboxID, toolboxToken string, loadEnv sbruntime.AdoptEnvLoader) (*models.SandboxRuntimeState, error)
StartWithIdentityEnv implements runtime.EnvIdentityStarter: StartWithIdentity for a pool container whose create carried env. That env reached the toolbox in the adopt frame and is in no spec, so the re-adopt must carry it again, as a cold container's start re-reads its env from its spec. loadEnv is called only for a container adopted with env (adoptEnvLabelKey), and before the task is created, so a start that cannot have the env starts nothing.
func (*Driver) StreamEvents ¶
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 (*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 ¶
func (p *PoolSpawner) Park(ctx context.Context, slotID string, key containerdpool.Key) (*containerdpool.ParkedSlot, error)
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 pushes the local image SourceTag to the registry as DestRef. No local image is created under DestRef (see pushLiveDeps).
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.
Source Files
¶
- aocr_pull_auth.go
- buildkit.go
- client.go
- client_test_seam.go
- client_transport.go
- driver.go
- events.go
- freeze.go
- hosts.go
- image_config.go
- image_import.go
- image_lease.go
- ipv6.go
- lifecycle.go
- logio.go
- metrics.go
- netns_handoff.go
- network_ip.go
- network_ip_linux.go
- network_rules.go
- push.go
- runsc_config.go
- runtime_gvisor.go
- security.go
- snapshot.go
- validate.go
- version.go
- warm_adopt.go
- warm_park.go
- warm_pool.go