Commit Graph

59 Commits

Author SHA1 Message Date
Maksym Pavlenko
06e085c8b5 Add Fields type alias to log package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-02-20 17:29:08 -08:00
Derek McGowan
ba243ffaaf
Merge pull request #7521 from iyear/fix-defer
Fix incorrect defer usage and refactor judgement
2022-12-27 15:50:41 -08:00
Hsing-Yu (David) Chen
d5010a12df docs: Authorizer.Authorize could return ErrUnexpectedStatus
Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>
2022-12-08 13:24:48 -08:00
Maksym Pavlenko
14a08721cc Remove OpenTelementry imports from remotes/docker package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-11-15 17:32:26 -08:00
Luca Comellini
b829e6f2d3
Bump OpenTelemetry to v1.11.1
Signed-off-by: Luca Comellini <luca.com@gmail.com>
2022-11-10 22:15:10 -08:00
Swagat Bora
7def13dde3 Add a thin wrapper around otel Span object
Signed-off-by: Swagat Bora <sbora@amazon.com>
2022-11-11 01:28:27 +00:00
Swagat Bora
3b87d46ce2 Add tracing spans in CRI image service and pull.go
Signed-off-by: Swagat Bora <sbora@amazon.com>

Add spans around image unpack operations
Use image.ref to denote image name and image.id for the image config digest
Add top-level spand and record errors in the CRI instrumentation service
2022-11-03 17:03:43 +00:00
iyear
7afe6d92dc Fix incorrect defer usage and refactor judgement
Signed-off-by: iyear <ljyngup@gmail.com>
2022-10-17 13:38:14 +08:00
Iceber Gu
3cfde732e1 remotes/docker/config: Skipping TLS verification for localhost
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2022-09-13 17:40:23 +08:00
Akihiro Suda
42584167b7
Officially deprecate Schema 1
Schema 1 has been substantially deprecated since circa. 2017 in favor of Schema 2 introduced in Docker 1.10 (Feb 2016)
and its successor OCI Image Spec v1, but we have not officially deprecated Schema 1.

One of the reasons was that Quay did not support Schema 2 so far, but it is reported that Quay has been
supporting Schema 2 since Feb 2020 (moby/buildkit issue 409).

This PR deprecates pulling Schema 1 images but the feature will not be removed before containerd 2.0.
Pushing Schema 1 images was never implemented in containerd (and its consumers such as BuildKit).

Docker/Moby already disabled pushing Schema 1 images in Docker 20.10 (moby/moby PR 41295),
but Docker/Moby has not yet disabled pulling Schema 1 as containerd has not yet deprecated Schema 1.
(See the comments in moby/moby PR 42300.)
Docker/Moby is expected to disable pulling Schema 1 images in future after this deprecation.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-05-02 19:08:38 +09:00
W3QKR2T
b90c466c38 Add ErrUnexpectedStatus to resolver
Signed-off-by: Fabian Hoffmann <fabian.hoffmann@posteo.de>
2022-03-04 10:46:39 +01:00
Shengjing Zhu
f4f41296c2 Replace golang.org/x/net/context with std library
Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2022-02-22 02:27:05 +08:00
haoyun
bbe46b8c43 feat: replace github.com/pkg/errors to errors
Signed-off-by: haoyun <yun.hao@daocloud.io>
Co-authored-by: zounengren <zouyee1989@gmail.com>
2022-01-07 10:27:03 +08:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Derek McGowan
dbccd0d357
Merge pull request #5275 from haslersn/fix-4531
Try next mirror in case of non-404 errors, too
2021-05-19 07:57:57 -07:00
Derek McGowan
b1d4140a22
Update docker resolver to authorize redirects
Allows redirects to be authorized if authorization is provided
for the redirected to host. The authorization will always go
to the redirect and never to the referrer.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-05-14 12:16:24 -07:00
Sebastian Hasler
c0e2f4b5d2 Try next mirror in case of non-404 errors, too
Signed-off-by: Sebastian Hasler <sebastian.hasler@gmx.net>
2021-04-15 12:04:07 +02:00
Mike Brown
d21fe46250 adds log for each failed host and status not found on host
Signed-off-by: Mike Brown <brownwm@us.ibm.com>
2021-04-14 13:23:22 -05:00
Paul "TBBle" Hampson
785ac3ab71 Ensure request.header is never nil
Header.Clone() will return `nil` if called on a nil object.

Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
2021-01-13 05:46:50 +11:00
Phil Estes
9db6aa625d
Merge pull request #4302 from songjiayang/update-docker-resolver
Refactor dockerResolver with resolveDockerBase helper
2021-01-12 11:15:06 -05:00
Tonis Tiigi
bf323c5bdd docker: avoid concurrent map access panic
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-12-15 22:26:26 -08:00
ktock
4b882eb93a Export repository scope helper functions
`docker.Authorizer` requires library clients to configure scope via context.
It is helpful for the clients to use the helper (currently private) functions
for generating scope string and to use that function with the combination of
other scope-related ones (e.g. `docker.WithScope`).

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2020-10-06 10:49:01 +09:00
songjiayang
5867c88832 Refactor dockerResolver to make code simple
1.add resolveDockerBase helper
2.dockerBase header copy with header.Clone()

