package sandbox

import "github.com/containerd/cri/pkg/store/sandbox"

Index

Variables

var ErrClosedNetNS = errors.New("network namespace is closed")

ErrClosedNetNS is the error returned when network namespace is closed.

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
}

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 NetNS

type NetNS struct {
	sync.Mutex
	// contains filtered or unexported fields
}

NetNS holds network namespace for sandbox

func LoadNetNS

func LoadNetNS(path string) (*NetNS, error)

LoadNetNS loads existing network namespace. It returns ErrClosedNetNS if the network namespace has already been closed.

func NewNetNS

func NewNetNS() (*NetNS, error)

NewNetNS creates a network namespace for the sandbox

func (*NetNS) GetPath

func (n *NetNS) GetPath() string

GetPath returns network namespace path for sandbox container

func (*NetNS) Remove

func (n *NetNS) Remove() error

Remove removes network namepace if it exists and not closed. Remove is idempotent, meaning it might be invoked multiple times and provides consistent result.

type Sandbox

type Sandbox struct {
	// Metadata is the metadata of the sandbox, it is immutable after created.
	Metadata
	// Container is the containerd sandbox container client
	Container containerd.Container
	// CNI network namespace client
	NetNS *NetNS
}

Sandbox contains all resources associated with the sandbox. All methods to mutate the internal state are thread safe.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store stores all sandboxes.

func NewStore

func NewStore() *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 nil if the sandbox doesn't exist.

func (*Store) List

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

List lists all sandboxes.

Source Files

metadata.go netns.go sandbox.go

Version
v1.0.0-alpha.1
Published
Oct 31, 2017
Platform
js/wasm
Imports
13 packages
Last checked
4 hours ago

Tools for package owners.