Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous blob mounting #756

Open
ktarplee opened this issue Apr 30, 2024 · 4 comments
Open

Anonymous blob mounting #756

ktarplee opened this issue Apr 30, 2024 · 4 comments
Labels
stale Inactive issues or pull requests

Comments

@ktarplee
Copy link
Contributor

ktarplee commented Apr 30, 2024

For motivation and background see this

From the spec the from field is now optional when doing blob mounts.

The registry MAY treat the from parameter as optional, and it MAY cross-mount the blob if it can be found.

@Wwwsylvia
Copy link
Member

Is this an issue of the distribution-spec? 🤔

@ktarplee
Copy link
Contributor Author

@Wwwsylvia I'm not sure what you mean. It is not an issue with the distribution spec. The spec gives the client more flexibility in that they do not have to provide the from field if they do not want to. Maybe oras-go is handling this already but I did not see it when looking at it earlier. It seems like even in the case where the source repo is unknown, we would want to always try a POST to /v2/<name>/blobs/uploads/?mount=<digest> to try and benefit from a mount.

@Wwwsylvia
Copy link
Member

@ktarplee Thanks for the clarification, I see what you mean now.
blobStore.Mount() accepts an empty value of from,

fromRef.Repository = fromRepo
ctx = auth.AppendRepositoryScope(ctx, fromRef, auth.ActionPull)
url := buildRepositoryBlobMountURL(s.repo.PlainHTTP, s.repo.Reference, desc.Digest, fromRepo)

and oras.Copy only checks if the sourceRepositories slice is empty or not but does not validate each sourceRepository.

oras-go/copy.go

Lines 287 to 296 in 9b6f321

sourceRepositories, err := opts.MountFrom(ctx, desc)
if err != nil {
// Technically this error is not fatal, we can still attempt to copy the node
// But for consistency with the other callbacks we bail out.
return err
}
if len(sourceRepositories) == 0 {
return copyNode(ctx, src, dst, desc, opts)
}

So oras-go technically supports this scenario. Users can do anonymous mounting through something like below:

anonymousMounting := func(ctx context.Context, desc ocispec.Descriptor) ([]string, error) {
      return []string{""}, nil
}
opts := oras.CopyOptions{
      MountFrom = anonymousMounting
}
desc, err := oras.Copy(ctx, src, tagName, dst, tagName, opts)

If needed, we can make if more user friendly though.

Copy link

This issue is stale because it has been open for 60 days with no activity. Remove the stale label or comment to prevent it from being closed in 30 days.

@github-actions github-actions bot added the stale Inactive issues or pull requests label Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Inactive issues or pull requests
Projects
None yet
Development

No branches or pull requests

2 participants