skip to content

After an OCI registry garbage collection that also removed untagged manifests, new replicas of a production service cannot pull its digest-pinned image. What happened, and how do you prevent it?

level: seniorimportance: should knowfreq 42%

answer

  1. the tag moved on
  2. registries see tags, not deployments
  3. untagged means eligible
  4. a tag nobody moves
  5. dry run against deployed digests

basics

~20 s

The pinned manifest's only tag moved to a newer build, leaving it untagged, so collection with untagged deletion removed it and swept its unique layers. Prevent it with a retained, never-moved tag per deployed digest and dry runs checked against deployments.

solid answer

~40 s

The deployment pinned a digest, but the only tag on that manifest was a moving one such as `main`. When CI moved the tag, the manifest became untagged, and the collection ran with untagged deletion (`--delete-untagged` in the Distribution registry, *Allow garbage collection on untagged artifacts* in Harbor), so it deleted the manifest and swept the layers nothing else used. A registry only sees references inside itself, never a cluster's pin. Running replicas survived on cached copies; new pulls get `MANIFEST_UNKNOWN`. Recover by copying the image by digest from a replica that still has it, since a rebuild usually yields a new digest. Prevent it by tagging every deployed build with a tag retention always keeps, enabling untagged collection only after that, and diffing each dry run against the digests actually deployed.

go deeper

for a junior

Remember that a registry only keeps what is referenced inside it, and that an untagged manifest can be collected even if something outside still uses its digest.

for a middle

Explain how moving a tag leaves the old manifest untagged, and what --delete-untagged and Harbor's untagged option add to a collection run.

for a senior

Lead the incident: confirm with the collection history and manifest-unknown errors, restore by copying by digest from a surviving replica, then fix retention around tags nobody moves and dry runs diffed against deployed digests.

for a principal

Treat retention as a contract with consumers the registry cannot see, and decide which team owns the inventory of deployed digests that every cleanup must check.

## The incident A service is deployed by digest, as it should be: its deployment references `registry.example.internal/payments@sha256:...`, not a tag. Every CI build pushes a new image and moves a shared tag such as `main` to it. One night the registry's scheduled garbage collection runs with untagged-manifest deletion turned on. The next morning the replicas that were already running are fine, but every **new** replica (a scale-up, a node replacement, a reschedule) fails to pull, and the registry answers `MANIFEST_UNKNOWN`. ## What actually happened The chain has four links, and each one is a registry behaviour working exactly as designed: 1. **A tag moved.** When CI pointed `main` at a newer build, the manifest the deployment pins lost its only tag. It still existed, but it was now **untagged**. 2. **Untagged meant unused.** The collection ran with an untagged option: `--delete-untagged` in the open-source Distribution registry, or **Allow garbage collection on untagged artifacts** in Harbor. Either deletes manifests no tag references before sweeping. 3. **The sweep followed.** With the manifest gone, its layers that no other manifest used were deleted too. 4. **The registry knows tags, not deployments.** Nothing in a registry records that a cluster somewhere pins a digest. "Referenced" means referenced by a tag or another manifest inside the registry. Running replicas survived only because their nodes already held the image locally; any node that needed to pull it hit the deleted manifest. The same failure appears in other tools under other names: - In **Nexus Repository**, the task *Docker - Delete unused manifests and images* soft-deletes manifests no tag references, and its documentation warns that requests by digest carry no tag reference, so digest-only images count as unused. - In **Harbor**, a tag retention rule with the untagged-artifacts checkbox left clear removes untagged artifacts, as the documented examples show. ## Confirming it - Check the collection or retention history: Harbor records every run with its trigger, its dry-run flag and a log link; for the Distribution registry, the collector's own output from that run is the record, so keep it. - Request the pinned digest directly: a `MANIFEST_UNKNOWN` error confirms the manifest itself is gone, not merely a tag. - List what the moved tag pointed at before and after, from CI logs or the registry's event notifications, to confirm the deployed digest lost its tag. ## Recovering What is possible depends on which delete stage the content reached: | Where the content is | Recovery | |---|---| | Nexus soft-deleted, not yet compacted | restorable by an administrator until the compact task runs | | Artifactory local repository with Trash Can enabled | restore from the Trash Can within its retention period | | Harbor or Distribution registry, already collected | gone; stopping a Harbor run restores nothing it already collected | When the bytes are gone, the best option is to **copy the image by digest** from a replica or another registry that still holds it. A copy by digest reproduces the identical manifest, so every existing deployment reference becomes valid again. Rebuilding from the same commit usually produces a different digest, which means changing and re-rolling every deployment that pinned the old one. ## Preventing it - **Give every deployed digest a tag that retention keeps.** A release or deploy tag per build, which nothing ever moves, keeps the manifest referenced. (Making such tags immutable is a registry setting covered with versioning.) - **Write retention rules around those tags.** Harbor's tag retention can **retain always** a tag pattern such as release tags, and because its rules are scoped by repository, production repositories can be left out of rules that remove untagged artifacts. - **Turn on untagged collection last**, only after the first two hold. In the Distribution registry and in Harbor's collector the untagged option covers the whole registry, so it is safe only once every untagged manifest really is a build leftover. - **Diff every dry run against what is deployed.** Export the digests running in every environment and fail the run if any appears in the dry-run's eligible list. - **Keep a recovery window.** A Nexus Blobs Older Than value or an Artifactory Trash Can turns an incident into a restore instead of a rebuild. ## The lesson Digest pinning guarantees **which** bytes a deployment gets; it does not guarantee that the registry keeps them. Retention is a contract between the registry and its consumers, and the registry can only honour references it can see.

  • Why did the replicas already running keep working while new ones failed?
    A node that already ran the image holds its layers locally and does not ask the registry again. Only a node that has to pull, after a scale-up, a node replacement or a reschedule, requests the manifest by digest and receives the registry's manifest-unknown error. The outage grows slowly, which is why it is often noticed late.
  • How do you check, before enabling untagged collection, that nothing deployed depends on an untagged manifest?
    Export every image digest currently running in every environment, then run the collection or retention rule as a dry run and compare its eligible list with that export. Any overlap is a deployment that would break. Fix it by giving those digests a retained tag, and repeat the check before each change to the rules.

  • Pinning an image by digest guarantees the registry will always keep it.
  • Garbage collection removes layers only and never deletes manifests.
  • Any rebuild of the same commit brings back the exact deleted digest.
  • Stopping a running Harbor garbage collection restores what it already deleted.
  • Untagged manifests are always build leftovers that nothing references.