container

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: AGPL-3.0 Imports: 81 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknown            = errors.New("unknown") // used internally to represent a missed mapping.
	ErrInvalidArgument    = errors.New("invalid argument")
	ErrNotFound           = errors.New("not found")
	ErrAlreadyExists      = errors.New("already exists")
	ErrFailedPrecondition = errors.New("failed precondition")
	ErrUnavailable        = errors.New("unavailable")
	ErrNotImplemented     = errors.New("not implemented") // represents not supported and unimplemented
)

Functions

func AppContext added in v0.8.0

func AppContext(context gocontext.Context) (gocontext.Context, gocontext.CancelFunc)

AppContext returns the context for a command. Should only be called once per command, near the start.

This will ensure the namespace is picked up and set the timeout, if one is defined.

func CheckRuntime added in v0.8.0

func CheckRuntime(current, expected string) bool

CheckRuntime returns true if the current runtime matches the expected runtime. Providing various parts of the runtime schema will match those parts of the expected runtime

func CreateContainer added in v0.8.0

func CreateContainer(context *RuncOpts, id string, spec *specs.Spec) (*libcontainer.Container, error)

func Dump

func Dump(dir string, containerID string) error

Gotta figure out containerID discovery - TODO NR

func GetCgroupMounts added in v0.8.0

func GetCgroupMounts(m *configs.Mount) ([]*configs.Mount, error)

func Init added in v0.8.0

func Init()

func IsAlreadyExists added in v0.8.0

func IsAlreadyExists(err error) bool

func NewNotifySocket added in v0.8.0

func NewNotifySocket(context *RuncOpts, notifySocketHost string, id string) *notifySocket

func Restore added in v0.8.0

func Restore(imgPath string, containerID string) error

func Root added in v0.8.0

func Root() (string, error)

Root returns the Intel RDT "resource control" filesystem mount point.

func RuncRestore added in v0.8.0

func RuncRestore(imgPath string, containerId string, opts RuncOpts) error

func StartContainer added in v0.8.0

func StartContainer(context *RuncOpts, action CtAct, criuOpts *libcontainer.CriuOpts) (int, error)

func WriteIntelRdtTasks added in v0.8.0

func WriteIntelRdtTasks(dir string, pid int) error

WriteIntelRdtTasks writes the specified pid into the "tasks" file

Types

type BaseState added in v0.8.0

type BaseState struct {
	// ID is the container ID.
	ID string `json:"id"`

	// InitProcessPid is the init process id in the parent namespace.
	InitProcessPid int `json:"init_process_pid"`

	// InitProcessStartTime is the init process start time in clock cycles since boot time.
	InitProcessStartTime uint64 `json:"init_process_start"`

	// Created is the unix timestamp for the creation time of the container in UTC
	Created time.Time `json:"created"`

	// Config is the container's configuration.
	Config configs.Config `json:"config"`
}

type CheckpointTaskInfo added in v0.8.0

type CheckpointTaskInfo struct {
	Name string
	// ParentCheckpoint is the digest of a parent checkpoint
	ParentCheckpoint digest.Digest
	// Options hold runtime specific settings for checkpointing a task
	Options interface{}
	// contains filtered or unexported fields
}

CheckpointTaskInfo allows specific checkpoint information to be set for the task

func (*CheckpointTaskInfo) Runtime added in v0.8.0

func (i *CheckpointTaskInfo) Runtime() string

Runtime name for the container

type CheckpointTaskOpts added in v0.8.0

type CheckpointTaskOpts func(*CheckpointTaskInfo) error

func WithCheckpointImagePath added in v0.8.0

func WithCheckpointImagePath(path string) CheckpointTaskOpts

WithCheckpointImagePath sets image path for checkpoint option

type Config added in v0.8.0

type Config struct {
	// BlockIOConfigFile specifies the path to blockio configuration file
	BlockIOConfigFile string `toml:"blockio_config_file" json:"blockioConfigFile"`
	// RdtConfigFile specifies the path to RDT configuration file
	RdtConfigFile string `toml:"rdt_config_file" json:"rdtConfigFile"`
}

Config for the tasks service plugin

type CriuOpts

