supervisor

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2016 License: Apache-2.0, CC-BY-SA-4.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StateStart        = "start-container"
	StatePause        = "pause"
	StateResume       = "resume"
	StateExit         = "exit"
	StateStartProcess = "start-process"
	StateOOM          = "oom"
	StateLive         = "live"
)

State constants used in Event types

Variables

View Source
var (
	// ErrContainerNotFound is returned when the container ID passed
	// for a given operation is invalid
	ErrContainerNotFound = errors.New("containerd: container not found")
	// ErrProcessNotFound is returned when the process ID passed for
	// a given operation is invalid
	ErrProcessNotFound = errors.New("containerd: process not found for container")
	// ErrUnknownContainerStatus is returned when the container status
	// cannot be determined
	ErrUnknownContainerStatus = errors.New("containerd: unknown container status ")
	// ErrUnknownTask is returned when an unknown Task type is
	// scheduled (should never happen).
	ErrUnknownTask = errors.New("containerd: unknown task type")
)
View Source
var (
	// ContainerCreateTimer holds the metrics timer associated with container creation
	ContainerCreateTimer = metrics.NewTimer()
	// ContainerDeleteTimer holds the metrics timer associated with container deletion
	ContainerDeleteTimer = metrics.NewTimer()
	// ContainerStartTimer holds the metrics timer associated with container start duration
	ContainerStartTimer = metrics.NewTimer()
	// ContainerStatsTimer holds the metrics timer associated with container stats generation
	ContainerStatsTimer = metrics.NewTimer()
	// ContainersCounter keeps track of the number of active containers
	ContainersCounter = metrics.NewCounter()
	// EventSubscriberCounter keeps track of the number of active event subscribers
	EventSubscriberCounter = metrics.NewCounter()
	// TasksCounter keeps track of the number of active supervisor tasks
	TasksCounter = metrics.NewCounter()
	// ExecProcessTimer holds the metrics timer associated with container exec
	ExecProcessTimer = metrics.NewTimer()
	// ExitProcessTimer holds the metrics timer associated with reporting container exit status
	ExitProcessTimer = metrics.NewTimer()
	// EpollFdCounter keeps trac of how many process are being monitored
	EpollFdCounter = metrics.NewCounter()
)

Functions

func Metrics

func Metrics() map[string]interface{}

Metrics return the list of all available metrics

Types

type AddProcessTask

type AddProcessTask struct {
	ID            string
	PID           string
	Stdout        string
	Stderr        string
	Stdin         string
	ProcessSpec   *specs.ProcessSpec
	StartResponse chan StartResponse
	// contains filtered or unexported fields
}

AddProcessTask holds everything necessary to add a process to a container

func (*AddProcessTask) ErrorCh

func (t *AddProcessTask) ErrorCh() chan error

type CreateCheckpointTask

type CreateCheckpointTask struct {
	ID            string
	CheckpointDir string
	Checkpoint    *runtime.Checkpoint
	// contains filtered or unexported fields
}

CreateCheckpointTask holds needed parameters to create a new checkpoint

func (*CreateCheckpointTask) ErrorCh

func (t *CreateCheckpointTask) ErrorCh() chan error

type DeleteCheckpointTask

type DeleteCheckpointTask struct {
	ID            string
	CheckpointDir string
	Checkpoint    *runtime.Checkpoint
	// contains filtered or unexported fields
}

DeleteCheckpointTask holds needed parameters to delete a checkpoint

func (*DeleteCheckpointTask) ErrorCh

func (t *DeleteCheckpointTask) ErrorCh() chan error

type DeleteTask

type DeleteTask struct {
	ID      string
	Status  uint32
	PID     string
	NoEvent bool
	Process runtime.Process
	// contains filtered or unexported fields
}

DeleteTask holds needed parameters to remove a container

func (*DeleteTask) ErrorCh

func (t *DeleteTask) ErrorCh() chan error

type Event

type Event struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	Timestamp time.Time `json:"timestamp"`
	PID       string    `json:"pid,omitempty"`
	Status    uint32    `json:"status,omitempty"`
}

Event represents a container event

type ExecExitTask

type ExecExitTask struct {
	ID      string
	PID     string
	Status  uint32
	Process runtime.Process
	// contains filtered or unexported fields
}

ExecExitTask holds needed parameters to execute the exec exit task

func (*ExecExitTask) ErrorCh

func (t *ExecExitTask) ErrorCh() chan error

type ExitTask

type ExitTask struct {
	Process runtime.Process
	// contains filtered or unexported fields
}

ExitTask holds needed parameters to execute the exit task

func (*ExitTask) ErrorCh

func (t *ExitTask) ErrorCh() chan error

type GetContainersTask

type GetContainersTask struct {
	ID       string
	GetState func(c runtime.Container) (interface{}, error)

	Containers []runtime.Container
	States     []interface{}
	// contains filtered or unexported fields
}

GetContainersTask holds needed parameters to retrieve a list of containers

func (*GetContainersTask) ErrorCh

func (t *GetContainersTask) ErrorCh() chan error

type Machine

type Machine struct {
	Cpus   int
	Memory int64
}

Machine holds the current machine cpu count and ram size

