sandbox

package
Version: v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: Apache-2.0 Imports: 12 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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
	// AdditionalIPs of the Pod if it is attached to non host network
	AdditionalIPs []string
	// RuntimeHandler is the runtime handler name of the pod.
	RuntimeHandler string
	// CNIresult resulting configuration for attached network namespace interfaces
	CNIResult *cni.CNIResult
	// ProcessLabel is the SELinux process label for the container
	ProcessLabel string
}

Metadata is the unversioned sandbox metadata.

func (*Metadata) MarshalJSON

func (c *Metadata) MarshalJSON() ([]byte, error)

MarshalJSON encodes Metadata into bytes in json format.

func (*Metadata) UnmarshalJSON

func (c *Metadata) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes Metadata from bytes.

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.
	// For hostnetwork pod, this is always nil;
	// For non hostnetwork pod, this should never be nil.
	NetNS *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

func NewSandbox(metadata Metadata, status Status) Sandbox

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 includes unknown, which is internal states not defined in CRI. The state mapping from internal states to CRI states: * ready -> ready * not ready -> not ready * unknown -> not ready

const (
	// StateReady is ready state, it means sandbox container
	// is running.
	StateReady State = iota
	// 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
	// StateUnknown is unknown state. Sandbox only goes
	// into unknown state when its status fails to be loaded.
	StateUnknown
)

func (State) String added in v1.19.0

func (s State) String() string

String returns the string representation of the state

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 NewStore

func NewStore(labels *label.Store) *Store

NewStore creates a sandbox store.

func (*Store) Add

func (s *Store) Add(sb Sandbox) error

Add a sandbox into the store.

func (*Store) Delete

func (s *Store) Delete(id string)

Delete deletes the sandbox with specified id.

func (*Store) Get

func (s *Store) Get(id string) (Sandbox, error)

Get returns the sandbox with specified id. Returns store.ErrNotExist if the sandbox doesn't exist.

func (*Store) List

func (s *Store) List() []Sandbox

List lists all sandboxes.

type UpdateFunc

type UpdateFunc func(Status) (Status, error)

UpdateFunc is function used to update the sandbox status. If there is an error, the update will be rolled back.

Jump to

Keyboard shortcuts

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