Signed-off-by: songjiayang <songjiayang@jd.com>
2020-09-14 11:38:05 +08:00
Derek McGowan
a7b2304f69
Merge pull request #4445 from tonistiigi/auth-refactor
docker: split private token helper functions to reusable pkg
2020-08-25 12:25:23 -07:00
Derek McGowan
adeba792f1
Add namespace query parameter for registry proxying
Proxy registries are designed to serve content from upstreams.
However, the proxy hostname will usually not match the hostname
of the upstream, requiring the proxy to only use a single
upstream or use its own pattern matching to determine the upstream.
To solve this issue, the client will pass along the namespace which
is being used for the request, allowing mirrors to easily map
to multiple upstreams. This query parameter can safely be ignored
if multiple upstreams are not supported.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-08-03 09:32:44 -07:00
Tonis Tiigi
957bcb3dff docker: split private token helper functions to reusable pkg
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-08-02 22:50:46 -07:00
Derek McGowan
3dd8242a67
Add host specific headers
Allows configuring headers per registry host

Signed-off-by: Derek McGowan <derek@mcg.dev>
2020-06-01 18:27:41 -07:00
Sebastiaan van Stijn
dc92ad6520
Replace errors.Cause() with errors.Is()
Dependencies may be switching to use the new `%w` formatting
option to wrap errors; switching to use `errors.Is()` makes
sure that we are still able to unwrap the error and detect the
underlying cause.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-05-08 14:36:45 +02:00
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
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
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
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
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
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
Derek McGowan
a6198b7692
Update resolver code
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-09-28 14:32:23 -07: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
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
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
Darren Stahl
f404331e90 ctr: print error when pull auth fails
Signed-off-by: Darren Stahl <darst@microsoft.com>
2018-01-23 16:14:09 -08:00
Daniel Nephin
f74862a0dd Add structcheck, unused, and varcheck linters.
Warn on unused and dead code

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-21 11:14:37 -05:00
Stephen J Day
682151b166 remotes/docker: implement seekable http requests
To support resumable download, the fetcher for a remote must implement
`io.Seeker`. If implemented the `content.Copy` function will detect the
seeker and begin from where the download was terminated by a previous
attempt.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-11-16 16:13:06 -05:00
Brian Goff
6eb56a2ec9 Use limited reader for some ReadAll cases.
Prevents a server from sending a large response causing containerd to
allocate too much RAM and potentially OOM.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-10-17 09:06:16 -04:00
Akihiro Suda
2f08032924 remotes/docker: add scope (registry:foo/bar:pull)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-09-07 05:10:48 +00:00
Akihiro Suda
aaae706067 remotes/docker: allow 404 for POST /v2/token
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2017-09-07 04:58:44 +00:00