Documentation
¶
Overview ¶
Copyright (c) 2024 Zededa, Inc. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func GetServicesNamespace() string
- func GetSnapshotID(rootpath string) string
- func SaveSnapshotID(oldRootpath, newRootpath string) error
- func StartUserContainerdInstance() error
- func WaitForUserContainerd(ps *pubsub.PubSub, log *base.LogObject, agentName string, ...) error
- type Client
- func (client *Client) CloseClient() error
- func (client *Client) CtrContainerInfo(ctx context.Context, name string) (int, int, string, error)
- func (client *Client) CtrCreateEmptySnapshot(ctx context.Context, snapshotID string) ([]mount.Mount, error)
- func (client *Client) CtrCreateImage(ctx context.Context, image images.Image) (images.Image, error)
- func (client *Client) CtrCreateTask(ctx context.Context, domainName string, io cio.Creator) (containerd.Task, error)
- func (client *Client) CtrDeleteBlob(ctx context.Context, blobHash string) error
- func (client *Client) CtrDeleteContainer(ctx context.Context, containerID string) error
- func (client *Client) CtrDeleteImage(ctx context.Context, reference string) error
- func (client *Client) CtrExec(ctx context.Context, domainName string, args []string) (string, string, error)
- func (client *Client) CtrGetAnnotations(ctx context.Context, containerID string) (map[string]string, error)
- func (client *Client) CtrGetBlobInfo(ctx context.Context, blobHash string) (content.Info, error)
- func (client *Client) CtrGetContainerMetrics(ctx context.Context, containerID string) (*v1stat.Metrics, error)
- func (client *Client) CtrGetImage(ctx context.Context, reference string) (containerd.Image, error)
- func (client *Client) CtrGetSnapshotUsage(ctx context.Context, snapshotID string) (*snapshots.Usage, error)
- func (client *Client) CtrListBlobInfo(ctx context.Context) ([]content.Info, error)
- func (client *Client) CtrListContainer(ctx context.Context) ([]containerd.Container, error)
- func (client *Client) CtrListContainerIds(ctx context.Context) ([]string, error)
- func (client *Client) CtrListImages(ctx context.Context) ([]images.Image, error)
- func (client *Client) CtrListSnapshotInfo(ctx context.Context) ([]snapshots.Info, error)
- func (client *Client) CtrListTaskIds(ctx context.Context) ([]string, error)
- func (client *Client) CtrLoadContainer(ctx context.Context, containerID string) (containerd.Container, error)
- func (client *Client) CtrLoadImage(ctx context.Context, reader *os.File) ([]images.Image, error)
- func (client *Client) CtrLogIOCreator(domainName string) cio.Creator
- func (client *Client) CtrMountSnapshot(ctx context.Context, snapshotID, targetPath string) error
- func (client *Client) CtrNewContainer(ctx context.Context, spec runtimespecs.Spec, specOpts []oci.SpecOpts, ...) (containerd.Container, error)
- func (client *Client) CtrNewContainerWithPersist(ctx context.Context, name string, containerImage containerd.Image) (containerd.Container, error)
- func (client *Client) CtrNewSystemServicesCtx() (context.Context, context.CancelFunc)
- func (client *Client) CtrNewSystemServicesCtxWithLease() (context.Context, context.CancelFunc, error)
- func (client *Client) CtrNewUserServicesCtx() (context.Context, context.CancelFunc)
- func (client *Client) CtrNewUserServicesCtxWithLease() (context.Context, context.CancelFunc, error)
- func (client *Client) CtrPrepareSnapshot(ctx context.Context, snapshotID string, image containerd.Image) ([]mount.Mount, error)
- func (client *Client) CtrPull(ctx context.Context, ref string) (containerd.Image, error)
- func (client *Client) CtrReadBlob(ctx context.Context, blobHash string) (io.Reader, error)
- func (client *Client) CtrRemoveSnapshot(ctx context.Context, snapshotID string) error
- func (client *Client) CtrSnapshotExists(ctx context.Context, snapshotName string) (bool, error)
- func (client *Client) CtrStartTask(ctx context.Context, domainName string) error
- func (client *Client) CtrStopContainer(ctx context.Context, containerID string, force bool) error
- func (client *Client) CtrSystemExec(ctx context.Context, domainName string, args []string) (string, string, error)
- func (client *Client) CtrUpdateBlobInfo(ctx context.Context, updatedContentInfo content.Info, updatedFields []string) error
- func (client *Client) CtrUpdateImage(ctx context.Context, image images.Image, fieldpaths ...string) (images.Image, error)
- func (client *Client) CtrWriteBlob(ctx context.Context, blobHash string, expectedSize uint64, reader io.Reader) error
- func (client *Client) CtrWriterCreator(stdout, stderr io.Writer) cio.Creator
- func (client *Client) NewOciSpec(name string, service bool) (OCISpec, error)
- func (client *Client) Resolver(ctx context.Context) (resolver.ResolverCloser, error)
- func (client *Client) UnpackClientImage(clientImage containerd.Image) error
- type Log
- type OCISpec
Constants ¶
const (
// EVEOCIVNCPasswordLabel is OCI runtime spec label that tracks VNC password in OCI Image config
EVEOCIVNCPasswordLabel = "org.lfedge.eve.vnc_password"
)
Variables ¶
This section is empty.
Functions ¶
func GetServicesNamespace ¶
func GetServicesNamespace() string
GetServicesNamespace returns defaultServicesNamespace The value is used to define the cgroups path of the EVE services
func GetSnapshotID ¶
GetSnapshotID handles the upgrade scenario when the snapshotID needs to be extracted from a file created by upgradeconverter Assumes that rootpath is a complete pathname
func SaveSnapshotID ¶
SaveSnapshotID stores snapshotID under newRootpath to handle upgrade scenario
func StartUserContainerdInstance ¶
func StartUserContainerdInstance() error
StartUserContainerdInstance execute user containerd instance in goroutine
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the handle we return to the caller
func NewContainerdClient ¶
NewContainerdClient returns a *Client Callable from multiple go-routines.
func (*Client) CloseClient ¶
CloseClient closes containerd client
func (*Client) CtrContainerInfo ¶
CtrContainerInfo returns PID, exit code and status of a container's main task Status can be one of the: created, running, pausing, paused, stopped, unknown For tasks that are in the running, pausing or paused state the PID is also provided and the exit code is set to 0. For tasks in the stopped state, exit code is provided and the PID is set to 0.
func (*Client) CtrCreateEmptySnapshot ¶
func (client *Client) CtrCreateEmptySnapshot(ctx context.Context, snapshotID string) ([]mount.Mount, error)
CtrCreateEmptySnapshot creates an empty snapshot with the given snapshotID or returns the existing snapshot if it already exists.
func (*Client) CtrCreateImage ¶
CtrCreateImage create an image in containerd's image store
func (*Client) CtrCreateTask ¶
func (client *Client) CtrCreateTask(ctx context.Context, domainName string, io cio.Creator) (containerd.Task, error)
CtrCreateTask creates (but doesn't start) the default task in a pre-existing container and attaches its logging to memlogd
func (*Client) CtrDeleteBlob ¶
CtrDeleteBlob deletes blob with the given blobHash
func (*Client) CtrDeleteContainer ¶
CtrDeleteContainer is a simple wrapper around container.Delete()
func (*Client) CtrDeleteImage ¶
CtrDeleteImage deletes an image with the given reference
func (*Client) CtrExec ¶
func (client *Client) CtrExec(ctx context.Context, domainName string, args []string) (string, string, error)
CtrExec starts the executable in a running user container
func (*Client) CtrGetAnnotations ¶
func (client *Client) CtrGetAnnotations(ctx context.Context, containerID string) (map[string]string, error)
CtrGetAnnotations gets annotations for defined containerID
func (*Client) CtrGetBlobInfo ¶
CtrGetBlobInfo returns a bolb's info as content.Info
func (*Client) CtrGetContainerMetrics ¶
func (client *Client) CtrGetContainerMetrics(ctx context.Context, containerID string) (*v1stat.Metrics, error)
CtrGetContainerMetrics returns all runtime metrics associated with a container ID
func (*Client) CtrGetImage ¶
CtrGetImage returns image object for the reference. Returns error if no image is found for the reference.
func (*Client) CtrGetSnapshotUsage ¶
func (client *Client) CtrGetSnapshotUsage(ctx context.Context, snapshotID string) (*snapshots.Usage, error)
CtrGetSnapshotUsage returns snapshot's usage for snapshotID present in containerd's snapshot store
func (*Client) CtrListBlobInfo ¶
CtrListBlobInfo returns a list of blob infos as []content.Info
func (*Client) CtrListContainer ¶
CtrListContainer returns a list of containerd.Container objects
func (*Client) CtrListContainerIds ¶
CtrListContainerIds returns a list of all known container IDs
func (*Client) CtrListImages ¶
CtrListImages returns a list of images object from ontainerd's image store
func (*Client) CtrListSnapshotInfo ¶
CtrListSnapshotInfo returns a list of all snapshot's info present in containerd's snapshot store.
func (*Client) CtrListTaskIds ¶
CtrListTaskIds returns a list of all known tasks
func (*Client) CtrLoadContainer ¶
func (client *Client) CtrLoadContainer(ctx context.Context, containerID string) (containerd.Container, error)
CtrLoadContainer returns container with the given `containerID`. Error is returned if there no container is found.
func (*Client) CtrLoadImage ¶
CtrLoadImage reads image as raw data from `reader` and loads it into containerd
func (*Client) CtrLogIOCreator ¶
CtrLogIOCreator creates a cio.Creator with logger
func (*Client) CtrMountSnapshot ¶
CtrMountSnapshot mounts the snapshot with snapshotID on the given targetPath.
func (*Client) CtrNewContainer ¶
func (client *Client) CtrNewContainer(ctx context.Context, spec runtimespecs.Spec, specOpts []oci.SpecOpts, name string, containerImage containerd.Image) (containerd.Container, error)
CtrNewContainer starts a new container with a specific spec and specOpts
func (*Client) CtrNewContainerWithPersist ¶
func (client *Client) CtrNewContainerWithPersist(ctx context.Context, name string, containerImage containerd.Image) (containerd.Container, error)
CtrNewContainerWithPersist starts a new container with /persist mounted
func (*Client) CtrNewSystemServicesCtx ¶
func (client *Client) CtrNewSystemServicesCtx() (context.Context, context.CancelFunc)
CtrNewSystemServicesCtx returns a new system service containerd context and a done func to cancel the context after use.
func (*Client) CtrNewSystemServicesCtxWithLease ¶
func (client *Client) CtrNewSystemServicesCtxWithLease() (context.Context, context.CancelFunc, error)
CtrNewSystemServicesCtxWithLease returns a new system service containerd context with a 24 hrs lease and a done func to delete the lease and cancel the context after use.
func (*Client) CtrNewUserServicesCtx ¶
func (client *Client) CtrNewUserServicesCtx() (context.Context, context.CancelFunc)
CtrNewUserServicesCtx returns a new user service containerd context and a done func to cancel the context after use.
func (*Client) CtrNewUserServicesCtxWithLease ¶
CtrNewUserServicesCtxWithLease returns a new user service containerd context with a 24 hrs lease and a done func to delete the lease and cancel the context after use.
func (*Client) CtrPrepareSnapshot ¶
func (client *Client) CtrPrepareSnapshot(ctx context.Context, snapshotID string, image containerd.Image) ([]mount.Mount, error)
CtrPrepareSnapshot creates snapshot for the given image or a clean one if no image is provided.
func (*Client) CtrReadBlob ¶
CtrReadBlob return a reader for the blob with given blobHash. Error is returned if no blob is found for the blobHash
func (*Client) CtrRemoveSnapshot ¶
CtrRemoveSnapshot removed snapshot by ID from containerd
func (*Client) CtrSnapshotExists ¶
CtrSnapshotExists checks if a snapshot with the given snapshotName exists in containerd's snapshot store
func (*Client) CtrStartTask ¶
CtrStartTask starts the default task in a pre-existing container that was prepared by CtrCreateTask
func (*Client) CtrStopContainer ¶
CtrStopContainer stops (kills) the main task in the container
func (*Client) CtrSystemExec ¶
func (client *Client) CtrSystemExec(ctx context.Context, domainName string, args []string) (string, string, error)
CtrSystemExec starts the executable in a running system (EVE's) container
func (*Client) CtrUpdateBlobInfo ¶
func (client *Client) CtrUpdateBlobInfo(ctx context.Context, updatedContentInfo content.Info, updatedFields []string) error
CtrUpdateBlobInfo updates blobs info
func (*Client) CtrUpdateImage ¶
func (client *Client) CtrUpdateImage(ctx context.Context, image images.Image, fieldpaths ...string) (images.Image, error)
CtrUpdateImage updates the files provided in fieldpaths of the image in containerd'd image store
func (*Client) CtrWriteBlob ¶
func (client *Client) CtrWriteBlob(ctx context.Context, blobHash string, expectedSize uint64, reader io.Reader) error
CtrWriteBlob reads the blob as raw data from `reader` and writes it into containerd. Accepts a custom context. If ctx is nil, then default context will be used.
func (*Client) CtrWriterCreator ¶
CtrWriterCreator creates a cio.Creator with specific writer for stdout/stderr
func (*Client) NewOciSpec ¶
NewOciSpec returns a default oci spec from the containerd point of view
func (*Client) UnpackClientImage ¶
func (client *Client) UnpackClientImage(clientImage containerd.Image) error
UnpackClientImage unpacks given client image into containerd.
type Log ¶
type Log interface { Path(string) string // Path of the log file (may be a FIFO) Open(string) (io.WriteCloser, error) // Opens a log stream Dump(string) // Copies logs to the console }
Log provides access to a log by path or io.WriteCloser
type OCISpec ¶
type OCISpec interface { Get() *specs.Spec Save(*os.File) error Load(*os.File) error CreateContainer(bool) error AddLoader(string) error AdjustMemLimit(types.DomainConfig, int64) UpdateVifList([]types.VifConfig) UpdateFromDomain(dom *types.DomainConfig, status *types.DomainStatus) UpdateFromVolume(string) error UpdateMounts([]types.DiskStatus) error UpdateEnvVar(map[string]string) UpdateWithIoBundles(config *types.DomainConfig, aa *types.AssignableAdapters, domainID int) error GrantFullAccessToDevices() }
OCISpec provides methods to manipulate OCI runtime specifications and create containers based on them