prune

package
v3.6.137-1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReferencedImageEdgeKind defines a "strong" edge where the tail is an
	// ImageNode, with strong indicating that the ImageNode tail is not a
	// candidate for pruning.
	ReferencedImageEdgeKind = "ReferencedImage"
	// WeakReferencedImageEdgeKind defines a "weak" edge where the tail is
	// an ImageNode, with weak indicating that this particular edge does
	// not keep an ImageNode from being a candidate for pruning.
	WeakReferencedImageEdgeKind = "WeakReferencedImage"

	// ReferencedImageConfigEdgeKind defines an edge from an ImageStreamNode or an
	// ImageNode to an ImageComponentNode.
	ReferencedImageConfigEdgeKind = "ReferencedImageConfig"

	// ReferencedImageLayerEdgeKind defines an edge from an ImageStreamNode or an
	// ImageNode to an ImageComponentNode.
	ReferencedImageLayerEdgeKind = "ReferencedImageLayer"
)

TODO these edges should probably have an `Add***Edges` method in images/graph and be moved there

Variables

This section is empty.

Functions

This section is empty.

Types

type BlobDeleter added in v1.3.0

type BlobDeleter interface {
	// DeleteBlob uses registryClient to ask the registry at registryURL
	// to remove the blob.
	DeleteBlob(registryClient *http.Client, registryURL, blob string) error
}

BlobDeleter knows how to delete a blob from the Docker registry.

func NewBlobDeleter added in v1.3.0

func NewBlobDeleter() BlobDeleter

NewBlobDeleter creates a new blobDeleter.

type ImageDeleter added in v1.3.0

type ImageDeleter interface {
	// DeleteImage removes the image from OpenShift's storage.
	DeleteImage(image *imageapi.Image) error
}

ImageDeleter knows how to remove images from OpenShift.

func NewImageDeleter added in v1.3.0

func NewImageDeleter(images client.ImageInterface) ImageDeleter

NewImageDeleter creates a new imageDeleter.

type ImageStreamDeleter added in v1.3.0

type ImageStreamDeleter interface {
	// DeleteImageStream removes all references to the image from the image
	// stream's status.tags. The updated image stream is returned.
	DeleteImageStream(stream *imageapi.ImageStream, image *imageapi.Image, updatedTags []string) (*imageapi.ImageStream, error)
}

ImageStreamDeleter knows how to remove an image reference from an image stream.

func NewImageStreamDeleter added in v1.3.0

func NewImageStreamDeleter(streams client.ImageStreamsNamespacer) ImageStreamDeleter

NewImageStreamDeleter creates a new imageStreamDeleter.

type LayerLinkDeleter added in v1.4.0

type LayerLinkDeleter interface {
	// DeleteLayerLink uses registryClient to ask the registry at registryURL to
	// delete the repository layer link.
	DeleteLayerLink(registryClient *http.Client, registryURL, repo, linkName string) error
}

LayerLinkDeleter knows how to delete a repository layer link from the Docker registry.

func NewLayerLinkDeleter added in v1.4.0

func NewLayerLinkDeleter() LayerLinkDeleter

NewLayerLinkDeleter creates a new layerLinkDeleter.

type ManifestDeleter added in v1.3.0

type ManifestDeleter interface {
	// DeleteManifest uses registryClient to ask the registry at registryURL to
	// delete the repository's image manifest data.
	DeleteManifest(registryClient *http.Client, registryURL, repo, manifest string) error
}

ManifestDeleter knows how to delete image manifest data for a repository from the Docker registry.

func NewManifestDeleter added in v1.3.0

func NewManifestDeleter() ManifestDeleter

NewManifestDeleter creates a new manifestDeleter.

type Pruner added in v1.3.0

type Pruner interface {
	// Prune uses imagePruner, streamPruner, layerLinkPruner, blobPruner, and
	// manifestPruner to remove images that have been identified as candidates
	// for pruning based on the Pruner's internal pruning algorithm.
	// Please see NewPruner for details on the algorithm.
	Prune(imagePruner ImageDeleter, streamPruner ImageStreamDeleter, layerLinkPruner LayerLinkDeleter, blobPruner BlobDeleter, manifestPruner ManifestDeleter) error
}

