lxcontainer

package
v0.0.3-0...-0ccb7e6 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrExist = fmt.Errorf("container already exists")
View Source
var ErrNotExist = fmt.Errorf("container does not exist")

Functions

func CreatePidFile

func CreatePidFile(path string, pid int) error

createPidFile atomically creates a pid file for the given pid at the given path

func DecodeFileJSON

func DecodeFileJSON(obj interface{}, src string) error

Types

type ContainerInfo

type ContainerInfo struct {
	ContainerID string
	CreatedAt   time.Time
	RuntimeRoot string

	BundlePath    string
	ConsoleSocket string `json:",omitempty"`
	// PidFile is the absolute path to the PID file of the container monitor process (crio-lxc-start)
	PidFile          string
	MonitorCgroupDir string

	// values derived from spec
	CgroupDir string

	// feature gates
	Seccomp       bool
	Capabilities  bool
	Apparmor      bool
	CgroupDevices bool

	// values duplicated from bundle.json
	// annotations are required for 'state'
	Annotations map[string]string `json:",omitempty"`
	// namespaces are required for 'exec'
	Namespaces []specs.LinuxNamespace `json:",omitempty"`
}

ContainerInfo holds the information about a single container. It is created at 'create' within the container runtime dir and not changed afterwards. It is removed when the container is deleted.

func (ContainerInfo) ConfigFilePath

func (c ContainerInfo) ConfigFilePath() string

func (*ContainerInfo) Create

func (c *ContainerInfo) Create() error

func (ContainerInfo) CreatePidFile

func (c ContainerInfo) CreatePidFile(pid int) error

func (*ContainerInfo) Load

func (c *ContainerInfo) Load() error

RuntimeRoot and ContainerID must be set

func (ContainerInfo) Pid

func (c ContainerInfo) Pid() (int, error)

func (ContainerInfo) RuntimePath

func (c ContainerInfo) RuntimePath(subPath ...string) string

RuntimePath returns the absolute path witin the container root

type Runtime

type Runtime struct {
	Container *lxc.Container
	ContainerInfo

	// [ global settings ]
	LogFile           *os.File
	LogFilePath       string
	LogLevel          string
	LogTimestamp      string
	ContainerLogLevel string
	SystemdCgroup     bool
	MonitorCgroup     string

	StartCommand  string
	InitCommand   string
	ContainerHook string

	Log zerolog.Logger
}

func (*Runtime) ConfigureLogging

func (c *Runtime) ConfigureLogging(cmdName string) error

func (*Runtime) Create

func (c *Runtime) Create(ctx context.Context, spec *specs.Spec) error

func (*Runtime) Delete

func (c *Runtime) Delete(ctx context.Context, force bool) error

func (*Runtime) Exec

func (c *Runtime) Exec(args []string, proc *specs.Process) (exitStatus int, err error)

func (*Runtime) ExecDetached

func (c *Runtime) ExecDetached(args []string, proc *specs.Process) (pid int, err error)

func (*Runtime) Kill

func (c *Runtime) Kill(ctx context.Context, signum unix.Signal) error

func (Runtime) Release

func (c Runtime) Release() error

Release releases/closes allocated resources (lxc.Container, LogFile)

func (*Runtime) Start

func (c *Runtime) Start(ctx context.Context) error

func (*Runtime) State

func (c *Runtime) State() (*specs.State, error)

Jump to

Keyboard shortcuts

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