cache

package
v0.0.0-...-cfcd82a Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache creates an image to store cache records in its image manifest, every record presents the relationship like:

source_layer_chainid -> (nydus_blob_layer_digest, nydus_bootstrap_layer_digest) If the converter hit cache record during build source layer, we can skip the layer building, see cache image example: examples/manifest/cache_manifest.json.

Here is the build cache workflow:

  1. Import cache records from registry;
  2. Check cache record using source layer ChainID before layer build, skip layer build if the cache hit;
  3. Export new cache records to registry;

func New

func New(remote *remote.Remote, opt Opt) (*Cache, error)

New creates Nydus cache instance,

func (*Cache) Check

func (cache *Cache) Check(ctx context.Context, layerChainID digest.Digest) (*CacheRecord, io.ReadCloser, io.ReadCloser, error)

Check checks bootstrap & blob layer exists in registry or storage backend

func (*Cache) Export

func (cache *Cache) Export(ctx context.Context) error

Export pushes cache manifest index to remote registry

func (*Cache) Import

func (cache *Cache) Import(ctx context.Context) error

Import pulls cache manifest index from remote registry

func (*Cache) PullBootstrap

func (cache *Cache) PullBootstrap(ctx context.Context, bootstrapDesc *ocispec.Descriptor, target string) error

PullBootstrap pulls bootstrap layer from registry, and unpack to a specified path, we can use it to prepare parent bootstrap for building.

func (*Cache) Push

func (cache *Cache) Push(ctx context.Context, desc ocispec.Descriptor, reader io.Reader) error

Push pushes cache image to registry

func (*Cache) Record

func (cache *Cache) Record(records []*CacheRecord)

Record puts new bootstrap & blob layer to cache record, it's a limited queue.

type CacheManifest

type CacheManifest struct {
	MediaType string `json:"mediaType,omitempty"`
	ocispec.Manifest
}

type CacheRecord

type CacheRecord struct {
	SourceChainID        digest.Digest
	NydusBlobDesc        *ocispec.Descriptor
	NydusBootstrapDesc   *ocispec.Descriptor
	NydusBootstrapDiffID digest.Digest
}

type Opt

type Opt struct {
	// Maximum records(bootstrap layer + blob layer) in cache image.
	MaxRecords uint
	// Make cache image manifest compatible with the docker v2 media
	// type defined in github.com/containerd/containerd/images.
	DockerV2Format bool
	// The blob layer record will not be written to cache image if
	// the backend be specified, because the blob layer will be uploaded
	// to backend.
	Backend backend.Backend
}

Opt configures Nydus cache

Jump to

Keyboard shortcuts

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