Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosedNetNS = errors.New("network namespace is closed")
ErrClosedNetNS is the error returned when network namespace is closed.
Functions ¶
This section is empty.
Types ¶
type Metadata ¶
type Metadata struct { // ID is the sandbox id. ID string // Name is the sandbox name. Name string // Config is the CRI sandbox config. Config *runtime.PodSandboxConfig // NetNSPath is the network namespace used by the sandbox. NetNSPath string // IP of Pod if it is attached to non host network IP string }
Metadata is the unversioned sandbox metadata.
func (*Metadata) MarshalJSON ¶
MarshalJSON encodes Metadata into bytes in json format.
func (*Metadata) UnmarshalJSON ¶
UnmarshalJSON decodes Metadata from bytes.
type NetNS ¶
NetNS holds network namespace for sandbox
func LoadNetNS ¶
LoadNetNS loads existing network namespace. It returns ErrClosedNetNS if the network namespace has already been closed.
type Sandbox ¶
type Sandbox struct { // Metadata is the metadata of the sandbox, it is immutable after created. Metadata // Status stores the status of the sandbox. Status StatusStorage // Container is the containerd sandbox container client Container containerd.Container // CNI network namespace client NetNS *NetNS // StopCh is used to propagate the stop information of the sandbox. *store.StopCh }
Sandbox contains all resources associated with the sandbox. All methods to mutate the internal state are thread safe.
func NewSandbox ¶
NewSandbox creates an internally used sandbox type. This functions reminds the caller that a sandbox must have a status.
type State ¶
type State uint32
State is the sandbox state we use in containerd/cri. It has unknown state defined.
const ( // StateUnknown is unknown state of sandbox. Sandbox // is in unknown state before its corresponding sandbox container // is created. Sandbox in unknown state should be ignored by most // functions, unless the caller needs to update sandbox state. StateUnknown State = iota // StateReady is ready state, it means sandbox container // is running. StateReady // StateNotReady is notready state, it ONLY means sandbox // container is not running. // StopPodSandbox should still be called for NOTREADY sandbox to // cleanup resources other than sandbox container, e.g. network namespace. // This is an assumption made in CRI. StateNotReady )
type Status ¶
type Status struct { // Pid is the init process id of the sandbox container. Pid uint32 // CreatedAt is the created timestamp. CreatedAt time.Time // State is the state of the sandbox. State State }
Status is the status of a sandbox.
type StatusStorage ¶
type StatusStorage interface { // Get a sandbox status. Get() Status // Update the sandbox status. Note that the update MUST be applied // in one transaction. Update(UpdateFunc) error }
StatusStorage manages the sandbox status. The status storage for sandbox is different from container status storage, because we don't checkpoint sandbox status. If we need checkpoint in the future, we should combine this with container status storage.
func StoreStatus ¶
func StoreStatus(status Status) StatusStorage
StoreStatus creates the storage containing the passed in sandbox status with the specified id. The status MUST be created in one transaction.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store stores all sandboxes.
func (*Store) Get ¶
Get returns the sandbox with specified id. Returns store.ErrNotExist if the sandbox doesn't exist.
type UpdateFunc ¶
UpdateFunc is function used to update the sandbox status. If there is an error, the update will be rolled back.