prune

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: Apache-2.0 Imports: 22 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 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 LayerDeleter added in v1.3.0

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

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

func NewLayerDeleter added in v1.3.0

func NewLayerDeleter() LayerDeleter

NewLayerDeleter creates a new layerDeleter.

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, layerPruner, 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, layerPruner LayerDeleter,
		blobPruner BlobDeleter, manifestPruner ManifestDeleter) error
}

Pruner knows how to prune images and layers.

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

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