Documentation ¶
Overview ¶
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func LeaveRunning(args []string) []string
- func PreDump(args []string) []string
- func ReadPidFile(path string) (int, error)
- type Blkio
- type BlkioEntry
- type CPUSet
- type CgroupMode
- type CheckpointAction
- type CheckpointOpts
- type ConsoleSocket
- type Container
- type Cpu
- type CpuUsage
- type CreateOpts
- type DeleteOpts
- type Event
- type ExecOpts
- type Exit
- type ExitError
- type Format
- type Hugetlb
- type IO
- type IOOpt
- type IOOption
- type IntelRdt
- type KillOpts
- type L3CacheInfo
- type MemBwInfo
- type Memory
- type MemoryEntry
- type NetworkInterface
- type Pids
- type ProcessMonitor
- type RestoreOpts
- type Runc
- func (r *Runc) Checkpoint(context context.Context, id string, opts *CheckpointOpts, ...) error
- func (r *Runc) Create(context context.Context, id, bundle string, opts *CreateOpts) error
- func (r *Runc) Delete(context context.Context, id string, opts *DeleteOpts) error
- func (r *Runc) Events(context context.Context, id string, interval time.Duration) (chan *Event, error)
- func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts *ExecOpts) error
- func (r *Runc) Features(context context.Context) (*features.Features, error)
- func (r *Runc) Kill(context context.Context, id string, sig int, opts *KillOpts) error
- func (r *Runc) List(context context.Context) ([]*Container, error)
- func (r *Runc) Pause(context context.Context, id string) error
- func (r *Runc) Ps(context context.Context, id string) ([]int, error)
- func (r *Runc) Restore(context context.Context, id, bundle string, opts *RestoreOpts) (int, error)
- func (r *Runc) Resume(context context.Context, id string) error
- func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts) (int, error)
- func (r *Runc) Start(context context.Context, id string) error
- func (r *Runc) State(context context.Context, id string) (*Container, error)
- func (r *Runc) Stats(context context.Context, id string) (*Stats, error)
- func (r *Runc) Top(context context.Context, id string, psOptions string) (*TopResults, error)
- func (r *Runc) Update(context context.Context, id string, resources *specs.LinuxResources) error
- func (r *Runc) Version(context context.Context) (Version, error)
- type Socket
- type StartCloser
- type Stats
- type Throttling
- type TopResults
- type Version
Constants ¶
This section is empty.
Variables ¶
var DefaultCommand = "runc"
DefaultCommand is the default command for Runc
var ErrParseRuncVersion = errors.New("unable to parse runc version")
ErrParseRuncVersion is used when the runc version can't be parsed
Functions ¶
func LeaveRunning ¶
LeaveRunning keeps the container running after the checkpoint has been completed
func ReadPidFile ¶
ReadPidFile reads the pid file at the provided path and returns the pid or an error if the read and conversion is unsuccessful
Types ¶
type Blkio ¶
type Blkio struct { IoServiceBytesRecursive []BlkioEntry `json:"ioServiceBytesRecursive,omitempty"` IoServicedRecursive []BlkioEntry `json:"ioServicedRecursive,omitempty"` IoQueuedRecursive []BlkioEntry `json:"ioQueueRecursive,omitempty"` IoServiceTimeRecursive []BlkioEntry `json:"ioServiceTimeRecursive,omitempty"` IoWaitTimeRecursive []BlkioEntry `json:"ioWaitTimeRecursive,omitempty"` IoMergedRecursive []BlkioEntry `json:"ioMergedRecursive,omitempty"` IoTimeRecursive []BlkioEntry `json:"ioTimeRecursive,omitempty"` SectorsRecursive []BlkioEntry `json:"sectorsRecursive,omitempty"` }
type BlkioEntry ¶
type CPUSet ¶
type CPUSet struct { CPUs []uint16 `json:"cpus,omitempty"` CPUExclusive uint64 `json:"cpu_exclusive"` Mems []uint16 `json:"mems,omitempty"` MemHardwall uint64 `json:"mem_hardwall"` MemExclusive uint64 `json:"mem_exclusive"` MemoryMigrate uint64 `json:"memory_migrate"` MemorySpreadPage uint64 `json:"memory_spread_page"` MemorySpreadSlab uint64 `json:"memory_spread_slab"` MemoryPressure uint64 `json:"memory_pressure"` SchedLoadBalance uint64 `json:"sched_load_balance"` SchedRelaxDomainLevel int64 `json:"sched_relax_domain_level"` }
type CgroupMode ¶
type CgroupMode string
CgroupMode defines the cgroup mode used for checkpointing
const ( // Soft is the "soft" cgroup mode Soft CgroupMode = "soft" // Full is the "full" cgroup mode Full CgroupMode = "full" // Strict is the "strict" cgroup mode Strict CgroupMode = "strict" )
type CheckpointAction ¶
CheckpointAction represents specific actions executed during checkpoint/restore
type CheckpointOpts ¶
type CheckpointOpts struct { // ImagePath is the path for saving the criu image file ImagePath string // WorkDir is the working directory for criu WorkDir string // ParentPath is the path for previous image files from a pre-dump ParentPath string // AllowOpenTCP allows open tcp connections to be checkpointed AllowOpenTCP bool // AllowExternalUnixSockets allows external unix sockets to be checkpointed AllowExternalUnixSockets bool // AllowTerminal allows the terminal(pty) to be checkpointed with a container AllowTerminal bool // CriuPageServer is the address:port for the criu page server CriuPageServer string // FileLocks handle file locks held by the container FileLocks bool // Cgroups is the cgroup mode for how to handle the checkpoint of a container's cgroups Cgroups CgroupMode // EmptyNamespaces creates a namespace for the container but does not save its properties // Provide the namespaces you wish to be checkpointed without their settings on restore EmptyNamespaces []string // LazyPages uses userfaultfd to lazily restore memory pages LazyPages bool // StatusFile is the file criu writes \0 to once lazy-pages is ready StatusFile *os.File ExtraArgs []string }
CheckpointOpts holds the options for performing a criu checkpoint using runc
type ConsoleSocket ¶
type ConsoleSocket interface {
Path() string
}
ConsoleSocket handles the path of the socket for console access
type Container ¶
type Container struct { ID string `json:"id"` Pid int `json:"pid"` Status string `json:"status"` Bundle string `json:"bundle"` Rootfs string `json:"rootfs"` Created time.Time `json:"created"` Annotations map[string]string `json:"annotations"` }
Container hold information for a runc container
type Cpu ¶
type Cpu struct { Usage CpuUsage `json:"usage,omitempty"` Throttling Throttling `json:"throttling,omitempty"` }
type CreateOpts ¶
type CreateOpts struct { IO // PidFile is a path to where a pid file should be created PidFile string ConsoleSocket ConsoleSocket Detach bool NoPivot bool NoNewKeyring bool ExtraFiles []*os.File Started chan<- int ExtraArgs []string }
CreateOpts holds all the options information for calling runc with supported options
type DeleteOpts ¶
DeleteOpts holds the deletion options for calling `runc delete`
type Event ¶
type Event struct { // Type are the event type generated by runc // If the type is "error" then check the Err field on the event for // the actual error Type string `json:"type"` ID string `json:"id"` Stats *Stats `json:"data,omitempty"` // Err has a read error if we were unable to decode the event from runc Err error `json:"-"` }
Event is a struct to pass runc event information
type ExecOpts ¶
type ExecOpts struct { IO PidFile string ConsoleSocket ConsoleSocket Detach bool Started chan<- int ExtraArgs []string }
ExecOpts holds optional settings when starting an exec process with runc
type ExitError ¶
type ExitError struct {
Status int
}
ExitError holds the status return code when a process exits with an error code
type IO ¶
type IO interface { io.Closer Stdin() io.WriteCloser Stdout() io.ReadCloser Stderr() io.ReadCloser Set(*exec.Cmd) }
IO is the terminal IO interface
type IntelRdt ¶
type IntelRdt struct { // The read-only L3 cache information L3CacheInfo *L3CacheInfo `json:"l3_cache_info,omitempty"` // The read-only L3 cache schema in root L3CacheSchemaRoot string `json:"l3_cache_schema_root,omitempty"` // The L3 cache schema in 'container_id' group L3CacheSchema string `json:"l3_cache_schema,omitempty"` // The read-only memory bandwidth information MemBwInfo *MemBwInfo `json:"mem_bw_info,omitempty"` // The read-only memory bandwidth schema in root MemBwSchemaRoot string `json:"mem_bw_schema_root,omitempty"` // The memory bandwidth schema in 'container_id' group MemBwSchema string `json:"mem_bw_schema,omitempty"` // The memory bandwidth monitoring statistics from NUMA nodes in 'container_id' group MBMStats *[]intelrdt.MBMNumaNodeStats `json:"mbm_stats,omitempty"` // The cache monitoring technology statistics from NUMA nodes in 'container_id' group CMTStats *[]intelrdt.CMTNumaNodeStats `json:"cmt_stats,omitempty"` }
type L3CacheInfo ¶
type Memory ¶
type Memory struct { Cache uint64 `json:"cache,omitempty"` Usage MemoryEntry `json:"usage,omitempty"` Swap MemoryEntry `json:"swap,omitempty"` Kernel MemoryEntry `json:"kernel,omitempty"` KernelTCP MemoryEntry `json:"kernelTCP,omitempty"` Raw map[string]uint64 `json:"raw,omitempty"` }
type MemoryEntry ¶
type NetworkInterface ¶
type ProcessMonitor ¶
type ProcessMonitor interface { Start(*exec.Cmd) (chan Exit, error) StartLocked(*exec.Cmd) (chan Exit, error) Wait(*exec.Cmd, chan Exit) (int, error) }
ProcessMonitor is an interface for process monitoring.
It allows daemons using go-runc to have a SIGCHLD handler to handle exits without introducing races between the handler and go's exec.Cmd.
ProcessMonitor also provides a StartLocked method which is similar to Start, but locks the goroutine used to start the process to an OS thread (for example: when Pdeathsig is set).
var Monitor ProcessMonitor = &defaultMonitor{}
Monitor is the default ProcessMonitor for handling runc process exit
type RestoreOpts ¶
type RestoreOpts struct { CheckpointOpts IO Detach bool PidFile string NoSubreaper bool NoPivot bool ConsoleSocket ConsoleSocket ExtraArgs []string }
RestoreOpts holds the options for performing a criu restore using runc
type Runc ¶
type Runc struct { // Command overrides the name of the runc binary. If empty, DefaultCommand // is used. Command string Root string Debug bool Log string LogFormat Format // PdeathSignal sets a signal the child process will receive when the // parent dies. // // When Pdeathsig is set, command invocations will call runtime.LockOSThread // to prevent OS thread termination from spuriously triggering the // signal. See https://github.com/golang/go/issues/27505 and // https://github.com/golang/go/blob/126c22a09824a7b52c019ed9a1d198b4e7781676/src/syscall/exec_linux.go#L48-L51 // // A program with GOMAXPROCS=1 might hang because of the use of // runtime.LockOSThread. Callers should ensure they retain at least one // unlocked thread. PdeathSignal syscall.Signal // using syscall.Signal to allow compilation on non-unix (unix.Syscall is an alias for syscall.Signal) Setpgid bool // Criu sets the path to the criu binary used for checkpoint and restore. // // Deprecated: runc option --criu is now ignored (with a warning), and the // option will be removed entirely in a future release. Users who need a non- // standard criu binary should rely on the standard way of looking up binaries // in $PATH. Criu string SystemdCgroup bool Rootless *bool // nil stands for "auto" ExtraArgs []string }
Runc is the client to the runc cli
func (*Runc) Checkpoint ¶
func (r *Runc) Checkpoint(context context.Context, id string, opts *CheckpointOpts, actions ...CheckpointAction) error
Checkpoint allows you to checkpoint a container using criu
func (*Runc) Create ¶
Create creates a new container and returns its pid if it was created successfully
func (*Runc) Events ¶
func (r *Runc) Events(context context.Context, id string, interval time.Duration) (chan *Event, error)
Events returns an event stream from runc for a container with stats and OOM notifications
func (*Runc) Exec ¶
Exec executes an additional process inside the container based on a full OCI Process specification
func (*Runc) Features ¶
Features shows the features implemented by the runtime.
Availability:
- runc: supported since runc v1.1.0
- crun: https://github.com/containers/crun/issues/1177
- youki: https://github.com/containers/youki/issues/815
func (*Runc) Run ¶
Run runs the create, start, delete lifecycle of the container and returns its exit status after it has exited
type Socket ¶
type Socket struct {
// contains filtered or unexported fields
}
Socket is a unix socket that accepts the pty master created by runc
func NewConsoleSocket ¶
NewConsoleSocket creates a new unix socket at the provided path to accept a pty master created by runc for use by the container
func NewTempConsoleSocket ¶
NewTempConsoleSocket returns a temp console socket for use with a container On Close(), the socket is deleted
type StartCloser ¶
type StartCloser interface {
CloseAfterStart() error
}
StartCloser is an interface to handle IO closure after start
type Stats ¶
type Stats struct { CPU Cpu `json:"cpu"` CPUSet CPUSet `json:"cpuset"` Memory Memory `json:"memory"` Pids Pids `json:"pids"` Blkio Blkio `json:"blkio"` Hugetlb map[string]Hugetlb `json:"hugetlb"` IntelRdt IntelRdt `json:"intel_rdt"` NetworkInterfaces []*NetworkInterface `json:"network_interfaces"` }
stats is the runc specific stats structure for stability when encoding and decoding stats.
type Throttling ¶
type TopResults ¶
type TopResults struct { // Processes running in the container, where each is process is an array of values corresponding to the headers Processes [][]string `json:"Processes"` // Headers are the names of the columns Headers []string `json:"Headers"` }
TopResults represents the structured data of the full ps output
func ParsePSOutput ¶
func ParsePSOutput(output []byte) (*TopResults, error)
ParsePSOutput parses the runtime's ps raw output and returns a TopResults