Documentation
¶
Index ¶
- Constants
- Variables
- func CompileRegexpsForPinnedImages(patterns []string) []*regexp.Regexp
- type ContainerInfo
- type NameTag
- type RuntimeContainerMetadata
- type StorageService
- func (ss *StorageService) ContainerDirectory(id string) (string, error)
- func (ss *StorageService) ContainerRunDirectory(id string) (string, error)
- func (ss *StorageService) Containers() ([]ContainerInfo, error)
- func (ss *StorageService) CreateContainer(podName, podID, userRequestedImage string, imageID string, ...) (ContainerInfo, error)
- func (ss *StorageService) CreatePodSandbox(podName, podID string, pauseImage NameTag, ...) (ContainerInfo, error)
- func (ss *StorageService) DeleteContainer(ctx context.Context, idOrName string) error
- func (ss *StorageService) DeleteImage(id string) error
- func (ss *StorageService) FromContainerDirectory(id, file string) ([]byte, error)
- func (ss *StorageService) GarbageCollect() error
- func (ss *StorageService) GetBundleByID(id string) (bundle *bundle.Bundle, err error)
- func (ss *StorageService) GetContainerMetadata(idOrName string) (RuntimeContainerMetadata, error)
- func (ss *StorageService) GetUsage(id string) (bytesUsed uint64, inodeUsed uint64)
- func (ss *StorageService) ImageStatusByID(id string) (img *types.Image, err error)
- func (ss *StorageService) ImageStatusByName(name NameTag) (img *types.Image, err error)
- func (ss *StorageService) ListImages() (result []*types.Image, err error)
- func (ss *StorageService) MountImage(id string, mountOptions []string, mountLabel string) (string, error)
- func (ss *StorageService) PullImage(ctx context.Context, imageName NameTag) (id string, err error)
- func (ss *StorageService) Root() string
- func (ss *StorageService) SetContainerMetadata(idOrName string, metadata *RuntimeContainerMetadata) error
- func (ss *StorageService) UnmountImage(id string, force bool) (bool, error)
- func (ss *StorageService) UntagImage(name NameTag) error
- func (ss *StorageService) UpdatePinnedImagesList(imageList []string)
Constants ¶
const DefaultRoot = "/var/lib/taskc"
const DefaultRunRoot = "/run/taskc"
Variables ¶
var ( // ErrInvalidPodName is returned when a pod name specified to a // function call is found to be invalid (most often, because it's // empty). ErrInvalidPodName = errors.New("invalid pod name") // ErrInvalidContainerName is returned when a container name specified // to a function call is found to be invalid (most often, because it's // empty). ErrInvalidContainerName = errors.New("invalid container name") // ErrInvalidSandboxID is returned when a sandbox ID specified to a // function call is found to be invalid (because it's either // empty or doesn't match a valid sandbox). ErrInvalidSandboxID = errors.New("invalid sandbox ID") // ErrInvalidContainerID is returned when a container ID specified to a // function call is found to be invalid (because it's either // empty or doesn't match a valid container). ErrInvalidContainerID = errors.New("invalid container ID") // ErrDuplicateName indicates that a name which is to be assigned to a new item is already being used. ErrDuplicateName = errors.New("that name is already in use") // ErrContainerUnknown indicates that there was no container with the specified name or ID. ErrContainerUnknown = errors.New("container not known") // ErrLayerUnknown indicates that there was no layer with the specified name or ID. ErrLayerUnknown = errors.New("layer not known") // ErrRootFsUnknown indicates that the RootFs does not exist ErrRootFsUnknown = errors.New("rootfs not known") )
Functions ¶
func CompileRegexpsForPinnedImages ¶
CompileRegexpsForPinnedImages compiles regular expressions for the given list of pinned images.
Types ¶
type ContainerInfo ¶
type ContainerInfo struct {
// ID is either one which was specified at create-time, or a random
// value which was generated by the library.
ID string `json:"id"`
// Names is an optional set of user-defined convenience values. The
// container can be referred to by its ID or any of its names. Names
// are unique among containers.
Names []string `json:"names,omitempty"`
// ImageID is the ID of the image which was used to create the container.
ImageID string `json:"image"`
// RootFs of the container
RootFs string `json:"rootfs"`
Dir string `json:"dir"`
RunDir string `json:"rundir"`
Config *v1.Image `json:"config"`
// Metadata is data we keep for the convenience of the caller. It is not
// expected to be large, since it is kept in memory.
Metadata string `json:"metadata,omitempty"`
ProcessLabel string `json:"processlabel"`
MountLabel string `json:"mountlabel"`
}
A Container is a reference to a read-write layer with metadata.
type NameTag ¶
func PaserNameTag ¶
type RuntimeContainerMetadata ¶
type RuntimeContainerMetadata struct {
// The pod's name and ID, kept for use by upper layers in determining
// which containers belong to which pods.
PodName string `json:"pod-name"` // Applicable to both PodSandboxes and Containers, mandatory
PodID string `json:"pod-id"` // Applicable to both PodSandboxes and Containers, mandatory
// The users' input originally used to find imageID; it might evaluate to a different image (or to a different kind of reference!) at any future time.
ImageName string `json:"image-name"` // Applicable to both PodSandboxes and Containers
// The ID of the image that was used to instantiate the container.
ImageID string `json:"image-id"` // Applicable to both PodSandboxes and Containers
// The container's name, which for an infrastructure container is usually PodName + "-infra".
ContainerName string `json:"name"` // Applicable to both PodSandboxes and Containers, mandatory
// The name as originally specified in PodSandbox or Container CRI metadata.
MetadataName string `json:"metadata-name"` // Applicable to both PodSandboxes and Containers, mandatory
UID string `json:"uid,omitempty"` // Only applicable to pods
Namespace string `json:"namespace,omitempty"` // Only applicable to pods
MountLabel string `json:"mountlabel,omitempty"` // Applicable to both PodSandboxes and Containers
CreatedAt int64 `json:"created-at"` // Applicable to both PodSandboxes and Containers
Attempt uint32 `json:"attempt,omitempty"` // Applicable to both PodSandboxes and Containers
// Pod is true if this is the pod's infrastructure container.
Pod bool `json:"pod,omitempty"` // Applicable to both PodSandboxes and Containers
Privileged bool `json:"privileged,omitempty"` // Applicable to both PodSandboxes and Containers
}
RuntimeContainerMetadata is the structure that we encode as JSON and store in the metadata field of storage.Container objects. It is used for specifying attributes of pod sandboxes and containers when they are being created, and allows a container's MountLabel, and possibly other values, to be modified in one read/write cycle via calls to RuntimeServer.ContainerMetadata, RuntimeContainerMetadata.SetMountLabel, and RuntimeServer.SetContainerMetadata.
type StorageService ¶
type StorageService struct {
// contains filtered or unexported fields
}
func NewStorageService ¶
func (*StorageService) ContainerDirectory ¶
func (ss *StorageService) ContainerDirectory(id string) (string, error)
ContainerDirectory returns a path of a directory which the caller can use to store data, specific to the container, which the library does not directly manage. The directory will be deleted when the container is deleted.
func (*StorageService) ContainerRunDirectory ¶
func (ss *StorageService) ContainerRunDirectory(id string) (string, error)
ContainerRunDirectory returns a path of a directory which the caller can use to store data, specific to the container, which the library does not directly manage. The directory will be deleted when the host system is restarted.
func (*StorageService) Containers ¶
func (ss *StorageService) Containers() ([]ContainerInfo, error)
Containers returns a list of the currently known containers.
func (*StorageService) CreateContainer ¶
func (ss *StorageService) CreateContainer(podName, podID, userRequestedImage string, imageID string, containerName, containerID, metadataName string, attempt uint32, privileged bool) (ContainerInfo, error)
CreateContainer creates a container with the specified ID. Pointer arguments can be nil. All other arguments are required.
func (*StorageService) CreatePodSandbox ¶
func (ss *StorageService) CreatePodSandbox(podName, podID string, pauseImage NameTag, containerName, metadataName, uid, namespace string, attempt uint32, privileged bool) (ContainerInfo, error)
CreatePodSandbox creates a pod infrastructure container, using the specified PodID for the infrastructure container's ID. In the CRI view of things, a sandbox is distinct from its containers, including its infrastructure container, but at this level the sandbox is essentially the same as its infrastructure container, with a container's membership in a pod being signified by it listing the same pod ID in its metadata that the pod's other members do, and with the pod's infrastructure container having the same value for both its pod's ID and its container ID. Pointer arguments can be nil. All other arguments are required.
func (*StorageService) DeleteContainer ¶
func (ss *StorageService) DeleteContainer(ctx context.Context, idOrName string) error
DeleteContainer deletes a container, unmounting it first if need be. If there is no matching container, or if the container exists but its layer does not, an error will be returned.
func (*StorageService) DeleteImage ¶
func (ss *StorageService) DeleteImage(id string) error
DeleteImage deletes a storage image (impacting all its tags)
func (*StorageService) FromContainerDirectory ¶
func (ss *StorageService) FromContainerDirectory(id, file string) ([]byte, error)
FromContainerDirectory is a convenience function which reads the contents of the specified file relative to the container's directory.
func (*StorageService) GarbageCollect ¶
func (ss *StorageService) GarbageCollect() error
Tries to clean up remainders of previous containers or layers that are not references in the json files. These can happen in the case of unclean shutdowns or regular restarts in transient store mode.
func (*StorageService) GetBundleByID ¶
func (ss *StorageService) GetBundleByID(id string) (bundle *bundle.Bundle, err error)
func (*StorageService) GetContainerMetadata ¶
func (ss *StorageService) GetContainerMetadata(idOrName string) (RuntimeContainerMetadata, error)
GetContainerMetadata returns the metadata we've stored for a container.
func (*StorageService) GetUsage ¶
func (ss *StorageService) GetUsage(id string) (bytesUsed uint64, inodeUsed uint64)
func (*StorageService) ImageStatusByID ¶
func (ss *StorageService) ImageStatusByID(id string) (img *types.Image, err error)
ImageStatusByID returns status of a single image
func (*StorageService) ImageStatusByName ¶
func (ss *StorageService) ImageStatusByName(name NameTag) (img *types.Image, err error)
ImageStatusByName returns status of an image tagged with name.
func (*StorageService) ListImages ¶
func (ss *StorageService) ListImages() (result []*types.Image, err error)
ListImages returns list of all images.
func (*StorageService) MountImage ¶
func (ss *StorageService) MountImage(id string, mountOptions []string, mountLabel string) (string, error)
MountImage mounts an image to temp directory and returns the mount point. MountImage allows caller to mount an image. Images will always be mounted read/only
func (*StorageService) Root ¶
func (ss *StorageService) Root() string
func (*StorageService) SetContainerMetadata ¶
func (ss *StorageService) SetContainerMetadata(idOrName string, metadata *RuntimeContainerMetadata) error
SetContainerMetadata updates the metadata we've stored for a container.
func (*StorageService) UnmountImage ¶
func (ss *StorageService) UnmountImage(id string, force bool) (bool, error)
Unmount attempts to unmount an image, given an ID. Returns whether or not the layer is still mounted. WARNING: The return value may already be obsolete by the time it is available to the caller, so it can be used for heuristic sanity checks at best. It should almost always be ignored.
func (*StorageService) UntagImage ¶
func (ss *StorageService) UntagImage(name NameTag) error
UntagImage removes a name from the specified image, and if it was the only name the image had, removes the image.
func (*StorageService) UpdatePinnedImagesList ¶
func (ss *StorageService) UpdatePinnedImagesList(imageList []string)
UpdatePinnedImagesList updates pinned and pause images list in imageService.