prune

package
Version: v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2015 License: Apache-2.0 Imports: 21 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"

	// ReferencedImageLayerEdgeKind defines an edge from an ImageStreamNode or an
	// ImageNode to an ImageLayerNode.
	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 BlobPruner added in v1.0.2

type BlobPruner interface {
	// PruneBlob uses registryClient to ask the registry at registryURL to delete
	// the blob.
	PruneBlob(registryClient *http.Client, registryURL, blob string) error
}

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

func NewDeletingBlobPruner added in v1.0.2

func NewDeletingBlobPruner() BlobPruner

NewDeletingLayerPruner creates a new deletingBlobPruner.

type ImagePruner

type ImagePruner interface {
	// PruneImage deletes the image from OpenShift's storage.
	PruneImage(image *imageapi.Image) error
}

ImagePruner knows how to delete images from OpenShift.

func NewDeletingImagePruner added in v1.0.2

func NewDeletingImagePruner(images client.ImageInterface) ImagePruner

NewDeletingImagePruner creates a new deletingImagePruner.

type ImageRegistryPruner added in v1.0.2

type ImageRegistryPruner interface {
	// Prune uses imagePruner, streamPruner, layerPruner, blobPruner, and
	// manifestPruner to remove images that have been identified as candidates
	// for pruning based on the ImageRegistryPruner's internal pruning algorithm.
	// Please see NewImageRegistryPruner for details on the algorithm.
	Prune(imagePruner ImagePruner, streamPruner ImageStreamPruner, layerPruner LayerPruner, blobPruner BlobPruner, manifestPruner ManifestPruner) error
}

ImageRegistryPruner knows how to prune images and layers.

func NewImageRegistryPruner added in v1.0.2

func NewImageRegistryPruner(options ImageRegistryPrunerOptions) ImageRegistryPruner

NewImageRegistryPruner creates a new ImageRegistryPruner.

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.

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 ImagePruner performs the following logic: remove any image containing the annotation openshift.io/image.managed=true 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

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 ImageRegistryPrunerOptions added in v1.0.2

type ImageRegistryPrunerOptions 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
	// 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
	// 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
}

ImageRegistryPrunerOptions contains the fields used to initialize a new ImageRegistryPruner.

type ImageStreamPruner added in v1.0.2

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

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

func NewDeletingImageStreamPruner added in v1.0.2

func NewDeletingImageStreamPruner(streams client.ImageStreamsNamespacer) ImageStreamPruner

NewDeletingImageStreamPruner creates a new deletingImageStreamPruner.

type LayerPruner added in v1.0.2

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

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

func NewDeletingLayerPruner added in v1.0.2

func NewDeletingLayerPruner() LayerPruner

NewDeletingLayerPruner creates a new deletingLayerPruner.

type ManifestPruner added in v1.0.2

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

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

func NewDeletingManifestPruner added in v1.0.2

func NewDeletingManifestPruner() ManifestPruner

NewDeletingManifestPruner creates a new deletingManifestPruner.

Source Files

Jump to

Keyboard shortcuts

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