Skip to content

Ability to hydrate a repository cache #2072

Closed

Description

@renshao

What is the version of your ORAS CLI

1.3.2

What would you like to be added?

Context

oras cp copies artifacts from a source repository to a target repository. However, it does not work reliably when the target is a pull-through cache.

A pull-through cache acts as a proxy for an upstream registry, letting clients pull upstream artifacts without connecting to the upstream directly. All major cloudproviders offer this feature — see Azure ACR Artifact Cache, AWS ECR pull-through cache, and Google Artifact Registry remote repositories.

When a pull-through cache is asked about a manifest it has not yet seen, it transparently fetches it from upstream and reports success, but the cache may only have hydrated a subset of the referenced content (for example, the index manifest plus a single platform's manifest and blobs from a previous docker pull on an amd64 host). The cache effectively reports objects as "present" that are, from oras' perspective, only partially materialized.

Problem

oras cp consults the target before pushing each descriptor and skips any node it reports as already existing. With a pull-through cache target this short-circuit fires on the index manifest, so oras never walks into the referenced platform manifests. The final tag PUT then fails because the registry's own validation finds the missing referenced manifests:

   Error: PUT "https://<cache>.azurecr.io/v2/library/node/manifests/lts-alpine3.23":
   response status code 400: manifest blob unknown:
   blob unknown to registry: sha256:966edd…6095b

There is currently no way to make oras cp traverse the full source graph and push any missing referenced content to a partially-hydrated target.

Proposal

Add an opt-in flag to oras cp that disables the "trust the target's existence response" optimization for manifest descriptors and walks the full source DAG, pushing any referenced manifests or blobs that are missing in the target, before updating the tag.

Working name: --hydrate (alternatives worth discussing: --verify-existing, --ensure-complete, --no-skip-existing).

The flag should be opt-in so the default behavior — and its performance characteristics — remain unchanged.

A new subcommand (oras hydrate) is also worth considering if we expect the semantics to diverge significantly from oras cp over time, but I lean toward a flag for discoverability and to reuse the existing source/target plumbing.

Why is this needed for ORAS?

User story

As a platform engineer mirroring images into a cloud registry that has a pull-through cache enabled, I want oras cp to guarantee the target ends up with the complete artifact, even when the cache has previously been populated by a single-platform docker pull.

Scenario

  1. I configure Azure Container Registry with an Artifact Cache rule for docker.io/library/node.
  2. A teammate runs docker pull /library/node:lts-alpine3.23 from an amd64 host. ACR hydrates only the index manifest and the linux/amd64 platform manifest plus itsblobs.
  3. Later I run oras cp docker.io/library/node:lts-alpine3.23 <acr>/library/node:lts-alpine3.23 to mirror the full multi-arch image. oras cp sees the index manifest as "existing" in ACR, skips traversal, and the tag PUT is rejected with manifest blob unknown for one of the non-amd64 platform manifests.

Today the only workaround is to delete the partial manifest from the target before running oras cp, which requires elevated permissions on the cache and defeats the point of using it.

Are you willing to submit PRs to contribute to this feature?

  • Yes, I am willing to implement it.

Activity

  1. added
    enhancement
    triage
    on Jun 9, 2026
  2. sajayantony commented on Jun 9, 2026

    @sajayantony
    Contributor

    My preference would be --force-push or --no-skip-existing:

    • --force-push is idiomatic for users coming from git-based workflows and correctly implies "push unconditionally"
    • --no-skip-existing is the most self-documenting and makes the default behavior discoverable from the flag name alone

    I'd avoid --hydrate specifically because it describes the effect on the target (filling the cache) rather than the behavior of the command (don't trust existence checks). The latter is more consistent with flag names in tools.

  3. kichalla commented on Jun 9, 2026

    @kichalla

    How about oras cp --force? When importing an image with az cli, user use az acr import --force to indicate what they are doing.

    • --force-push: oras 'copy' and force 'push' do not seem like to gel well even though the underlying effect is similar.
      • Also we have oras manifest push and oras blob push which both hint at pushing from client machine to upstream where as copy is between registries.
    • --no-skip-existing: double negations (no and skip) are usually hard to follow for user and is better to avoid.
  4. renshao commented on Jun 9, 2026

    @renshao
    ContributorAuthor

    I'm happy with both --force and --force-push. I think in this context the 'push' action is implied, so just using --force is clear enough. So, I prefer slightly more --force over --force-push.

  5. akashsinghal commented on Jun 9, 2026

    @akashsinghal

    +1 on --force. will this flag only apply to the cp or will it also apply to push?

  6. renshao commented on Jun 10, 2026

    @renshao
    ContributorAuthor

    +1 on --force. will this flag only apply to the cp or will it also apply to push?

    That's a good point. Currently, oras push has the same optimization logic. We can implement --force flag for both oras cp and oras push, so when it is set they always re-push all blobs and manifests.

  7. TerryHowe commented on Jun 12, 2026

    @TerryHowe
    Member

    If there a need for an oras-go copy.go change for this?

  8. TerryHowe commented on Jul 20, 2026

    @TerryHowe
    Member

    Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementtriage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions