Commit Graph

97 Commits

Author SHA1 Message Date
Alex Price
a022c21819 Improve host fallback behaviour in docker remote
This commit improves the fallback behaviour when resolving and
fetching images with multiple hosts. If an error is encountered
when resolving and fetching images, and more than one host is being
used, we will try the same operation on the next host. The error
from the first host is preserved so that if all hosts fail, we can
display the error from the first host.

fixes #3850

Signed-off-by: Alex Price <aprice@atlassian.com>
2019-12-13 11:42:32 +11:00
Derek McGowan
08517e5864
Allow empty scope authorization
Registries may allow using token authorization without
explicitly setting the scope. This may cover use cases where
no scope is required for an endpoint or the registry is only
covering authentication using the token. This aligns with the
oauth2 spec which specifies the scope as optional.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-12-12 11:05:48 -08:00
Evan Cordell
7177af84ac Allow 202 response code for commit
Quay returns this status code when pushing

Signed-off-by: Evan Cordell <cordell.evan@gmail.com>
2019-10-14 09:21:31 -04:00
Michael Crosby
901bcb2231 Add distribution subpkgs to core
Ref: #3554

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-10-07 13:38:12 -04:00
Derek McGowan
394db03f15
Fix all media types in Accept header to match RFC
Fixes the media type to align with Accept HTTP header
RFC which specifies glob syntax */*

See https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-09-26 14:48:42 -07:00
Brian Goff
e84a84a5a9 Add function to set custom auth scope in context
Currently auth.docker.io uses a custom auth scope for (docker) plugins
`repository(plugin):<repo>:<perms>`.
This makes it impossible to use containerd distribution tooling to fetch
plugins without also supplying a totally custom authorizer.

This changes allows clients to set the correct scope on the context.
It's a little bit nasty but "works".

I'm also a bit suspect of some a couple of these unexported context
functrions. Before the primary one used `contextWithRepositoryScope`
overwrites any scope value and there is another one that appends the
scope value.
With this change they both append...

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-09-18 11:29:16 -07:00
Michael Crosby
f06e605f1a
Merge pull request #3515 from fuweid/me-remove-comment-line
remotes: remove useless line
2019-08-09 09:21:36 -04:00
Wei Fu
282b19efd2 remotes: remove useless line
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-08-09 17:15:09 +08:00
ethan
0a3769eec6 pusher.go: error message typo correction
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-08-07 10:09:23 +08:00
Jintao Zhang
4b4ce4a26c remotes: remove unnecessary string formatting
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
2019-08-05 02:16:57 +08:00
Derek McGowan
c965a6c4da
Prevent push by tag for sub-manifests
When pushing a manifest list, all manifests should be pushed by digest
and only the final manifest pushed by tag. The Pusher was preventing
this by mistakenly disallowing objects to contain a digest. When objects
have a digest, only push tags associated with that digest.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-31 15:19:44 -07:00
Derek McGowan
518be1cb07
Fix bug in setting request body
Go documentation says
`Use of GetBody still requires setting Body`.
This change ensures the body is always set in
addition to GetBody. This fixes a bug where
sometimes the body is nil.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-18 11:21:51 -07:00
Derek McGowan
0b29c9c371
Update resolver to handle endpoint configuration
Adds support for registry mirrors
Adds support for multiple pull endpoints
Adds capabilities to limit trust in public mirrors
Fixes user agent header missing


Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-16 11:28:23 -07:00
Konstantin Maksimov
3d3dbc8fbf Handle RequestTimeout and TooManyRequests
Retry 5 times in case of StatusRequestTimeout StatusTooManyRequests
This fixes the issue #2680 "Make content fetch retry more robust"

Signed-off-by: Konstantin Maksimov <kmaksimov@gmail.com>
2019-07-01 19:19:40 +03:00
zhangyue
12a14c4424 fix: polish log to make more clear
Signed-off-by: zhangyue <zy675793960@yeah.net>
2019-06-20 20:46:26 +08:00
Wei Fu
dd7c0aabcc remotes: support cross-repo-push
With distribution source label in content store, select the longest
common prefix components as condidate mount blob source and try to push
with mount blob.

Fix #2964

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-06-13 09:51:46 +08:00
Derek McGowan
bb00872800
Add user agent header to all requests
Currently the user agent is only being used on the initial
resolve request, then switching to the default user agent.
This ensures the correct user agent is always used. There is
a larger fix in progress which does this is a cleaner way, but
the scope of this change is fixing the user agent issue.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-06-11 22:57:58 +08:00
msg555
ee902afa5f Compute manifest metadata when not provided.
This closes #3238

Signed-off-by: msg555 <msg555@gmail.com>
2019-05-01 00:53:16 -04:00
Davor Kapsa
eded188f4f Fix misspells
Signed-off-by: Davor Kapsa <davor.kapsa@gmail.com>
2019-04-30 20:38:24 +02:00
Michael Crosby
de1da8be32 Update handling of registry errors
Update to #3109

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-04-04 14:51:03 -04:00
Michael Crosby
9bc231532d
Merge pull request #3109 from bainsy88/issue_3076
Add code to return errors from registries
2019-04-04 13:23:37 -04:00
Jack Baines
d15832a4c2 Address review comments
-Fix whitespace on imports
-Fix test case naming

Signed-off-by: Jack Baines <jack.baines@uk.ibm.com>
2019-03-21 15:59:49 +00:00
Jack Baines
908b771086 Add code to return message field of returned registry errors
Docker registries return errors in a know format so this change now checks for these
errors and returns the message field. If the error is not in the expected format fall
back to the original behaviour.

https://github.com/containerd/containerd/issues/3076

Signed-off-by: Jack Baines <jack.baines@uk.ibm.com>
2019-03-19 21:05:36 +00:00
Wei Fu
506b815483 remotes: add distribution labels to blob data
We can use cross repository push feature to reuse the existing blobs in
the same registry. Before make push fast, we know where the blob comes
from.

Use the `containerd.io/distribution.source. = [,]` as label format. For
example, the blob is downloaded by the docker.io/library/busybox:latest
and the label will be

    containerd.io/distribution.source.docker.io = library/busybox

If the blob is shared by different repos in the same registry, the repo
name will be appended, like:

    containerd.io/distribution.source.docker.io = library/busybox,x/y

NOTE:
1. no need to apply for legacy docker image schema1.
2. the concurrent fetch actions might miss some repo names in label, but
it is ok.
3. it is optional. no need to add label if the engine only uses images
not push.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-03-12 13:42:54 +08:00
Wei Fu
132ee9b826 fix: linter issue
megacheck, gosimple and unused has been deprecated and subsumed by
staticcheck. And staticcheck also has been upgraded. we need to update
code for the linter issue.

close: #2945

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-01-23 22:54:51 +08:00
Wei Fu
5137fc6f11 bugfix: support application/octet-stream during pull
Even though application/octet-stream issue has been fixed in docker,
there exists lots of images which contains the invalid mediatype.

In order to pull those images, containerd client side modifies the
manifest content before insert/update image reference.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2018-12-29 13:58:36 +08:00
Eric Lin
2db0c6c262 Explicitly stating utf-8 when fetching oauth token
Fixes #2870

Signed-off-by: Eric Lin <linxiulei@gmail.com>
2018-12-12 12:16:27 +08:00
Derek McGowan
b8631c750c
Merge pull request #2751 from Charliekenney23/add-useragent-resolver-option
Add custom headers resolver option
2018-11-20 10:51:10 -08:00
Tonis Tiigi
a2e8ab9ff7 remotes: avoid panic with default resolver conf
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2018-11-19 17:33:59 -08:00
Charles Kenney
068880ff16 Add custom headers option to dockerResolver
Signed-off-by: Charles Kenney <charlesc.kenney@gmail.com>
2018-10-31 19:42:42 -04:00
Charles Kenney
7c85d873a0 fix typo in ResolverOptions.Credentials documentation
Signed-off-by: Charles Kenney <charlesc.kenney@gmail.com>
2018-10-31 11:06:28 -04:00
Gábor Lipták
4a0c40664a
Correct redundant nil check
Signed-off-by: Gábor Lipták <gliptak@gmail.com>
2018-10-19 16:50:17 -04:00
Michael Crosby
5993d096ff
Merge pull request #2691 from fuweid/bugfix_cache_empty_label
bugfix: cache empty layer for docker schema1 image
2018-10-15 15:43:23 -04:00
Derek McGowan
26506e9e23
Update empty layer label
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-10-15 11:28:45 -07:00
Derek McGowan
a6198b7692
Update resolver code
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-09-28 14:32:23 -07:00
Wei Fu
57d79e1b49 bugfix: cache empty layer for docker schema1 image
containerd should cache empty label for docker schema1 image.

if not, the original empty layer will be non-empty layer and the image
config will be changed too. in this case, the image ID will be changed.

check the blob empty label to avoid changing image ID when repull docker
schema1 image.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2018-09-28 15:45:59 +08:00
nashasha1
7f03ad6579 Fix typos
Signed-off-by: nashasha1 <a4012017@sina.com>
2018-09-07 16:59:42 +08:00
Wei Fu
9db21deb5d bugfix: avoid to re-calculate blob state for schema1
Use containerd.io/uncompressed label to avoid to re-calculate blob
diffID.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2018-09-06 09:14:56 +08:00
Phil Estes
c55b9636f7
Merge pull request #2263 from alibaba/fix_no_gzip
fixbug: blob for schemav1 could be uncompressed
2018-07-30 18:49:28 -04:00
Lantao Liu
c8a8a49584 Support specifying host in resolver.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-07-09 18:26:02 -07:00
Vincent Demeester
832b05ae67
Update tests to use gotest.tools angel
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-08 21:02:01 +02:00
frank yang
046536cfb1 fixbug: blob for schemav1 could be uncompressed
Signed-off-by: frank yang <yyb196@gmail.com>
2018-06-08 11:50:54 +08:00
Akihiro Suda
703c25e452 fix schema1 fetchBlob()
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-06-07 17:51:41 +09:00
Bin Du
9b865d86a9 docker/pusher: handle location string containing path and query
Signed-off-by: Bin Du <bindu@microsoft.com>
2018-06-05 19:25:19 +00:00
Akihiro Suda
d88de4a34f content: change Writer/ReaderAt to take OCI
This change allows implementations to resolve the location of the actual data
using OCI descriptor fields such as MediaType.

No OCI descriptor field is written to the store.

No change on gRPC API.

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2018-06-01 11:51:43 +09:00
Derek McGowan
59740d8985
Fix invalid length bug with some registries
Ensures that the client can handle cases where the
registry ignores content length.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-05-26 23:41:56 -07:00
Stephen J Day
27a14f1a9d
remotes/docker: protect secret with a mutex
Signed-off-by: Stephen J Day <stephen.day@docker.com>
2018-04-05 15:16:38 -07:00
Derek McGowan
5304ef294b
Add writer open helper to handle unavailable refs
Updates blob writer helper to use new open and ensure
unavailable errors are always handled.
Removes duplication of unavailable handling code.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-03-21 16:30:22 -07:00
ruediger-maass
373f1e5612 Adds handling of 401 for POST /v2/token without authentication
This fix adds support for image registries that expect authentication for POST /v2/token such as used by the GET. E.g., JFrog Artifactory y has been observed to respond with a 401 (Unauthorized) in that case. Adding 401 in addition to the current handling of 405 and 404 in the resolver solves the authentication problem. Finally, this enables image pulls also for Artifactory.

Signed-off-by: Ruediger Maass <ruediger.maass@de.ibm.com>
2018-02-28 02:32:44 +00:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00