runtime

package
v1.0.0-alpha6 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2017 License: Apache-2.0, CC-BY-SA-4.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TaskCreateEventTopic       = "/tasks/create"
	TaskStartEventTopic        = "/tasks/start"
	TaskOOMEventTopic          = "/tasks/oom"
	TaskExitEventTopic         = "/tasks/exit"
	TaskDeleteEventTopic       = "/tasks/delete"
	TaskExecAddedEventTopic    = "/tasks/exec-added"
	TaskPausedEventTopic       = "/tasks/paused"
	TaskResumedEventTopic      = "/tasks/resumed"
	TaskCheckpointedEventTopic = "/tasks/checkpointed"
)

Variables

View Source
var (
	ErrTaskNotExists     = errors.New("task does not exist")
	ErrTaskAlreadyExists = errors.New("task already exists")
)

Functions

This section is empty.

Types

type ConsoleSize added in v1.0.0

type ConsoleSize struct {
	Width  uint32
	Height uint32
}

type CreateOpts added in v1.0.0

type CreateOpts struct {
	// Spec is the OCI runtime spec
	Spec *types.Any
	// Rootfs mounts to perform to gain access to the container's filesystem
	Rootfs []mount.Mount
	// IO for the container's main process
	IO IO
	// Checkpoint digest to restore container state
	Checkpoint string
	// Options for the runtime and container
	Options *types.Any
}

type ExecOpts added in v1.0.0

type ExecOpts struct {
	Spec *types.Any
	IO   IO
}

type Exit added in v1.0.0

type Exit struct {
	Pid       uint32
	Status    uint32
	Timestamp time.Time
}

type IO added in v1.0.0

type IO struct {
	Stdin    string
	Stdout   string
	Stderr   string
	Terminal bool
}

type Process

type Process interface {
	ID() string
	// State returns the process state
	State(context.Context) (State, error)
	// Kill signals a container
	Kill(context.Context, uint32, bool) error
	// Pty resizes the processes pty/console
	ResizePty(context.Context, ConsoleSize) error
	// CloseStdin closes the processes stdin
	CloseIO(context.Context) error
	// Start the container's user defined process
	Start(context.Context) error
}

type Runtime added in v1.0.0

type Runtime interface {
	// ID of the runtime
	ID() string
	// Create creates a task with the provided id and options.
	Create(ctx context.Context, id string, opts CreateOpts) (Task, error)
	// Get returns a task.
	Get(context.Context, string) (Task, error)
	// Tasks returns all the current tasks for the runtime.
	// Any container runs at most one task at a time.
	Tasks(context.Context) ([]Task, error)
	// Delete removes the task in the runtime.
	Delete(context.Context, Task) (*Exit, error)
}

Runtime is responsible for the creation of containers for a certain platform, arch, or custom usage.

type State

type State struct {
	// Status is the current status of the container
	Status Status
	// Pid is the main process id for the container
	Pid uint32
	// ExitStatus of the process
	// Only valid if the Status is Stopped
	ExitStatus uint32
	// ExitedAt is the time at which the process exited
	// Only valid if the Status is Stopped
	ExitedAt time.Time
	Stdin    string
	Stdout   string
	Stderr   string
	Terminal bool
}

type Status added in v1.0.0

type Status int
const (
	CreatedStatus Status = iota + 1
	RunningStatus
	StoppedStatus
	DeletedStatus
	PausedStatus
	PausingStatus
)

type Task added in v1.0.0

type Task interface {
	Process

	// Information of the container
	Info() TaskInfo
	// Pause pauses the container process
	Pause(context.Context) error
	// Resume unpauses the container process
	Resume(context.Context) error
	// Exec adds a process into the container
	Exec(context.Context, string, ExecOpts) (Process, error)
	// Pids returns all pids
	Pids(context.Context) ([]uint32, error)
	// Checkpoint checkpoints a container to an image with live system data
	Checkpoint(context.Context, string, *types.Any) error
	// DeleteProcess deletes a specific exec process via its id
	DeleteProcess(context.Context, string) (*Exit, error)
	// Update sets the provided resources to a running task
	Update(context.Context, *types.Any) error
	// Process returns a process within the task for the provided id
	Process(context.Context, string) (Process, error)
}

type TaskInfo added in v1.0.0

type TaskInfo struct {
	ID        string
	Runtime   string
	Spec      []byte
	Namespace string
}

type TaskList added in v1.0.0

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

func NewTaskList added in v1.0.0

func NewTaskList() *TaskList

func (*TaskList) Add added in v1.0.0

func (l *TaskList) Add(ctx context.Context, t Task) error

func (*TaskList) AddWithNamespace added in v1.0.0

func (l *TaskList) AddWithNamespace(namespace string, t Task) error

func (*TaskList) Delete added in v1.0.0

func (l *TaskList) Delete(ctx context.Context, t Task)

func (*TaskList) Get added in v1.0.0

func (l *TaskList) Get(ctx context.Context, id string) (Task, error)

func (*TaskList) GetAll added in v1.0.0

func (l *TaskList) GetAll(ctx context.Context) ([]Task, error)

type TaskMonitor added in v1.0.0

type TaskMonitor interface {
	// Monitor adds the provided container to the monitor
	Monitor(Task) error
	// Stop stops and removes the provided container from the monitor
	Stop(Task) error
}

TaskMonitor provides an interface for monitoring of containers within containerd

func NewMultiTaskMonitor added in v1.0.0

func NewMultiTaskMonitor(monitors ...TaskMonitor) TaskMonitor

func NewNoopMonitor added in v1.0.0

func NewNoopMonitor() TaskMonitor

Jump to

Keyboard shortcuts

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