Skip to main content

garbage_collections

Creates, updates, deletes, gets or lists a garbage_collections resource.

Overview

Namegarbage_collections
TypeResource
Iddigitalocean.container_registry.garbage_collections

Fields

The following fields are returned by SELECT queries:

The response will be a JSON object with a key of garbage_collections. This will be set to an array containing objects representing each past garbage collection. Each will contain the standard Garbage Collection attributes.

NameDatatypeDescription
registry_namestringThe name of the container registry. (example: example)
blobs_deletedintegerThe number of blobs deleted as a result of this garbage collection.
created_atstring (date-time)The time the garbage collection was created. (example: 2020-10-30T21:03:24Z)
freed_bytesintegerThe number of bytes freed as a result of this garbage collection.
statusstringThe current status of this garbage collection. (example: requested)
updated_atstring (date-time)The time the garbage collection was last updated. (example: 2020-10-30T21:03:44Z)
uuidstringA string specifying the UUID of the garbage collection. (example: eff0feee-49c7-4e8f-ba5c-a320c109c8a8)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
registries_list_garbage_collectionsselectregistry_nameper_page, pageTo get information about past garbage collections for a registry, send a GET request to /v2/registry/$REGISTRY_NAME/garbage-collections.
registries_update_garbage_collectionreplaceregistry_name, garbage_collection_uuidTo cancel the currently-active garbage collection for a registry, send a PUT request to /v2/registries/$REGISTRY_NAME/garbage-collection/$GC_UUID and specify one or more of the attributes below. It is similar to PUT /v2/registries/$REGISTRY_NAME/garbage-collection/$GC_UUID and exists for backward compatibility.
registries_run_garbage_collectionexecregistry_nameGarbage collection enables users to clear out unreferenced blobs (layer &
manifest data) after deleting one or more manifests from a repository. If
there are no unreferenced blobs resulting from the deletion of one or more
manifests, garbage collection is effectively a noop.
See here for more information
about how and why you should clean up your container registry periodically.

To request a garbage collection run on your registry, send a POST request to
/v2/registries/$REGISTRY_NAME/garbage-collection. This will initiate the
following sequence of events on your registry.

* Set the registry to read-only mode, meaning no further write-scoped
JWTs will be issued to registry clients. Existing write-scoped JWTs will
continue to work until they expire which can take up to 15 minutes.
* Wait until all existing write-scoped JWTs have expired.
* Scan all registry manifests to determine which blobs are unreferenced.
* Delete all unreferenced blobs from the registry.
* Record the number of blobs deleted and bytes freed, mark the garbage
collection status as success.
* Remove the read-only mode restriction from the registry, meaning write-scoped
JWTs will once again be issued to registry clients.
registry_run_garbage_collection_legacyexecregistry_nameGarbage collection enables users to clear out unreferenced blobs (layer &
manifest data) after deleting one or more manifests from a repository. If
there are no unreferenced blobs resulting from the deletion of one or more
manifests, garbage collection is effectively a noop.
See here for more information
about how and why you should clean up your container registry periodically.

To request a garbage collection run on your registry, send a POST request to
/v2/registry/$REGISTRY_NAME/garbage-collection. This will initiate the
following sequence of events on your registry.

* Set the registry to read-only mode, meaning no further write-scoped
JWTs will be issued to registry clients. Existing write-scoped JWTs will
continue to work until they expire which can take up to 15 minutes.
* Wait until all existing write-scoped JWTs have expired.
* Scan all registry manifests to determine which blobs are unreferenced.
* Delete all unreferenced blobs from the registry.
* Record the number of blobs deleted and bytes freed, mark the garbage
collection status as success.
* Remove the read-only mode restriction from the registry, meaning write-scoped
JWTs will once again be issued to registry clients.
registry_get_garbage_collection_legacyexecregistry_nameTo get information about the currently-active garbage collection for a registry, send a GET request to /v2/registry/$REGISTRY_NAME/garbage-collection.
registry_list_garbage_collections_legacyexecregistry_nameper_page, pageTo get information about past garbage collections for a registry, send a GET request to /v2/registry/$REGISTRY_NAME/garbage-collections.
registry_update_garbage_collection_legacyexecregistry_name, garbage_collection_uuidTo cancel the currently-active garbage collection for a registry, send a PUT request to /v2/registry/$REGISTRY_NAME/garbage-collection/$GC_UUID and specify one or more of the attributes below.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
garbage_collection_uuidstringThe UUID of a garbage collection run. (example: eff0feee-49c7-4e8f-ba5c-a320c109c8a8)
registry_namestringThe name of a container registry. (example: example)
pageintegerWhich 'page' of paginated results to return. (example: 1)
per_pageintegerNumber of items returned per page (example: 2)

SELECT examples

To get information about past garbage collections for a registry, send a GET request to /v2/registry/$REGISTRY_NAME/garbage-collections.

SELECT
registry_name,
blobs_deleted,
created_at,
freed_bytes,
status,
updated_at,
uuid
FROM digitalocean.container_registry.garbage_collections
WHERE registry_name = '{{ registry_name }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}';

REPLACE examples

To cancel the currently-active garbage collection for a registry, send a PUT request to /v2/registries/$REGISTRY_NAME/garbage-collection/$GC_UUID and specify one or more of the attributes below. It is similar to PUT /v2/registries/$REGISTRY_NAME/garbage-collection/$GC_UUID and exists for backward compatibility.

REPLACE digitalocean.container_registry.garbage_collections
SET
data__cancel = {{ cancel }}
WHERE
registry_name = '{{ registry_name }}' --required
AND garbage_collection_uuid = '{{ garbage_collection_uuid }}' --required
RETURNING
garbage_collection;

Lifecycle Methods

Garbage collection enables users to clear out unreferenced blobs (layer &
manifest data) after deleting one or more manifests from a repository. If
there are no unreferenced blobs resulting from the deletion of one or more
manifests, garbage collection is effectively a noop.
See here for more information
about how and why you should clean up your container registry periodically.

To request a garbage collection run on your registry, send a POST request to
/v2/registries/$REGISTRY_NAME/garbage-collection. This will initiate the
following sequence of events on your registry.

* Set the registry to read-only mode, meaning no further write-scoped
JWTs will be issued to registry clients. Existing write-scoped JWTs will
continue to work until they expire which can take up to 15 minutes.
* Wait until all existing write-scoped JWTs have expired.
* Scan all registry manifests to determine which blobs are unreferenced.
* Delete all unreferenced blobs from the registry.
* Record the number of blobs deleted and bytes freed, mark the garbage
collection status as success.
* Remove the read-only mode restriction from the registry, meaning write-scoped
JWTs will once again be issued to registry clients.

EXEC digitalocean.container_registry.garbage_collections.registries_run_garbage_collection 
@registry_name='{{ registry_name }}' --required;