Skip to content

Add support for layers from foreign sources#1725

Merged
aaronlehmann merged 1 commit intodistribution:masterfrom
jstarks:foreign_layer
May 20, 2016
Merged

Add support for layers from foreign sources#1725
aaronlehmann merged 1 commit intodistribution:masterfrom
jstarks:foreign_layer

Conversation

@jstarks
Copy link
Contributor

@jstarks jstarks commented May 14, 2016

This will be used to support downloading Windows base layers from Microsoft URLs.

You can see this change in full context at jstarks/docker@27b81d4.

cc @aaronlehmann

@codecov-io
Copy link

codecov-io commented May 15, 2016

Current coverage is 50.24%

Merging #1725 into master will decrease coverage by 11.56%

  1. 2 files in manifest/schema2 were modified. more
    • Misses +8
    • Partials +1
    • Hits -9
  2. 2 files (not in diff) in registry/middleware were deleted. more
  3. 12 files (not in diff) in registry/handlers were deleted. more
  4. 4 files (not in diff) in ...istry/storage/driver were modified. more
    • Misses +811
    • Partials -93
    • Hits -718
  5. 14 files (not in diff) in registry/storage were modified. more
    • Misses +36
    • Partials +50
    • Hits -86
  6. 7 files (not in diff) in registry/proxy were modified. more
    • Misses +120
    • Partials -3
    • Hits -117
  7. 2 files (not in diff) in registry/client/auth were modified. more
    • Misses +1
    • Partials +3
    • Hits -4
  8. 2 files (not in diff) in registry/client were modified. more
    • Misses +56
    • Partials +5
    • Hits -61
  9. 2 files (not in diff) in registry/api/errcode were modified. more
    • Misses +8
    • Partials +1
    • Hits -9
  10. 1 files (not in diff) in registry/api were modified. more
    • Misses +2
    • Partials +3
    • Hits -5
@@             master      #1725   diff @@
==========================================
  Files           121        107     -14   
  Lines         10579       9352   -1227   
  Methods           0          0           
  Messages          0          0           
  Branches          0          0           
==========================================
- Hits           6537       4698   -1839   
- Misses         3436       4173    +737   
+ Partials        606        481    -125   

Sunburst

Powered by Codecov. Last updated by 4a915d6...a3db037

@jstarks
Copy link
Contributor Author

jstarks commented May 17, 2016

I've updated the PR with changes to successfully validate manifests with foreign layers. With this update and the referenced Docker changes, I am able to push/pull foreign layers to a private registry.

@jstarks
Copy link
Contributor Author

jstarks commented May 18, 2016

Any feedback?

type LayerDescriptor struct {
distribution.Descriptor
// ForeignURL contains the foreign source URL of this layer.
ForeignURL string `json:"foreign_url,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

URLs []string to allow more that one URL. I don't think there is any reason to call this "foreign".

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general, this works because foreign and URL doesn't need to be combined. More precisely, the presence of URL shouldn't imply the foreign media type and vice versa.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would you expect a client to try to try each of the URLs in order until one succeeded?

@stevvooe
Copy link
Collaborator

@jstarks Looks like a good start. There may be some additions required in registry/client. Most importantly, the relevant specification updates need to happen with this field addition.

@jstarks
Copy link
Contributor Author

jstarks commented May 18, 2016

@stevvooe Thanks. I'll look at registry/client and the specs.

@jstarks
Copy link
Contributor Author

jstarks commented May 19, 2016

@stevvooe For registry/client, were you thinking that it would be helpful to have a function that returns a ReadSeekCloser that uses URLs if they are set in the descriptor? Currently I have put this code in the Docker engine, but I could move it to registry/client so that it would be available to any client.

The tricky part is that currently blobs.Open() takes a Digest and not a Descriptor, so this would have to be an extension to the BlobProvider interface...

Thoughts?

@stevvooe
Copy link
Collaborator

@jstarks I see. Since we aren't really communicating with the registry, it may not make sense to bake this into the client. Really, there needs to be some component that parses a manifest and figures out the set of operations. Currently, we really do this in the engine, so it's likely the proposed break down is fine.

@jstarks
Copy link
Contributor Author

jstarks commented May 20, 2016

I've pushed an update that moves URLs into distributionDescriptor and updates the 2.2 spec.


- **`urls`** *array*

For an ordinary layer, this is empty, and the layer contents can be
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to go more generic here?

cc @RichardScothern @aaronlehmann

@stevvooe
Copy link
Collaborator

LGTM

for _, u := range fsLayer.URLs {
pu, err := url.ParseRequestURI(u)
if err != nil || (pu.Scheme != "http" && pu.Scheme != "https") {
err = errors.New("invalid URL on layer")

Choose a reason for hiding this comment

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

pu, err := url.ParseRequestURI(u) creates a new err variable in the current scope, so when you assign to err here, you are not assigning the one you declare with var err error, and this error won't be caught by the check below.

It might be worth adding a simple unit test to make sure that valid URLs are accepted and invalid URLs, or URLs in the presence of the wrong mediatype, are rejected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, good catch. This is by far the most common mistake I make in Go...

I'll add a test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed and test added.

This will be used to support downloading Windows base layers from
Microsoft URLs.

Signed-off-by: John Starks <jostarks@microsoft.com>
@aaronlehmann
Copy link

LGTM

@aaronlehmann aaronlehmann merged commit 5bbf654 into distribution:master May 20, 2016
@RichardScothern RichardScothern added this to the Registry/2.5 milestone Jun 13, 2016
@runcom runcom mentioned this pull request Jul 8, 2016
2 tasks
thaJeztah pushed a commit to thaJeztah/distribution that referenced this pull request Apr 22, 2021
Add support for layers from foreign sources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants