Skip to content

Provide stat descriptor for Create method during cross-repo mount #1857

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

Merged

Conversation

miminar
Copy link
Contributor

@miminar miminar commented Jul 20, 2016

In OpenShift, there's a pullthroughBlobStore middleware wrapper that acts like a proxy. It allows to pull blobs from remote registries based on per-repository configuration stored in etcd.

During a cross-repo mount, the linkedBlobStore stats requested blob in the source repository. The repository object used for it doesn't have middleware wrappers, therefore it's impossible to override this behaviour.

With the CreateOptions exposed we are able to intercept the request and handle it in custom way. However, we still need to create the layer link for a successful mount. Sadly, this operation is private.

It's true we could handle this completely on our side (without creating and stat-ing repository links) since we already store most of the metadata in etcd. Unfortunately we're not there yet.

This PR adds a Stat attribute to the create mount options that contains precomputed descriptor that shall be returned by Create method. If set, linkedBlobStore won't do its own Stat call to ensure the presence of the blob.

@miminar
Copy link
Contributor Author

miminar commented Jul 20, 2016

@GordonTheTurtle wins the first round.

@miminar
Copy link
Contributor Author

miminar commented Jul 20, 2016

/cc-ing my favorite victims @stevvooe @RichardScothern

Sorry for asking you to go through this once again. It would really help us.

@codecov-io
Copy link

codecov-io commented Jul 20, 2016

Current coverage is 52.60% (diff: 100%)

Merging #1857 into master will decrease coverage by 2.40%

@@             master      #1857   diff @@
==========================================
  Files            74        120     +46   
  Lines          6910      10515   +3605   
  Methods           0          0           
  Messages          0          0           
  Branches          0          0           
==========================================
+ Hits           3801       5531   +1730   
- Misses         2633       4243   +1610   
- Partials        476        741    +265   

Sunburst

Powered by Codecov. Last update 2b72dd3...c5105cc

@miminar
Copy link
Contributor Author

miminar commented Jul 21, 2016

Kudos to @liggitt who found a much less intrusive change. Basically, the middleware just passes a blob descriptor to the Create method. The blob descriptor shall be returned if the cross-repo mount is requested without a local query for the layer link in the source repository.

@miminar miminar changed the title Allow for overriding repository during cross-repo mount Provide stat descriptor for Create method during cross-repo mount Jul 21, 2016
@miminar miminar force-pushed the cross-mount-repo-override branch from 13371a3 to efa7622 Compare July 21, 2016 13:24
@@ -198,6 +198,7 @@ type CreateOptions struct {
Mount struct {
ShouldMount bool
From reference.Canonical
Stat *Descriptor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document the role of this field?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document the role of this field?

Sure, done.

@stevvooe
Copy link
Collaborator

Basically, the middleware just passes a blob descriptor to the Create method. The blob descriptor shall be returned if the cross-repo mount is requested without a local query for the layer link in the source repository.

Clever.

Presumably, the access control is maintained at a higher level?

liggitt and others added 2 commits July 22, 2016 09:19
@miminar miminar force-pushed the cross-mount-repo-override branch from efa7622 to c5105cc Compare July 22, 2016 07:20
@miminar
Copy link
Contributor Author

miminar commented Jul 22, 2016

Presumably, the access control is maintained at a higher level?

Correct, repository access check is done in access control and the blob access check in repository middleware. Both query etcd.

@RichardScothern
Copy link

👍 to this approach.

@RichardScothern RichardScothern added this to the Registry/2.6 milestone Aug 2, 2016
@RichardScothern
Copy link

LGTM

@RichardScothern RichardScothern merged commit 7365003 into distribution:master Aug 2, 2016
JamesClonk pushed a commit to JamesClonk/distribution that referenced this pull request Aug 10, 2016
…stribution#1857)

* Allow precomputed stats on cross-mounted blobs

Signed-off-by: Michal Minář <[email protected]>

* Extended cross-repo mount tests

Signed-off-by: Michal Minář <[email protected]>
dalsh pushed a commit to dalsh/distribution that referenced this pull request Jan 13, 2017
…stribution#1857)

* Allow precomputed stats on cross-mounted blobs

Signed-off-by: Michal Minář <[email protected]>

* Extended cross-repo mount tests

Signed-off-by: Michal Minář <[email protected]>
sargun added a commit to sargun/distribution that referenced this pull request Sep 20, 2021
In distribution#1857, it was made possible
for middlewares to have the blob store perform cross-mounts. As far as I know,
there was only one middleware using this, Openshift. It was removed from the
openshift registry in:
openshift/image-registry@a0ac6ff

In the future, the cross-mount can be performed using automatic blob
discovery.

Signed-off-by: Sargun Dhillon <[email protected]>
@sargun sargun mentioned this pull request Sep 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants