Add state machine for sandbox and container
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
@@ -21,8 +21,44 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// The sandbox state machine in the CRI plugin:
|
||||
// + +
|
||||
// | |
|
||||
// | Create(Run) | Load
|
||||
// | |
|
||||
// Start +----v----+ |
|
||||
// (failed) | | |
|
||||
// +-------------+ INIT | +-----------+
|
||||
// | | | | |
|
||||
// | +----+----+ | |
|
||||
// | | | |
|
||||
// | | Start(Run) | |
|
||||
// | | | |
|
||||
// | PortForward +----v----+ | |
|
||||
// | +------+ | | |
|
||||
// | | | READY <---------+ |
|
||||
// | +------> | | |
|
||||
// | +----+----+ | |
|
||||
// | | | |
|
||||
// | | Stop/Exit | |
|
||||
// | | | |
|
||||
// | +----v----+ | |
|
||||
// | | <---------+ +----v----+
|
||||
// | | NOTREADY| | |
|
||||
// | | <----------------+ UNKNOWN |
|
||||
// | +----+----+ Stop | |
|
||||
// | | +---------+
|
||||
// | | Remove
|
||||
// | v
|
||||
// +-------------> DELETED
|
||||
|
||||
// State is the sandbox state we use in containerd/cri.
|
||||
// It has init state defined.
|
||||
// It includes init and unknown, which are internal states not defined in CRI.
|
||||
// The state mapping from internal states to CRI states:
|
||||
// * ready -> ready
|
||||
// * not ready -> not ready
|
||||
// * init -> not exist
|
||||
// * unknown -> not ready
|
||||
type State uint32
|
||||
|
||||
const (
|
||||
@@ -40,6 +76,9 @@ const (
|
||||
// cleanup resources other than sandbox container, e.g. network namespace.
|
||||
// This is an assumption made in CRI.
|
||||
StateNotReady
|
||||
// StateUnknown is unknown state. Sandbox only goes
|
||||
// into unknown state when its status fails to be loaded.
|
||||
StateUnknown
|
||||
)
|
||||
|
||||
// Status is the status of a sandbox.
|
||||
|
||||
Reference in New Issue
Block a user