Commit Graph

218 Commits

Author SHA1 Message Date
Paweł Gronowski
dd3eedf3c3 labels: Add LabelDistributionSource
Add a public const for "containerd.io/distribution.source" in `labels`
package and replace hardcoded usages.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-03-08 10:01:58 +01:00
Fu Wei
8cb00f45c9
Merge pull request #8143 from mxpv/log
Add Fields type alias to log package
2023-02-21 10:22:23 +08:00
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
Akihiro Suda
8bf975b4fa
lint: silence "type HostFileConfig is unused (unused)"
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-02-16 03:50:22 +09:00
Fish-pro
76a62e52ae Use http constants instead of string
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
2023-02-10 14:01:48 +08:00
Justin Chadwell
9f6058d029 pushWriter: correctly propagate errors
In the refactor from 926b9c72f61b5be6bf8d952512f1d0932fbaf898, the error
handling was substantially reworked, and changed the types of errors
returned.

Notably, in the case of a network error, instead of propogating the
error through to return from pushWriter.Write (as previously), it would
be propagated through to pushWriter.Commit - however, this is too late,
since we've already closed the io.Pipe by the time we would have reached
this function. Therefore, we get the generic error message  "io:
read/write on closed pipe" for *every network error*.

This patch corrects this behavior to ensure that the correct error
object is always returned as early as possible, by checking the error
result after writing and detecting a closed pipe.

Additionally, we do some additional hardening - specifically we prevent
falling through when resetting the content or detecting errors, and
update the tests to explicitly check for the ErrReset message.

Signed-off-by: Justin Chadwell <me@jedevc.com>
2023-01-24 11:37:41 +00:00
Akihiro Suda
4adf3fb3af
Merge pull request #7906 from Iceber/use_label_uncompressed
Use the const labels.LabelUncompressed
2023-01-04 01:04:20 +09:00
Iceber Gu
778e8f2af4 Use the const labels.LabelUncompressed
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-01-03 18:29:21 +08:00
Wei Fu
6b7e237fc7 chore: use go fix to cleanup old +build buildtag
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2022-12-29 14:25:14 +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
Sebastiaan van Stijn
f0ce2f6d36
remotes/docker: remove deprecated NewAuthorizer alias
This was deprecated since containerd v1.3.0.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-20 22:27:21 +01: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
Derek McGowan
31bb8fef7e
Merge pull request #7460 from AkihiroSuda/fetch-by-digest
remotes: add `FetcherByDigest` for fetching blobs without foreknown descriptors (useful for general-purpose CAS)
2022-11-04 15:20:29 -07:00
Kazuyoshi Kato
e306680f44
Merge pull request #7607 from jess-sol/main
Support default hosts.toml configuration
2022-11-04 10:22:00 -07:00
Akihiro Suda
dfd6a3aa6e
remotes: add FetcherByDigest for fetching blobs without foreknown descriptors
Fetching blobs without foreknown descriptors is useful for using a registry as a general-purpose CAS.

Related: `oras blob fetch` (ORAS v0.15.0)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-11-04 11:41:07 +09:00
Jess
f0bf9e7f8b Support default hosts.toml configuration
Add support for an optional `default` registry hosts config, should no
other hosts config match.

Signed-off-by: Jess <jess@ros.io>
2022-11-03 16:26:51 -06: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
rongfu.leng
63a7d8a7ff fix pusher concurrent close channel
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
2022-10-08 11:27:54 +08:00
Samuel Karp
b7a8a54141
Merge pull request #6995 from akhilerm/retry-on-reset 2022-09-28 10:36:55 -07:00
Akhil Mohan
8f4c23b69f
retry request on writer reset
when a put request is retried due to the response from registry,
the body of the request should be seekable. A dynamic pipe is added
to the body so that the content of the body can be read again.
Currently a maximum of 5 resets are allowed, above which will fail the
request. A new error ErrReset is introduced which informs that a
reset has occured and request needs to be retried.

also added tests for Copy() and push() to test the new functionality

Signed-off-by: Akhil Mohan <makhil@vmware.com>
2022-09-20 22:09:11 +05:30
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
Maksym Pavlenko
ca3b9b50fe Run gofmt 1.19
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-08-04 18:18:33 -07:00
Jonny Stoten
2fa84b1b8d
Add extra context to error when push unauthorized
For consistency with pulls, see #2052.

Signed-off-by: Jonny Stoten <jonny.stoten@docker.com>
2022-07-27 12:23:18 +01:00
Jeff Widman
050cd58ce6 Drop deprecated ioutil
`ioutil` has been deprecated by golang. All the code in `ioutil` just
forwards functionality to code in either the `io` or `os` packages.

See https://github.com/golang/go/pull/51961 for more info.

Signed-off-by: Jeff Widman <jeff@jeffwidman.com>
2022-07-23 08:36:20 -07:00
guiyong.ou
628f6ac681 code cleanup
Signed-off-by: guiyong.ou <guiyong.ou@daocloud.io>
2022-07-19 22:46:32 +08:00
Kazuyoshi Kato
e9e33f847d Copy fuzzers from github.com/cncf/cncf-fuzzing
This commit copies the fuzzers from the repository except for
containerd_import_structured_fuzzer.go.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-07-06 15:21:48 +00:00
Kazuyoshi Kato
548c9c317b Fix WWW-Authenticate parsing
According to RFC 9110, quoted-string could be "".

https://datatracker.ietf.org/doc/html/rfc9110#section-11.6.1
https://datatracker.ietf.org/doc/html/rfc9110#appendix-A

Fixes #6376.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-07-01 20:26:39 +00:00
Kazuyoshi Kato
b27a229df6 Move contrib/fuzz/docker_fuzzer.go to remotes/docker
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-06-20 23:34:23 +00:00
Kazuyoshi Kato
f91616e45e Copy FuzzConvertManifest from cncf/cncf-fuzzing
This test is one of the noisiest and should be moved from
cncf/cncf-fuzzing first.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2022-06-20 23:34:23 +00: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
Fu Wei
9b33526ef6
Merge pull request #5681 from kzys/info-url
remotes/docker: log registry URLs as info instead of debug
2022-04-20 14:21:15 +08:00
Maksym Pavlenko
871b6b6a9f Use testify
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-01 18:17:58 -07:00
Eng Zer Jun
18ec2761c0
test: use T.TempDir to create temporary test directory
The directory created by `T.TempDir` is automatically removed when the
test and all its subtests complete.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-03-15 14:03:50 +08: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
Derek McGowan
05177ab5cd
Merge pull request #6243 from ktock/pusher-abort
remotes: fix dockerPusher to handle abort correctly
2022-02-01 18:07:46 -08:00
ye.sijun
c0e00f19ab fix acr fetch token 400
Signed-off-by: ye.sijun <junnplus@gmail.com>
2022-01-27 17:34:45 +08:00
Phil Estes
ab8d99cf4b
Merge pull request #6463 from Junnplus/empty-scope
Fix empty scopes return
2022-01-20 15:34:11 -05:00
ye.sijun
936faf9c98 fix empty scopes return
Signed-off-by: ye.sijun <junnplus@gmail.com>
2022-01-20 15:16:44 +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
Akihiro Suda
97623ab0cd
remotes/docker: allow fetching "refresh token" (aka "identity token")
The new AuthorizerOpt `WithFetchRefreshToken` allows fetching "refresh token"
(aka "identity token", "offline token").

For HTTP GET mode (`FetchToken`), `offline_token=true` is set in the request.
https://docs.docker.com/registry/spec/auth/token/#requesting-a-token

For HTTP POST mode (`FetchTokenWithOAuth`), `access_type=offline` is set in the request.
https://docs.docker.com/registry/spec/auth/oauth/#getting-a-token

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-27 15:19:45 +09:00
Akihiro Suda
8094f50dd0
remotes/docker/config: allow setting custom AuthorizerOpts
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-12-24 18:17:40 +09:00
haoyun
c0d07094be feat: Errorf usage
Signed-off-by: haoyun <yun.hao@daocloud.io>
2021-12-13 14:31:53 +08:00
Kazuyoshi Kato
5d4dc57802 remotes/docker: log registry URLs as info instead of debug
Registry URLs are important and should be logged even the logging level is
info.

Fixes #5486.

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-12-03 10:44:05 -08:00
Kohei Tokunaga
a97564411c remotes: fix dockerPusher to handle abort correctly
`dockerPusher` provides `pushWriter` which implements `content.Writer`.
However, even if `pushWriter` become abort status (i.e. `Close()` is called
before `Commit()`), `dockerPusher` doesn't recognise that status and treats that
writer as on-going.
This behaviour doesn't allow the client to retry an aborted push.

This commit fixes this issue.
This commit also adds an test to ensure that the issue is fixed.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-11-26 13:43:01 +09:00
Derek McGowan
a776a27af5
Merge pull request from GHSA-5j5w-g665-5m35
images: validate document type before unmarshal
2021-11-17 10:54:25 -08:00