Pruner knows how to prune istags, images, layers and image configs.

func NewPruner added in v1.3.0

func NewPruner(options PrunerOptions) Pruner

NewPruner creates a Pruner.

Images younger than keepYoungerThan and images referenced by image streams and/or pods younger than keepYoungerThan are preserved. All other images are candidates for pruning. For example, if keepYoungerThan is 60m, and an ImageStream is only 59 minutes old, none of the images it references are eligible for pruning.

keepTagRevisions is the number of revisions per tag in an image stream's status.tags that are preserved and ineligible for pruning. Any revision older than keepTagRevisions is eligible for pruning.

pruneOverSizeLimit is a boolean flag speyfing that all images exceeding limits defined in their namespace will be considered for pruning. Important to note is the fact that this flag does not work in any combination with the keep* flags.

images, streams, pods, rcs, bcs, builds, and dcs are the resources used to run the pruning algorithm. These should be the full list for each type from the cluster; otherwise, the pruning algorithm might result in incorrect calculations and premature pruning.

The ImageDeleter performs the following logic:

remove any image that was created at least *n* minutes ago and is *not* currently referenced by:

- any pod created less than *n* minutes ago - any image stream created less than *n* minutes ago - any running pods - any pending pods - any replication controllers - any deployment configs - any build configs - any builds - the n most recent tag revisions in an image stream's status.tags

including only images with the annotation openshift.io/image.managed=true unless allImages is true.

When removing an image, remove all references to the image from all ImageStreams having a reference to the image in `status.tags`.

Also automatically remove any image layer that is no longer referenced by any images.

type PrunerOptions added in v1.3.0

type PrunerOptions struct {
	// KeepYoungerThan indicates the minimum age an Image must be to be a
	// candidate for pruning.
	KeepYoungerThan *time.Duration
	// KeepTagRevisions is the minimum number of tag revisions to preserve;
	// revisions older than this value are candidates for pruning.
	KeepTagRevisions *int
	// PruneOverSizeLimit indicates that images exceeding defined limits (openshift.io/Image)
	// will be considered as candidates for pruning.
	PruneOverSizeLimit *bool
	// AllImages considers all images for pruning, not just those pushed directly to the registry.
	// Requires RegistryURL be set.
	AllImages *bool
	// Namespace to be pruned, if specified it should never remove Images.
	Namespace string
	// Images is the entire list of images in OpenShift. An image must be in this
	// list to be a candidate for pruning.
	Images *imageapi.ImageList
	// Streams is the entire list of image streams across all namespaces in the
	// cluster.
	Streams *imageapi.ImageStreamList
	// Pods is the entire list of pods across all namespaces in the cluster.
	Pods *kapi.PodList
	// RCs is the entire list of replication controllers across all namespaces in
	// the cluster.
	RCs *kapi.ReplicationControllerList
	// BCs is the entire list of build configs across all namespaces in the
	// cluster.
	BCs *buildapi.BuildConfigList
	// Builds is the entire list of builds across all namespaces in the cluster.
	Builds *buildapi.BuildList
	// DCs is the entire list of deployment configs across all namespaces in the
	// cluster.
	DCs *deployapi.DeploymentConfigList
	// LimitRanges is a map of LimitRanges across namespaces, being keys in this map.
	LimitRanges map[string][]*kapi.LimitRange
	// DryRun indicates that no changes will be made to the cluster and nothing
	// will be removed.
	DryRun bool
	// RegistryClient is the http.Client to use when contacting the registry.
	RegistryClient *http.Client
	// RegistryURL is the URL for the registry.
	RegistryURL string
	// Allow a fallback to insecure transport when contacting the registry.
	Insecure bool
}

PrunerOptions contains the fields used to initialize a new Pruner.

Jump to

Keyboard shortcuts

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