Documentation
¶
Index ¶
- Variables
- func GetBaseConfig(runtimeName string) string
- func GetCgroupPathFromPID(pid int) (string, error)
- type Capabilities
- type CgroupOOMWatcher
- type CheckpointOpts
- type Config
- type DeleteOpts
- type ErrContainerNotFound
- type ErrRuntimeNotAvailable
- type ErrUnsupportedRuntime
- type Event
- type ExecOpts
- type GvisorOOMWatcher
- type KillOpts
- type OOMWatcher
- type OutputWriter
- type RestoreOpts
- type RunOpts
- type Runc
- func (r *Runc) Capabilities() Capabilities
- func (r *Runc) Checkpoint(ctx context.Context, containerID string, opts *CheckpointOpts) error
- func (r *Runc) Close() error
- func (r *Runc) Delete(ctx context.Context, containerID string, opts *DeleteOpts) error
- func (r *Runc) Events(ctx context.Context, containerID string) (<-chan Event, error)
- func (r *Runc) Exec(ctx context.Context, containerID string, proc specs.Process, opts *ExecOpts) error
- func (r *Runc) Kill(ctx context.Context, containerID string, sig syscall.Signal, opts *KillOpts) error
- func (r *Runc) List(ctx context.Context) ([]State, error)
- func (r *Runc) Name() string
- func (r *Runc) Prepare(ctx context.Context, spec *specs.Spec) error
- func (r *Runc) Restore(ctx context.Context, containerID string, opts *RestoreOpts) (int, error)
- func (r *Runc) Run(ctx context.Context, containerID, bundlePath string, opts *RunOpts) (int, error)
- func (r *Runc) State(ctx context.Context, containerID string) (State, error)
- type Runsc
- func (r *Runsc) AddDockerInDockerCapabilities(spec *specs.Spec)
- func (r *Runsc) Capabilities() Capabilities
- func (r *Runsc) Checkpoint(ctx context.Context, containerID string, opts *CheckpointOpts) error
- func (r *Runsc) Close() error
- func (r *Runsc) Delete(ctx context.Context, containerID string, opts *DeleteOpts) error
- func (r *Runsc) Events(ctx context.Context, containerID string) (<-chan Event, error)
- func (r *Runsc) Exec(ctx context.Context, containerID string, proc specs.Process, opts *ExecOpts) error
- func (r *Runsc) Kill(ctx context.Context, containerID string, sig syscall.Signal, opts *KillOpts) error
- func (r *Runsc) List(ctx context.Context) ([]State, error)
- func (r *Runsc) Name() string
- func (r *Runsc) Prepare(ctx context.Context, spec *specs.Spec) error
- func (r *Runsc) Restore(ctx context.Context, containerID string, opts *RestoreOpts) (int, error)
- func (r *Runsc) Run(ctx context.Context, containerID, bundlePath string, opts *RunOpts) (int, error)
- func (r *Runsc) State(ctx context.Context, containerID string) (State, error)
- type Runtime
- type State
Constants ¶
This section is empty.
Variables ¶
var BaseRuncConfigRaw string
var BaseRunscConfigRaw string
Functions ¶
func GetBaseConfig ¶
GetBaseConfig returns the appropriate base config for the runtime
func GetCgroupPathFromPID ¶
GetCgroupPathFromPID reads the actual cgroup path from a process This works for both cgroup v1 and v2, and for any runtime
Types ¶
type Capabilities ¶
type Capabilities struct {
CheckpointRestore bool // CRIU support
GPU bool // GPU device passthrough
OOMEvents bool // Runtime-native OOM events (use cgroup poller as fallback)
JoinExistingNetNS bool // Can join existing network namespace
CDI bool // Container Device Interface support
}
Capabilities describes what features a runtime supports
type CgroupOOMWatcher ¶
type CgroupOOMWatcher struct {
// contains filtered or unexported fields
}
CgroupOOMWatcher watches for OOM kills via cgroup v2 memory.events Works for runc and other traditional runtimes
func NewCgroupOOMWatcher ¶
func NewCgroupOOMWatcher(ctx context.Context, cgroupPath string) *CgroupOOMWatcher
NewCgroupOOMWatcher creates a new cgroup-based OOM watcher for runc
func (*CgroupOOMWatcher) Watch ¶
func (w *CgroupOOMWatcher) Watch(onOOM func()) error
Watch starts watching for OOM events via cgroup memory.events
type CheckpointOpts ¶
type CheckpointOpts struct {
ImagePath string // Path to store checkpoint image
WorkDir string // Working directory for checkpoint files
LeaveRunning bool // Leave container running after checkpoint
AllowOpenTCP bool // Allow open TCP connections
SkipInFlight bool // Skip in-flight TCP connections
LinkRemap bool // Enable link remapping
OutputWriter OutputWriter // Writer for checkpoint output
}
CheckpointOpts contains options for checkpointing a container
type Config ¶
type Config struct {
Type string // "runc" | "gvisor"
RuncPath string // Path to runc binary (default: "runc")
RunscPath string // Path to runsc binary (default: "runsc")
RunscPlatform string // "kvm" | "ptrace" (optional)
RunscRoot string // Root directory for runsc state (default: "/run/gvisor")
Debug bool // Enable debug mode
}
Config contains configuration for creating a runtime
type DeleteOpts ¶
type DeleteOpts struct {
Force bool // Force deletion
}
DeleteOpts contains options for deleting a container
type ErrContainerNotFound ¶
type ErrContainerNotFound struct {
ContainerID string
}
ErrContainerNotFound is returned when a container is not found
func (ErrContainerNotFound) Error ¶
func (e ErrContainerNotFound) Error() string
type ErrRuntimeNotAvailable ¶
ErrRuntimeNotAvailable is returned when a runtime is not available on the system
func (ErrRuntimeNotAvailable) Error ¶
func (e ErrRuntimeNotAvailable) Error() string
type ErrUnsupportedRuntime ¶
type ErrUnsupportedRuntime struct {
Runtime string
}
ErrUnsupportedRuntime is returned when an unsupported runtime type is requested
func (ErrUnsupportedRuntime) Error ¶
func (e ErrUnsupportedRuntime) Error() string
type ExecOpts ¶
type ExecOpts struct {
OutputWriter OutputWriter
StdinReader io.Reader
Started chan<- int
}
ExecOpts contains options for executing a command in a container
type GvisorOOMWatcher ¶
type GvisorOOMWatcher struct {
// contains filtered or unexported fields
}
GvisorOOMWatcher watches for OOM by monitoring memory usage vs limits Works for gVisor where cgroup files aren't accessible from host
func NewGvisorOOMWatcher ¶
func NewGvisorOOMWatcher(ctx context.Context, pid int, memoryLimitBytes uint64) *GvisorOOMWatcher
NewGvisorOOMWatcher creates a new memory-monitoring OOM watcher for gVisor
func (*GvisorOOMWatcher) Watch ¶
func (w *GvisorOOMWatcher) Watch(onOOM func()) error
Watch starts monitoring memory usage for gVisor containers
type KillOpts ¶
type KillOpts struct {
All bool // Kill all processes in the container
}
KillOpts contains options for killing a container
type OOMWatcher ¶
type OOMWatcher interface {
Watch(onOOM func()) error
Stop()
}
OOMWatcher interface for different runtime implementations
type OutputWriter ¶
OutputWriter is an interface for writing container output
type RestoreOpts ¶
type RestoreOpts struct {
ImagePath string // Path to checkpoint image
WorkDir string // Working directory for restore files
BundlePath string // Path to container bundle
OutputWriter OutputWriter // Writer for restore output
Started chan<- int // PID channel
TCPClose bool // Close TCP connections on restore
}
RestoreOpts contains options for restoring a container from checkpoint
type RunOpts ¶
type RunOpts struct {
OutputWriter OutputWriter
Started chan<- int // PID channel
DockerEnabled bool // Enable Docker-in-Docker (gVisor only)
}
RunOpts contains options for running a container
type Runc ¶
type Runc struct {
// contains filtered or unexported fields
}
Runc implements Runtime using the runc container runtime
func (*Runc) Capabilities ¶
func (r *Runc) Capabilities() Capabilities
func (*Runc) Checkpoint ¶
type Runsc ¶
type Runsc struct {
// contains filtered or unexported fields
}
Runsc implements Runtime using the gVisor runsc runtime
CUDA Checkpoint/Restore: For GPU workloads, cuda-checkpoint is bind-mounted from the host and executed inside the container via runsc exec to freeze/unfreeze GPU state before/after checkpoint/restore operations.
func (*Runsc) AddDockerInDockerCapabilities ¶
AddDockerInDockerCapabilities adds the capabilities required for running Docker inside gVisor. According to gVisor documentation, Docker requires: audit_write, chown, dac_override, fowner, fsetid, kill, mknod, net_bind_service, net_admin, net_raw, setfcap, setgid, setpcap, setuid, sys_admin, sys_chroot, sys_ptrace
func (*Runsc) Capabilities ¶
func (r *Runsc) Capabilities() Capabilities
func (*Runsc) Checkpoint ¶
type Runtime ¶
type Runtime interface {
// Name returns the name of the runtime (e.g., "runc", "gvisor")
Name() string
// Capabilities returns what features this runtime supports
Capabilities() Capabilities
// Prepare may mutate spec to fit runtime quirks (e.g., seccomp, mounts)
// Called before writing config.json
Prepare(ctx context.Context, spec *specs.Spec) error
// Run starts a container with the given configuration
Run(ctx context.Context, containerID, bundlePath string, opts *RunOpts) (int, error)
// Exec executes a command inside a running container
Exec(ctx context.Context, containerID string, proc specs.Process, opts *ExecOpts) error
// Kill sends a signal to a container
Kill(ctx context.Context, containerID string, sig syscall.Signal, opts *KillOpts) error
// Delete removes a container
Delete(ctx context.Context, containerID string, opts *DeleteOpts) error
// State returns the current state of a container
State(ctx context.Context, containerID string) (State, error)
// Events returns a channel for receiving container events
// Optional; use cgroup poller as portable fallback
Events(ctx context.Context, containerID string) (<-chan Event, error)
// Checkpoint creates a checkpoint of a running container
// Returns an error if the runtime doesn't support checkpointing
Checkpoint(ctx context.Context, containerID string, opts *CheckpointOpts) error
// Restore restores a container from a checkpoint
// Returns the exit code and any error
Restore(ctx context.Context, containerID string, opts *RestoreOpts) (int, error)
// Close cleans up any resources held by the runtime
Close() error
}
Runtime defines the interface for different container/microvm runtime implementations