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

Adds cross-repository blob mounting behavior #1269

Merged
merged 3 commits into from Jan 8, 2016

Conversation

BrianBland
Copy link
Contributor

Extends blob upload POST endpoint to support mount and from query
parameters as described in #634

t.Errorf("Unexpected error type stat-ing deleted manifest: %#v", err)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not too difficult, it would be great to have a test that ensures that an attempt to mount a source image outside the authorization scope fails.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can that be broken out into a specific test? It will need a mocked auth implementation to test this properly.

blobs := buh.Repository.Blobs(buh)

if mountDigest != "" && fromRepo != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we put this in a separate method?

@stevvooe
Copy link
Collaborator

@BrianBland Have we updated the specification for these additions?

@RichardScothern
Copy link
Contributor

registry/api/v2/routes.go and docs/spec/api.md.tmpl should be updated

@BrianBland BrianBland force-pushed the crossRepositoryPush branch 2 times, most recently from ac72830 to 9a7e897 Compare December 21, 2015 19:42
defer resp.Body.Close()

if SuccessStatus(resp.StatusCode) {
// TODO(brianbland): Check for possible Accepted response (legacy create)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We also need a mechanism here to create and get httpBlobUpload. Possibly cache it and have the next call to Create use it. Returning it as part of an error does not seem like an ideal solution for fallback.

@codecov-io
Copy link

Current coverage is 57.73%

Merging #1269 into master will decrease coverage by -0.49% as of 613cfc8

@@            master   #1269   diff @@
======================================
  Files          123     123       
  Stmts        10932   11071   +139
  Branches       762     773    +11
  Methods          0       0       
======================================
+ Hit           6365    6392    +27
- Partial        762     773    +11
- Missed        3805    3906   +101

Review entire Coverage Diff as of 613cfc8


Uncovered Suggestions

  1. +0.29% via ...ge/driver/gcs/gcs.go#185...216
  2. +0.29% via ...ge/driver/gcs/gcs.go#104...135
  3. +0.22% via ...ge/driver/gcs/gcs.go#474...497
  4. See 7 more...

Powered by Codecov. Updated on successful CI builds.

@vbatts
Copy link

vbatts commented Dec 23, 2015

cc @jwhonce

@BrianBland BrianBland force-pushed the crossRepositoryPush branch 4 times, most recently from 80c0b4c to 16b3ef1 Compare December 30, 2015 00:37
@@ -1023,7 +1051,7 @@ A list of methods and URIs are covered in the table below:
|------|----|------|-----------|
| GET | `/v2/` | Base | Check that the endpoint implements Docker Registry API V2. |
| GET | `/v2/<name>/tags/list` | Tags | Fetch the tags under the repository identified by `name`. |
| GET | `/v2/<name>/manifests/<reference>` | Manifest | Fetch the manifest identified by `name` and `reference` where `reference` can be a tag or digest. |
| GET | `/v2/<name>/manifests/<reference>` | Manifest | Fetch the manifest identified by `name` and `reference` where `reference` can be a tag or digest. A `HEAD` request can also be issued to this endpoint to obtain resource information without receiving all data. |
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is redundant. That is the definition of a HEAD request. Would it be better to state somewhere at the start that all GET should support HEAD?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, this was already in the api descriptors file but had not been filled into the spec template. We can update this descriptor, but it probably belongs in a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

O, ick. Separate PR. This should be removed.

@BrianBland BrianBland force-pushed the crossRepositoryPush branch 5 times, most recently from d780bdc to d5127c3 Compare January 6, 2016 22:30
@@ -21,6 +21,7 @@ Ben Firshman <ben@firshman.co.uk>
bin liu <liubin0329@gmail.com>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't include AUTHORS update in your PR. We do this at release time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 removing this

@stevvooe
Copy link
Collaborator

stevvooe commented Jan 6, 2016

After writing #1269 (comment), I realized it might be a good idea to have an event specific to the mount call on the target repository. It may be sufficient to use the url to detect this but we may want to consider adding an action.

Looking here, we just need to have an action for "mount" and a source indicating where the mount happened from. Optionally, it may be okay to leave these as "push" but then populate a "from" field on target.

@BrianBland BrianBland force-pushed the crossRepositoryPush branch 4 times, most recently from 88aebc8 to 553d03d Compare January 8, 2016 18:35
Extends blob upload POST endpoint to support mount and from query
parameters as described in distribution#634

Signed-off-by: Brian Bland <brian.bland@docker.com>
When an auth request provides the "from" query parameter, the token
handler will add a "pull" scope for the provided repository, refreshing
the token if the overall scope has increased

Signed-off-by: Brian Bland <brian.bland@docker.com>
Adds an optional "fromRepository" field to the event target

Signed-off-by: Brian Bland <brian.bland@docker.com>
@@ -604,6 +621,45 @@ func (bs *blobs) Resume(ctx context.Context, id string) (distribution.BlobWriter
panic("not implemented")
}

func (bs *blobs) Mount(ctx context.Context, sourceRepo string, dgst digest.Digest) (distribution.Descriptor, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think sourceRepo should be reference.Named rather than a string. Perhaps the digest should also be incorporated into this argument (in that case, it would be reference.Canonical). Not sure if that makes sense here, since canonical references are usually used for identifying manifests, not blobs. @dmcgowan @stevvooe WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

As is this use of string is consistent with the rest of the client package. I would agree though that it would be desirable to refactor the interfaces to use the reference package, I would not enforce that here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I got confused about this. I remembered refactoring everything to use the reference package in #1270, but it turns out that didn't get merged and I closed it until other PRs got merged. I'll reopen that PR and bring it up to date, but this PR can go in as-is first.

@RichardScothern
Copy link
Contributor

LGTM

2 similar comments
@dmcgowan
Copy link
Collaborator

dmcgowan commented Jan 8, 2016

LGTM

@aaronlehmann
Copy link
Contributor

LGTM

RichardScothern pushed a commit that referenced this pull request Jan 8, 2016
Adds cross-repository blob mounting behavior
@RichardScothern RichardScothern merged commit 93d9070 into distribution:master Jan 8, 2016
@BrianBland BrianBland deleted the crossRepositoryPush branch January 8, 2016 23:05
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Apr 22, 2021
Adds cross-repository blob mounting behavior
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Jan 19, 2022
Adds cross-repository blob mounting behavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants