Documentation ¶
Index ¶
- Constants
- Variables
- func Metrics() map[string]interface{}
- type AddProcessTask
- type CreateCheckpointTask
- type DeleteCheckpointTask
- type DeleteTask
- type Event
- type ExecExitTask
- type ExitTask
- type GetContainersTask
- type Machine
- type Monitor
- type OOMTask
- type SignalTask
- type StartResponse
- type StartTask
- type StatsTask
- type Supervisor
- func (s *Supervisor) Close() error
- func (s *Supervisor) Events(from time.Time, storedOnly bool, id string) chan Event
- func (s *Supervisor) Machine() Machine
- func (s *Supervisor) SendTask(evt Task)
- func (s *Supervisor) Start() error
- func (s *Supervisor) Stop()
- func (s *Supervisor) Unsubscribe(sub chan Event)
- type Task
- type UpdateProcessTask
- type UpdateTask
- type Worker
Constants ¶
const ( StateStart = "start-container" StatePause = "pause" StateResume = "resume" StateExit = "exit" StateStartProcess = "start-process" StateOOM = "oom" StateLive = "live" )
State constants used in Event types
Variables ¶
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") )
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 ¶
Types ¶
type AddProcessTask ¶
type AddProcessTask struct { ID string PID string Stdout string Stderr string Stdin string ProcessSpec *specs.ProcessSpec StartResponse chan StartResponse Ctx context.Context // contains filtered or unexported fields }
AddProcessTask holds everything necessary to add a process to a container
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
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
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
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
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
type Machine ¶
Machine holds the current machine cpu count and ram size
func CollectMachineInformation ¶
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 ¶
NewMonitor starts a new process monitor and returns it
func (*Monitor) MonitorOOM ¶
MonitorOOM adds a container to the list of the ones monitored for OOM
type OOMTask ¶
type OOMTask struct { ID string // contains filtered or unexported fields }
OOMTask holds needed parameters to report a container OOM
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
type StartResponse ¶
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 Ctx context.Context // contains filtered or unexported fields }
StartTask holds needed parameters to create a new container
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
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 ¶
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