func CollectMachineInformation

func CollectMachineInformation() (Machine, error)

CollectMachineInformation returns information regarding the current machine (e.g. CPU count, RAM amount)

type Monitor

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

Monitor represents a runtime.Process monitor

func NewMonitor

func NewMonitor() (*Monitor, error)

NewMonitor starts a new process monitor and returns it

func (*Monitor) Close

func (m *Monitor) Close() error

Close cleans up resources allocated by NewMonitor()

func (*Monitor) Exits

func (m *Monitor) Exits() chan runtime.Process

Exits returns the channel used to notify of a process exit

func (*Monitor) Monitor

func (m *Monitor) Monitor(p runtime.Process) error

Monitor adds a process to the list of the one being monitored

func (*Monitor) MonitorOOM

func (m *Monitor) MonitorOOM(c runtime.Container) error

MonitorOOM adds a container to the list of the ones monitored for OOM

func (*Monitor) OOMs

func (m *Monitor) OOMs() chan string

OOMs returns the channel used to notify of a container exit due to OOM

type OOMTask

type OOMTask struct {
	ID string
	// contains filtered or unexported fields
}

OOMTask holds needed parameters to report a container OOM

func (*OOMTask) ErrorCh

func (t *OOMTask) ErrorCh() chan error

type SignalTask

type SignalTask struct {
	ID     string
	PID    string
	Signal os.Signal
	// contains filtered or unexported fields
}

SignalTask holds needed parameters to signal a container

func (*SignalTask) ErrorCh

func (t *SignalTask) ErrorCh() chan error

type StartResponse

type StartResponse struct {
	Container runtime.Container
}

StartResponse is the response containing a started container

type StartTask

type StartTask struct {
	ID            string
	BundlePath    string
	Stdout        string
	Stderr        string
	Stdin         string
	StartResponse chan StartResponse
	Labels        []string
	NoPivotRoot   bool
	Checkpoint    *runtime.Checkpoint
	CheckpointDir string
	Runtime       string
	RuntimeArgs   []string
	// contains filtered or unexported fields
}

StartTask holds needed parameters to create a new container

func (*StartTask) ErrorCh

func (t *StartTask) ErrorCh() chan error

type StatsTask

type StatsTask struct {
	ID   string
	Stat chan *runtime.Stat
	// contains filtered or unexported fields
}

StatsTask holds needed parameters to retrieve a container statistics

func (*StatsTask) ErrorCh

func (t *StatsTask) ErrorCh() chan error

type Supervisor

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

Supervisor represents a container supervisor

func New

func New(stateDir string, runtimeName, shimName string, runtimeArgs []string, timeout time.Duration, retainCount int) (*Supervisor, error)

New returns an initialized Process supervisor.

func (*Supervisor) Close

func (s *Supervisor) Close() error

Close closes any open files in the supervisor but expects that Stop has been callsed so that no more containers are started.

func (*Supervisor) Events

func (s *Supervisor) Events(from time.Time, storedOnly bool, id string) chan Event

Events returns an event channel that external consumers can use to receive updates on container events

func (*Supervisor) Machine

func (s *Supervisor) Machine() Machine

Machine returns the machine information for which the supervisor is executing on.

func (*Supervisor) SendTask

func (s *Supervisor) SendTask(evt Task)

SendTask sends the provided event the the supervisors main event loop

func (*Supervisor) Start

func (s *Supervisor) Start() error

Start is a non-blocking call that runs the supervisor for monitoring contianer processes and executing new containers.

This event loop is the only thing that is allowed to modify state of containers and processes therefore it is save to do operations in the handlers that modify state of the system or state of the Supervisor

func (*Supervisor) Stop

func (s *Supervisor) Stop()

Stop closes all startTasks and sends a SIGTERM to each container's pid1 then waits for they to terminate. After it has handled all the SIGCHILD events it will close the signals chan and exit. Stop is a non-blocking call and will return after the containers have been signaled

func (*Supervisor) Unsubscribe

func (s *Supervisor) Unsubscribe(sub chan Event)

Unsubscribe removes the provided channel from receiving any more events

type Task

type Task interface {
	// ErrorCh returns a channel used to report and error from an async task
	ErrorCh() chan error
}

Task executes an action returning an error chan with either nil or the error from executing the task

type UpdateProcessTask

type UpdateProcessTask struct {
	ID         string
	PID        string
	CloseStdin bool
	Width      int
	Height     int
	// contains filtered or unexported fields
}

UpdateProcessTask holds needed parameters to update a container process terminal size or close its stdin

func (*UpdateProcessTask) ErrorCh

func (t *UpdateProcessTask) ErrorCh() chan error

type UpdateTask

type UpdateTask struct {
	ID        string
	State     runtime.State
	Resources *runtime.Resource
	// contains filtered or unexported fields
}

UpdateTask holds needed parameters to update a container resource constraints

func (*UpdateTask) ErrorCh

func (t *UpdateTask) ErrorCh() chan error

type Worker

type Worker interface {
	Start()
}

Worker interface

func NewWorker

func NewWorker(s *Supervisor, wg *sync.WaitGroup) Worker

NewWorker return a new initialized worker

Jump to

Keyboard shortcuts

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