libcapsule

package
v0.0.0-...-28e6f37 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	ID() string

	// errors:
	// ContainerNotExists - Container no longer exists,
	// Systemerror - System util.
	Status() (ContainerStatus, error)

	// errors:
	// SystemError - System util.
	State() (*StateStorage, error)

	// errors:
	// SystemError - System util.
	OCIState() (*specs.State, error)

	// Returns the current configs of the container.
	Config() configs.ContainerConfig

	// 创建但不运行cmd
	// errors:
	// ContainerNotExists - Container no longer exists,
	// ConfigInvalid - configs is invalid,
	// ContainerPaused - Container is paused,
	// SystemError - System util.
	Create(process *Process) (err error)

	// Create + Start
	// errors:
	// ContainerNotExists - Container no longer exists,
	// ConfigInvalid - configs is invalid,
	// ContainerPaused - Container is paused,
	// SystemError - System util.
	Run(process *Process) (err error)

	// 删除容器,如果容器还处于created,则杀掉容器进程
	// errors:
	// ContainerNotStopped - Container is still running,
	// ContainerPaused - Container is paused,
	// SystemError - System util.
	Destroy() error

	// 向容器init进程发送信号
	// errors:
	// SystemError - System util.
	Signal(s os.Signal) error

	// 让容器执行最终命令
	// errors:
	// SystemError - System util.
	Start() error
}

Container is a container object. Each container is thread-safe within the same config. Since a container can be destroyed by a separate config, any function may return that the container was not found.

type ContainerStatus

type ContainerStatus int

ContainerStatus is the status of a container.

const (
	// Created is the status that denotes the container exists but has not been run yet.
	Created ContainerStatus = iota
	// Running is the status that denotes the container exists and is running.
	Running
	// Stopped is the status that denotes the container does not have a created or running config.
	Stopped
)

func (ContainerStatus) String

func (s ContainerStatus) String() string

type ContainerStatusBehavior

type ContainerStatusBehavior interface {
	// contains filtered or unexported methods
}

func NewContainerStatusBehavior

func NewContainerStatusBehavior(status ContainerStatus, c *LinuxContainer) (ContainerStatusBehavior, error)

type CreatedStatusBehavior

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

****************************************************************************************** 【CreatedStatusBehavior】 ******************************************************************************************

type Factory

type Factory interface {
	// 创建一个新的容器
	Create(id string, config *configs.ContainerConfig) (Container, error)

	// 加载一个容器
	Load(id string) (Container, error)

	Exists(id string) bool

	// 用于init/exec进程初始化
	StartInitialization() error

	// 返回运行时文件的根目录
	GetRuntimeRoot() string
}

func NewFactory

func NewFactory(runtimeRoot string, init bool) (Factory, error)

type InitExecConfig

type InitExecConfig struct {
	ContainerConfig configs.ContainerConfig `json:"container_config"`
	ProcessConfig   Process                 `json:"process_config"`
	ID              string                  `json:"id"`
}

type Initializer

type Initializer interface {
	Init() error
}

func NewInitializer

func NewInitializer(initializerType InitializerType, config *InitExecConfig, configPipe *os.File, runtimeRoot string) (Initializer, error)

type InitializerExecImpl

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

func (*InitializerExecImpl) Init

func (initializer *InitializerExecImpl) Init() error

type InitializerStandardImpl

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

func (*InitializerStandardImpl) Init

func (initializer *InitializerStandardImpl) Init() (err error)

容器初始化

func (*InitializerStandardImpl) SetRootfsReadOnlyIfSpecified

func (initializer *InitializerStandardImpl) SetRootfsReadOnlyIfSpecified() error

type InitializerType

type InitializerType string
const (
	ExecInitializer InitializerType = "exec"
	InitInitializer InitializerType = "init"
)

type LinuxContainer

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

func (*LinuxContainer) Config

func (*LinuxContainer) Create

func (c *LinuxContainer) Create(process *Process) error

Create并不会运行cmd 会让init process阻塞在cmd之前的

func (*LinuxContainer) Destroy

func (c *LinuxContainer) Destroy() (err error)

func (*LinuxContainer) ID

func (c *LinuxContainer) ID() string

func (*LinuxContainer) OCIState

func (c *LinuxContainer) OCIState() (*specs.State, error)

func (*LinuxContainer) Run

func (c *LinuxContainer) Run(process *Process) error

CreateAndStart 如果是exec(即不是init cmd),则在start中就会执行cmd,不需要exec再通知

func (*LinuxContainer) Signal

func (c *LinuxContainer) Signal(s os.Signal) error

func (*LinuxContainer) Start

func (c *LinuxContainer) Start() error

取消init process的阻塞

func (*LinuxContainer) State

func (c *LinuxContainer) State() (*StateStorage, error)

func (*LinuxContainer) Status

func (c *LinuxContainer) Status() (ContainerStatus, error)

type LinuxContainerFactory

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

func (*LinuxContainerFactory) Create

func (factory *LinuxContainerFactory) Create(id string, config *configs.ContainerConfig) (Container, error)

func (*LinuxContainerFactory) Exists

func (factory *LinuxContainerFactory) Exists(id string) bool

func (*LinuxContainerFactory) GetRuntimeRoot

func (factory *LinuxContainerFactory) GetRuntimeRoot() string

func (*LinuxContainerFactory) Load

func (factory *LinuxContainerFactory) Load(id string) (Container, error)

func (*LinuxContainerFactory) StartInitialization

func (factory *LinuxContainerFactory) StartInitialization() error

type ParentAbstractProcess

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

type ParentNoChildProcess

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

ParentProcess接口的实现类,no child意味着我们现在启动的进程并不是容器init process的父进程,但仍是init process的代理

type ParentProcess

type ParentProcess interface {
	// contains filtered or unexported methods
}

func NewParentNoChildProcess

func NewParentNoChildProcess(initProcessPid int, initProcessStartTime uint64, c *LinuxContainer) ParentProcess

type ParentProcessStartHook

type ParentProcessStartHook func(*ParentAbstractProcess) error

type Process

type Process struct {
	// The command to be run followed by any arguments.
	Args []string

	// Env specifies the environment variables for the config.
	Env []string

	// Cwd will change the processes current working directory inside the container's rootfs.
	Cwd string

	// Init specifies whether the config is the first config in the container.
	Init bool

	// Detach specifies the container is running frontend or backend
	Detach bool

	// if init = true, ID is container id, or ID is exec id.
	ID string
}

type RunningStatusBehavior

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

****************************************************************************************** 【RunningStatusBehavior】 represents a container that is currently running. ******************************************************************************************

type StateStorage

type StateStorage 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 create time in clock cycles since boot time.
	InitProcessStartTime uint64 `json:"init_process_start_time"`

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

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

	// Path to all the cgroups setup for a container. Key is cgroup subsystem name
	// with the value as the path.
	CgroupPaths map[string]string `json:"cgroup_paths"`

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

	// Endpoint is container veth
	Endpoint *network.Endpoint `json:"endpoint"`
}

StateStorage represents a running container's state

type StoppedStatusBehavior

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

****************************************************************************************** 【StoppedStatusBehavior】 represents a container is a stopped/destroyed state. ******************************************************************************************

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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