containerd

package
v27.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 85 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImageManifest

type ImageManifest struct {
	containerd.Image

	// Parent of the manifest (index/manifest list)
	RealTarget ocispec.Descriptor
	// contains filtered or unexported fields
}

ImageManifest implements the containerd.Image interface, but all operations act on the specific manifest instead of the index as opposed to the struct returned by containerd.NewImageWithPlatform.

func (*ImageManifest) CheckContentAvailable

func (im *ImageManifest) CheckContentAvailable(ctx context.Context) (bool, error)

func (*ImageManifest) ImagePlatform

func (m *ImageManifest) ImagePlatform(ctx context.Context) (ocispec.Platform, error)

ImagePlatform returns the platform of the image manifest. If the manifest list doesn't have a platform filled, it will be read from the config.

func (*ImageManifest) IsAttestation

func (im *ImageManifest) IsAttestation() bool

func (*ImageManifest) IsPseudoImage

func (im *ImageManifest) IsPseudoImage(ctx context.Context) (bool, error)

IsPseudoImage returns false when any of the below is true: - The manifest has no layers - None of its layers is a known image layer. - The manifest has unknown/unknown platform.

Some manifests use the image media type for compatibility, even if they are not a real image.

func (*ImageManifest) Manifest

func (im *ImageManifest) Manifest(ctx context.Context) (ocispec.Manifest, error)

func (*ImageManifest) Metadata

func (im *ImageManifest) Metadata() containerdimages.Image

type ImageService

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

ImageService implements daemon.ImageService

func NewService

func NewService(config ImageServiceConfig) *ImageService

NewService creates a new ImageService.

func (*ImageService) Changes

func (i *ImageService) Changes(ctx context.Context, container *container.Container) ([]archive.Change, error)

func (*ImageService) Children

func (i *ImageService) Children(ctx context.Context, id image.ID) ([]image.ID, error)

Children returns a slice of image IDs that are children of the `id` image

func (*ImageService) Cleanup

func (i *ImageService) Cleanup() error

Cleanup resources before the process is shutdown. called from daemon.go Daemon.Shutdown()

func (*ImageService) CommitBuildStep

func (i *ImageService) CommitBuildStep(ctx context.Context, c backend.CommitConfig) (image.ID, error)

CommitBuildStep is used by the builder to create an image for each step in the build.

This method is different from CreateImageFromContainer:

  • it doesn't attempt to validate container state
  • it doesn't send a commit action to metrics
  • it doesn't log a container commit event

This is a temporary shim. Should be removed when builder stops using commit.

func (*ImageService) CommitImage

func (i *ImageService) CommitImage(ctx context.Context, cc backend.CommitConfig) (image.ID, error)

CommitImage creates a new image from a commit config.

func (*ImageService) CountImages

func (i *ImageService) CountImages(ctx context.Context) int

CountImages returns the number of images stored by ImageService called from info.go

func (*ImageService) CreateImage

func (i *ImageService) CreateImage(ctx context.Context, config []byte, parent string, layerDigest digest.Digest) (builder.Image, error)

CreateImage creates a new image by adding a config and ID to the image store. This is similar to LoadImage() except that it receives JSON encoded bytes of an image instead of a tar archive.

func (*ImageService) CreateLayer

func (i *ImageService) CreateLayer(container *container.Container, initFunc layer.MountInit) (layer.RWLayer, error)

CreateLayer creates a filesystem layer for a container. called from create.go TODO: accept an opt struct instead of container?

func (*ImageService) DistributionServices

func (i *ImageService) DistributionServices() dimages.DistributionServices

DistributionServices return services controlling daemon image storage.

func (*ImageService) ExportImage

func (i *ImageService) ExportImage(ctx context.Context, names []string, outStream io.Writer) error

ExportImage exports a list of images to the given output stream. The exported images are archived into a tar when written to the output stream. All images with the given tag and all versions containing the same tag are exported. names is the set of tags to export, and outStream is the writer which the images are written to.

TODO(thaJeztah): produce JSON stream progress response and image events; see https://github.com/moby/moby/issues/43910

func (*ImageService) GetContainerLayerSize

