Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct { // Metadata is the metadata of the container, it is **immutable** after created. Metadata // Status stores the status of the container. Status StatusStorage // Container is the containerd container client. Container containerd.Container // Container IO. // IO could only be nil when the container is in unknown state. IO *cio.ContainerIO // StopCh is used to propagate the stop information of the container. *store.StopCh }
Container contains all resources associated with the container. All methods to mutate the internal state are thread-safe.
func NewContainer ¶
NewContainer creates an internally used container type.
type Metadata ¶
type Metadata struct { // ID is the container id. ID string // Name is the container name. Name string // SandboxID is the sandbox id the container belongs to. SandboxID string // Config is the CRI container config. // NOTE(random-liu): Resource limits are updatable, the source // of truth for resource limits are in containerd. Config *runtime.ContainerConfig // ImageRef is the reference of image used by the container. ImageRef string // LogPath is the container log path. LogPath string // StopSignal is the system call signal that will be sent to the container to exit. // TODO(random-liu): Add integration test for stop signal. StopSignal string // ProcessLabel is the SELinux process label for the container ProcessLabel string }
Metadata is the unversioned container metadata.
func (*Metadata) MarshalJSON ¶
MarshalJSON encodes Metadata into bytes in json format.
func (*Metadata) UnmarshalJSON ¶
UnmarshalJSON decodes Metadata from bytes.
type Opts ¶
Opts sets specific information to newly created Container.
func WithContainer ¶
func WithContainer(cntr containerd.Container) Opts
WithContainer adds the containerd Container to the internal data store.
func WithContainerIO ¶
func WithContainerIO(io *cio.ContainerIO) Opts
WithContainerIO adds IO into the container.
func WithFakeStatus ¶
WithFakeStatus adds fake status to the container.
func WithStatus ¶
WithStatus adds status to the container.
type Status ¶
type Status struct { // Pid is the init process id of the container. Pid uint32 // CreatedAt is the created timestamp. CreatedAt int64 // StartedAt is the started timestamp. StartedAt int64 // FinishedAt is the finished timestamp. FinishedAt int64 // ExitCode is the container exit code. ExitCode int32 // CamelCase string explaining why container is in its current state. Reason string // Human-readable message indicating details about why container is in its // current state. Message string // Starting indicates that the container is in starting state. // This field doesn't need to be checkpointed. Starting bool `json:"-"` // Removing indicates that the container is in removing state. // This field doesn't need to be checkpointed. Removing bool `json:"-"` // Unknown indicates that the container status is not fully loaded. // This field doesn't need to be checkpointed. Unknown bool `json:"-"` }
Status is the status of a container.
func LoadStatus ¶
LoadStatus loads container status from checkpoint. There shouldn't be threads writing to the file during loading.
func (Status) State ¶
func (s Status) State() runtime.ContainerState
State returns current state of the container based on the container status.
type StatusStorage ¶
type StatusStorage interface { // Get a container status. Get() Status // UpdateSync updates the container status and the on disk checkpoint. // Note that the update MUST be applied in one transaction. UpdateSync(UpdateFunc) error // Update the container status. Note that the update MUST be applied // in one transaction. Update(UpdateFunc) error // Delete the container status. // Note: // * Delete should be idempotent. // * The status must be deleted in one trasaction. Delete() error }
StatusStorage manages the container status with a storage backend.
func StoreStatus ¶
func StoreStatus(root, id string, status Status) (StatusStorage, error)
StoreStatus creates the storage containing the passed in container 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 Containers.
func (*Store) Add ¶
Add a container into the store. Returns store.ErrAlreadyExist if the container already exists.
type UpdateFunc ¶
UpdateFunc is function used to update the container status. If there is an error, the update will be rolled back.