runtime

package
v1.0.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 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

type ConsoleSize struct {
	Width  uint32
	Height uint32
}

type CreateOpts

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

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

type Exit

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

type IO

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
}

type Runtime

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
	Stdin    string
	Stdout   string
	Stderr   string
	Terminal bool
}

type Status

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

type Task

type Task interface {
	Process

	// Information of the container
	Info() TaskInfo
	// Start the container's user defined process
	Start(context.Context) error
	// 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

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

type TaskList

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

func NewTaskList

func NewTaskList() *TaskList

func (*TaskList) Add

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

func (*TaskList) AddWithNamespace

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

func (*TaskList) Delete

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

func (*TaskList) Get

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

func (*TaskList) GetAll

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

type TaskMonitor

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

func NewMultiTaskMonitor(monitors ...TaskMonitor) TaskMonitor

func NewNoopMonitor

func NewNoopMonitor() TaskMonitor

Jump to

Keyboard shortcuts

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