func (i *ImageService) GetContainerLayerSize(ctx context.Context, containerID string) (int64, int64, error)

GetContainerLayerSize returns the real size & virtual size of the container.

func (*ImageService) GetImage

func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error)

GetImage returns an image corresponding to the image referred to by refOrID.

func (*ImageService) GetImageAndReleasableLayer

func (i *ImageService) GetImageAndReleasableLayer(ctx context.Context, refOrID string, opts backend.GetImageAndLayerOptions) (builder.Image, builder.ROLayer, error)

GetImageAndReleasableLayer returns an image and releaseable layer for a reference or ID. Every call to GetImageAndReleasableLayer MUST call releasableLayer.Release() to prevent leaking of layers.

func (*ImageService) GetImageManifest

func (i *ImageService) GetImageManifest(ctx context.Context, refOrID string, options backend.GetImageOpts) (*ocispec.Descriptor, error)

func (*ImageService) GetLayerFolders

func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer, containerID string) ([]string, error)

GetLayerFolders returns the layer folders from an image RootFS.

func (*ImageService) GetLayerMountID

func (i *ImageService) GetLayerMountID(cid string) (string, error)

GetLayerMountID returns the mount ID for a layer called from daemon.go Daemon.Shutdown(), and Daemon.Cleanup() (cleanup is actually continerCleanup) TODO: needs to be refactored to Unmount (see callers), or removed and replaced with GetLayerByID

func (*ImageService) ImageDelete

func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) (response []imagetypes.DeleteResponse, retErr error)

ImageDelete deletes the image referenced by the given imageRef from this daemon. The given imageRef can be an image ID, ID prefix, or a repository reference (with an optional tag or digest, defaulting to the tag name "latest"). There is differing behavior depending on whether the given imageRef is a repository reference or not.

If the given imageRef is a repository reference then that repository reference will be removed. However, if there exists any containers which were created using the same image reference then the repository reference cannot be removed unless either there are other repository references to the same image or force is true. Following removal of the repository reference, the referenced image itself will attempt to be deleted as described below but quietly, meaning any image delete conflicts will cause the image to not be deleted and the conflict will not be reported.

There may be conflicts preventing deletion of an image and these conflicts are divided into two categories grouped by their severity:

Hard Conflict:

  • any running container using the image.

Soft Conflict:

  • any stopped container using the image.
  • any repository tag or digest references to the image.

The image cannot be removed if there are any hard conflicts and can be removed if there are soft conflicts only if force is true.

If prune is true, ancestor images will each attempt to be deleted quietly, meaning any delete conflicts will cause the image to not be deleted and the conflict will not be reported.

TODO(thaJeztah): image delete should send prometheus counters; see https://github.com/moby/moby/issues/45268

func (*ImageService) ImageHistory

func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*imagetype.HistoryResponseItem, error)

ImageHistory returns a slice of HistoryResponseItem structures for the specified image name by walking the image lineage.

func (*ImageService) Images

Images returns a filtered list of images.

TODO(thaJeztah): verify behavior of `RepoDigests` and `RepoTags` for images without (untagged) or multiple tags; see https://github.com/moby/moby/issues/43861 TODO(thaJeztah): verify "Size" vs "VirtualSize" in images; see https://github.com/moby/moby/issues/43862

func (*ImageService) ImagesPrune

func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*image.PruneReport, error)

ImagesPrune removes unused images

func (*ImageService) ImportImage

func (i *ImageService) ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (image.ID, error)

ImportImage imports an image, getting the archived layer data from layerReader. Layer archive is imported as-is if the compression is gzip or zstd. Uncompressed, xz and bzip2 archives are recompressed into gzip. The image is tagged with the given reference. If the platform is nil, the default host platform is used. The message is used as the history comment. Image configuration is derived from the dockerfile instructions in changes.

func (*ImageService) LayerDiskUsage

func (i *ImageService) LayerDiskUsage(ctx context.Context) (int64, error)

LayerDiskUsage returns the number of bytes used by layer stores called from disk_usage.go

func (*ImageService) LayerStoreStatus

func (i *ImageService) LayerStoreStatus() [][2]string

LayerStoreStatus returns the status for each layer store called from info.go

func (*ImageService) LoadImage

func (i *ImageService) LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error

LoadImage uploads a set of images into the repository. This is the complement of ExportImage. The input stream is an uncompressed tar ball containing images and metadata.

func (*ImageService) LogImageEvent

func (i *ImageService) LogImageEvent(imageID, refName string, action events.Action)

LogImageEvent generates an event related to an image with only the default attributes.

func (*ImageService) MakeImageCache

func (i *ImageService) MakeImageCache(ctx context.Context, sourceRefs []string) (builder.ImageCache, error)

MakeImageCache creates a stateful image cache.

func (*ImageService) Mount

func (i *ImageService) Mount(ctx context.Context, container *container.Container) error

Mount mounts the container filesystem in a temporary location, use defer imageService.Unmount to unmount the filesystem when calling this

func (*ImageService) NewImageManifest

func (i *ImageService) NewImageManifest(ctx context.Context, img containerdimages.Image, manifestDesc ocispec.Descriptor) (*ImageManifest, error)

func (*ImageService) PerformWithBaseFS

func (i *ImageService) PerformWithBaseFS(ctx context.Context, c *container.Container, fn func(root string) error) error

func (*ImageService) PrepareSnapshot

func (i *ImageService) PrepareSnapshot(ctx context.Context, id string, parentImage string, platform *ocispec.Platform, setupInit func(string) error) error

PrepareSnapshot prepares a snapshot from a parent image for a container

func (*ImageService) PullImage

func (i *ImageService) PullImage(ctx context.Context, baseRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registrytypes.AuthConfig, outStream io.Writer) (retErr error)

PullImage initiates a pull operation. baseRef is the image to pull. If reference is not tagged, all tags are pulled.

func (*ImageService) PushImage

func (i *ImageService) PushImage(ctx context.Context, sourceRef reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) (retErr error)

PushImage initiates a push operation of the image pointed to by sourceRef. If reference is untagged, all tags from the reference repository are pushed. Image manifest (or index) is pushed as is, which will probably fail if you don't have all content referenced by the index. Cross-repo mounts will be attempted for non-existing blobs.

It will also add distribution source labels to the pushed content pointing to the new target repository. This will allow subsequent pushes to perform cross-repo mounts of the shared content when pushing to a different repository on the same registry.

func (*ImageService) ReleaseLayer

func (i *ImageService) ReleaseLayer(rwlayer layer.RWLayer) error

ReleaseLayer releases a layer allowing it to be removed called from delete.go Daemon.cleanupContainer(), and Daemon.containerExport()

func (*ImageService) ResolveImage

func (i *ImageService) ResolveImage(ctx context.Context, refOrID string) (containerdimages.Image, error)

ResolveImage looks up an image by reference or identifier in the image store.

func (*ImageService) SquashImage

func (i *ImageService) SquashImage(id, parent string) (string, error)

SquashImage creates a new image with the diff of the specified image and the specified parent. This new image contains only the layers from its parent + 1 extra layer which contains the diff of all the layers in between. The existing image(s) is not destroyed. If no parent is specified, a new image with the diff of all the specified image's layers merged into a new layer that has no parents.

func (*ImageService) StorageDriver

func (i *ImageService) StorageDriver() string

StorageDriver returns the name of the default storage-driver (snapshotter) used by the ImageService.

func (*ImageService) TagImage

func (i *ImageService) TagImage(ctx context.Context, imageID image.ID, newTag reference.Named) error

TagImage creates an image named as newTag and targeting the given descriptor id.

func (*ImageService) Unmount

func (i *ImageService) Unmount(ctx context.Context, container *container.Container) error

Unmount unmounts the container base filesystem

func (*ImageService) UpdateConfig

func (i *ImageService) UpdateConfig(maxDownloads, maxUploads int)

UpdateConfig values

called from reload.go

type ImageServiceConfig

type ImageServiceConfig struct {
	Client          *containerd.Client
	Containers      container.Store
	Snapshotter     string
	RegistryHosts   docker.RegistryHosts
	Registry        registryResolver
	EventsService   *daemonevents.Events
	RefCountMounter snapshotter.Mounter
	IDMapping       idtools.IdentityMapping
}

Jump to

Keyboard shortcuts

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