In an OCI registry, images are promoted by copying the stg tag to prd, and production ran an image QA never tested; what happened and how do you fix promotion?
answer
- when is the tag resolved
- tags are movable by default
- QA approved a digest, not a tag
- copy by digest into a locked project
- immutable release tags
basics
~20 sCopying a tag copies whatever digest it points to at copy time. CI pushed a newer build to stg after approval, so that build was promoted. Promote the approved digest into a release repository CI cannot write, with immutable tags.
solid answer
~40 sA tag is a movable name for a manifest digest, and by default a registry lets anyone with push rights re-point it. Retagging `stg` to `prd` resolves `stg` at the moment of the copy, not at the moment QA approved it, so a CI push in between promoted an untested digest. Confirm it by comparing the digest production runs with the digest in QA's approval record and the registry's push events. The fix is on the repository side: record the approved **digest**, promote by that digest, write it into a release project or repository CI cannot push to, give it a version tag as well as any moving alias, and make release version tags immutable, as Harbor's tag immutability rules allow. Deployments then reference the digest.
code
http · 8 linesPOST /v2/release/app/blobs/uploads/?mount=sha256:<layer-digest>&from=staging/app
-> 201 Created
PUT /v2/release/app/manifests/1.4.2
Content-Type: application/vnd.oci.image.manifest.v1+json
<the exact manifest bytes fetched from staging/app@sha256:<approved-digest>>
-> 201 Created
Docker-Content-Digest: sha256:<approved-digest>go deeper
Recall that a tag is a movable pointer to a digest, so copying a tag copies whatever it points to at that moment.
Explain why the approval must name a digest, and how a release repository with a version tag differs from a moving alias.
Diagnose the incident from digests and push history, then fix promotion: copy by digest, release project CI cannot write, immutable version tags, deployments pinned by digest.
Decide the organisation-wide rule: what the approval record must contain, which tags are immutable, and which identity alone may create them.
## What a tag is to the registry In an **OCI registry**, an image is a **manifest** stored under its **digest**, a hash of the manifest's exact bytes. A **tag** is a human-readable pointer to a manifest; the distribution specification describes it as a custom pointer, and one digest may have zero, one or many tags. Nothing in the specification ties a tag to one digest forever. Harbor's documentation says it plainly: by default, users can repeatedly push an artifact with the same tag, the tag migrates to the new artifact, and the old one becomes tagless. ## What went wrong The team promoted by **retagging**: take the image tagged `stg` and give it the tag `prd`. That operation resolves `stg` to a digest **when it runs**. The sequence was: 1. CI pushed build A to `app:stg`; QA tested and approved it. 2. CI pushed build B to `app:stg`, re-pointing the tag. 3. The promotion job copied `app:stg` to `app:prd` and picked up build B. 4. Production deployed `prd` and ran B, which no one had tested. No one overwrote anything maliciously. The process approved a **tag** while the thing that ships is a **digest**. ## How to confirm it - Read the digest production actually runs from the deployment or node. - Compare it with the digest recorded when QA signed off. If QA recorded only a tag, that is the first defect. - Check the registry's push history for `stg` between approval and promotion; a push in that window is the cause. ## Fixing promotion on the repository side - **Approve a digest.** The QA record must name the manifest digest, not the tag. - **Promote by digest.** The copy reads the source as `name@sha256:...`, so later pushes to `stg` cannot change what is promoted. - **Promote into a separate release repository or project** that CI cannot write to, so only the promotion identity can create release tags there. - **Give it a version tag** such as `1.4.2`, not only a moving alias such as `prd`. A moving alias re-points on every promotion, so rolling back needs a name nobody moves. - **Make release version tags immutable.** In Harbor, a **tag immutability rule** on the release project stops a matching tag from being re-pushed, re-tagged or overwritten by replication, and prevents deleting the artifact that holds it. Rules match repositories and tags with patterns, combine with OR logic, and a project allows up to 15. Leave the moving alias out of the rule. - **Deploy by digest**, so even a tag that does move cannot change what runs. ## What a digest-preserving copy needs The digest survives a copy only if the manifest bytes are copied unchanged. The distribution specification requires a registry to store a pushed manifest in the exact byte representation the client provided, so a tool that fetches the manifest by digest and pushes the same bytes keeps the digest. A tool that converts or rewrites the manifest produces a new digest, and the promoted image then no longer matches the approval record. Order matters too. Blobs are pushed before the manifest that lists them, and the specification allows a registry to reject a manifest whose descriptors point at blobs it does not hold, with a `MANIFEST_BLOB_UNKNOWN` error. So a promotion that copies only the manifest can fail, or leave a release tag that cannot be pulled, depending on the registry. Inside one registry, the layers do not need re-uploading: the release repository can mount each blob from staging with `POST /v2/<name>/blobs/uploads/?mount=<digest>&from=<other_name>`, then the manifest is pushed under the new tag. Between registries, the blobs are transferred, and generic clients such as ORAS copy by digest; `oras cp` copies every manifest of an image index, and copying the image's referrers as well needs its `-r` option, which ORAS marks as preview. ## Summary | Practice | Retag `stg` to `prd` | Copy approved digest to release | |---|---|---| | What gets promoted | whatever `stg` points to now | exactly what QA approved | | Who can create release tags | anyone who can push to the project | only the promotion identity | | Can the release tag move later | yes, by default | no, with an immutability rule | | Rollback target | lost when `prd` moves | the immutable version tag |
- If the release tags are immutable, how do you still keep a moving prd or stable alias?Exclude the alias from the immutability rule. Harbor rules match tags by pattern and can exclude names, so version tags such as 1.4.2 are locked while an alias can still be re-pointed by the promotion identity. Deployments should pin the digest or the version tag, never the alias.
- Why might a promoted image's digest differ in the target registry even though nobody rebuilt it?Because the copy rewrote the manifest. The digest is a hash of the manifest bytes, so any tool that converts the manifest's format or re-serialises it creates a new digest. A faithful copy fetches the manifest by digest and pushes the same bytes, which the registry must store unchanged.
- Retagging copies the digest that was current when QA approved it.
- An OCI registry never lets a tag point to a different digest.
- Copying an image to another registry always changes its digest.
- One moving prd tag is enough to roll back safely.
- Tag immutability prevents adding any further tag to the same artifact.