Add state machine for sandbox and container
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
bfd25c80b4
commit
4dc6f6d0b5
@ -28,6 +28,38 @@ import (
|
|||||||
runtime "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
runtime "k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// The container state machine in the CRI plugin:
|
||||||
|
//
|
||||||
|
// + +
|
||||||
|
// | |
|
||||||
|
// | Create | Load
|
||||||
|
// | |
|
||||||
|
// +----v----+ |
|
||||||
|
// | | |
|
||||||
|
// | CREATED <---------+-----------+
|
||||||
|
// | | | |
|
||||||
|
// +----+----- | |
|
||||||
|
// | | |
|
||||||
|
// | Start | |
|
||||||
|
// | | |
|
||||||
|
// +----v----+ | |
|
||||||
|
// Exec +--------+ | | |
|
||||||
|
// Attach | | RUNNING <---------+ |
|
||||||
|
// LogReopen +--------> | | |
|
||||||
|
// +----+----+ | |
|
||||||
|
// | | |
|
||||||
|
// | Stop/Exit | |
|
||||||
|
// | | |
|
||||||
|
// +----v----+ | |
|
||||||
|
// | <---------+ +----v----+
|
||||||
|
// | EXITED | | |
|
||||||
|
// | <----------------+ UNKNOWN |
|
||||||
|
// +----+----+ Stop | |
|
||||||
|
// | +---------+
|
||||||
|
// | Remove
|
||||||
|
// v
|
||||||
|
// DELETED
|
||||||
|
|
||||||
// statusVersion is current version of container status.
|
// statusVersion is current version of container status.
|
||||||
const statusVersion = "v1" // nolint
|
const statusVersion = "v1" // nolint
|
||||||
|
|
||||||
|
@ -21,8 +21,44 @@ import (
|
|||||||
"time"
|
"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.
|
// 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
|
type State uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -40,6 +76,9 @@ const (
|
|||||||
// cleanup resources other than sandbox container, e.g. network namespace.
|
// cleanup resources other than sandbox container, e.g. network namespace.
|
||||||
// This is an assumption made in CRI.
|
// This is an assumption made in CRI.
|
||||||
StateNotReady
|
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.
|
// Status is the status of a sandbox.
|
||||||
|
Loading…
Reference in New Issue
Block a user