type CriuOpts struct {
	ImagesDirectory         string             // directory for storing image files
	WorkDirectory           string             // directory to cd and write logs/pidfiles/stats to
	ParentImage             string             // directory for storing parent image files in pre-dump and dump
	LeaveRunning            bool               // leave container in running state after checkpoint
	TcpEstablished          bool               // checkpoint/restore established TCP connections
	ExternalUnixConnections bool               // allow external unix connections
	ShellJob                bool               // allow to dump and restore shell jobs
	FileLocks               bool               // handle file locks, for safety
	PreDump                 bool               // call criu predump to perform iterative checkpoint
	VethPairs               []VethPairName     // pass the veth to criu when restore
	ManageCgroupsMode       criurpc.CriuCgMode // dump or restore cgroup mode
	EmptyNs                 uint32             // don't c/r properties for namespace from this mask
	AutoDedup               bool               // auto deduplication for incremental dumps
	LazyPages               bool               // restore memory pages lazily using userfaultfd
	StatusFd                int                // fd for feedback when lazy server is ready
	LsmProfile              string             // LSM profile used to restore the container
	LsmMountContext         string             // LSM mount context value to use during restore
}

Higher level CriuOptions that are used to turn on/off the flags passed to criu

type CtAct added in v0.8.0

type CtAct uint8
const (
	CT_ACT_CREATE CtAct = iota + 1
	CT_ACT_RUN
	CT_ACT_RESTORE
)

type Fields added in v0.8.0

type Fields map[string]interface{}

type Manager added in v0.8.0

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

func NewManager added in v0.8.0

func NewManager(config *configs.Config, id string, path string) *Manager

NewManager returns a new instance of Manager, or nil if the Intel RDT functionality is not specified in the config, available from hardware or enabled in the kernel.

func (*Manager) Apply added in v0.8.0

func (m *Manager) Apply(pid int) (err error)

Applies Intel RDT configuration to the process with the specified pid

func (*Manager) Destroy added in v0.8.0

func (m *Manager) Destroy() error

Destroys the Intel RDT container-specific 'container_id' group

func (*Manager) GetPath added in v0.8.0

func (m *Manager) GetPath() string

Returns Intel RDT path to save in a state file and to be able to restore the object later

func (*Manager) Set added in v0.8.0

func (m *Manager) Set(container *configs.Config) error

Set Intel RDT "resource control" filesystem as configured.

type RuncContainer

type RuncContainer struct {
	Id                   string
	Root                 string
	Pid                  int
	Config               *configs.Config // standin for configs.Config from runc
	CgroupManager        cgroups.Manager
	InitProcessStartTime uint64
	InitProcess          parentProcess
	M                    sync.Mutex
	CriuVersion          int
	Created              time.Time
	DockerConfig         *dockerTypes.ContainerJSON
	IntelRdtManager      *Manager
	State                containerState
}

func GetContainerFromRunc added in v0.8.0

func GetContainerFromRunc(containerID string, root string) *RuncContainer

func (*RuncContainer) RuncCheckpoint

func (c *RuncContainer) RuncCheckpoint(criuOpts *CriuOpts, pid int) error

type RuncOpts added in v0.8.0

type RuncOpts struct {
	Root            string
	ContainerId     string
	Bundle          string
	SystemdCgroup   bool
	NoPivot         bool
	NoMountFallback bool
	NoNewKeyring    bool
	Rootless        string
	NoSubreaper     bool
	Keep            bool
	ConsoleSocket   string
	Detatch         bool
	PidFile         string
	PreserveFds     int
}

type Runner added in v0.8.0

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

func (*Runner) Run added in v0.8.0

func (r *Runner) Run(config *specs.Process) (int, error)

type State added in v0.8.0

type State struct {
	BaseState

	// Specified if the container was started under the rootless mode.
	// Set to true if BaseState.Config.RootlessEUID && BaseState.Config.RootlessCgroups
	Rootless bool `json:"rootless"`

	// Paths to all the container's cgroups, as returned by (*cgroups.Manager).GetPaths
	//
	// For cgroup v1, a key is cgroup subsystem name, and the value is the path
	// to the cgroup for this subsystem.
	//
	// For cgroup v2 unified hierarchy, a key is "", and the value is the unified path.
	CgroupPaths map[string]string `json:"cgroup_paths"`

	// NamespacePaths are filepaths to the container's namespaces. Key is the namespace type
	// with the value as the path.
	NamespacePaths map[configs.NamespaceType]string `json:"namespace_paths"`

	// Container's standard descriptors (std{in,out,err}), needed for checkpoint and restore
	ExternalDescriptors []string `json:"external_descriptors,omitempty"`

	// Intel RDT "resource control" filesystem path
	IntelRdtPath string `json:"intel_rdt_path"`
}

type Status added in v0.8.0

type Status int

type VethPairName

type VethPairName struct {
	ContainerInterfaceName string
	HostInterfaceName      string
}

this comes from runc, see github.com/cedana/runc they use an external CriuOpts struct that's populated

Jump to

Keyboard shortcuts

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