// Module included in the following assemblies:
//
// * applications/pruning-objects.adoc

:_mod-docs-content-type: REFERENCE
[id="pruning-images-conditions_{context}"]
= Image prune conditions

[role="_abstract"]
Review the prerequisites, dependency checks, and soft-delete conditions required before removing registry images to safely prune image layers without breaking active pod deployments.

{product-title} supports two methodologies for pruning images:

. Pruning by age and tag

. Pruning by size limit

These methodologies are mutually exclusive. You must choose whether to prune by age and tag, or by size limit. Regardless of the method that you choose, the image pruner checks to ensure that images in use are not removed.

An image is only pruned if it meets the primary condition *and* is not actively referenced by a system component. 

Image pruning by age and tag::

Pruning an image by age and tag is the default pruning strategy. It identifies images for removal by using the `--keep-younger-than` and `--keep-tag-revisions` flags. To prune an image by age and tag, the image must be older than the `--keep-younger-than` threshold, not one of the most recent tag revisions, and cannot be in use by an active workload.
+
For an image to be pruned by age and tag, *all* of the following conditions must be met:
+
. The image is managed by {product-title} or has the `openshift.io/image.managed` annotation.

. The image is older than the time specified by the `--keep-younger-than` flag. 

. The image is not one of the most recent images for its tag, as specified by the `--keep-tag-revisions` flag. 

. The image is *not* currently referenced by any of the following active or recent API objects:
+
* Pods or image streams created more recently than the `--keep-younger-than` duration.
* Running or pending pods
* Deployments, replication controllers, replica sets, or stateful sets.
* Builds, build configurations, jobs, or cronjobs. 
+
An image is only removed if it is old, not a recent tag revision, and is confirmed to have no active references by system components. 

Image pruning by size limit::

Pruning an image by size limit uses the `--prune-over-size-limit` flag. This method is used to bring a project back under its defined image storage limit.
+
[NOTE]
====
The `--prune-over-size-limit` flag cannot be combined with the `--keep-tag-revisions` flag nor the `--keep-younger-than` flags. Doing so returns information that this operation is not allowed.
====
+
For an image to be pruned using this method, all of the following conditions must be true:

. The image is part of a project that is currently exceeding its smallest defined size limit.

. The image is selected by the pruner as a candidate for deletion to reduce the total size. 

. The image is not currently referenced by any of the following active API objects:
+
* Pods that are in a `running` or `pending` state.
* Deployments, replication controllers, replica sets, or stateful sets.
* Builds, build configurations, jobs, or cronjobs.
+
With this method, the primary trigger is the project's size, but the safety check to ensure that the image is not actively in use is still performed.