Commit Graph

36 Commits

Author SHA1 Message Date
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
Shiming Zhang
53ec1abec2 remotes/docker/pusher.go: Fix missing Close()
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-07-21 11:37:08 +08:00
coryb
894b6ae39b Fix missing Body.Close() calls on push to docker remote
Discovered this while using HTTP tracing via OpenTelemetry inside of
buildkitd, where the trace spans were not being reported for the
registry PUT http requests.  The spans are only reported on the Close
for the Body, after adding these Close calls, the spans are reported as
expected.

Signed-off-by: coryb <cbennett@netflix.com>
2021-07-11 08:14:57 -07:00
ktock
ab1654d0e2 Fix PushHandler cannot push image that contains duplicated blobs
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2021-04-20 14:00:53 +09:00
Aaron Lehmann
4c1fa57194 remotes/docker: Only return "already exists" on push when the upload was successful
The `(dockerPusher).Push` method uses a `StatusTracker` to check if an
upload already happened, before repeating the upload. However, there is
no provision for failure handling. If a PUT request returns an error,
the `StatusTracker` will still see the upload as if it happened
successfully. Add a status boolean so that only successful uploads
short-circuit `Push`.

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
2021-04-06 19:45:24 -07:00
Ilya Dmitrichenko
d1b7784357
Use ErrUnexpectedStatus more consistently
Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
2021-03-11 14:37:59 +00:00
Tonis Tiigi
4dfec7fa01 pusher: add missing authentication support for requests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-12-15 22:26:59 -08:00
Tonis Tiigi
f601887a3c docker: don’t hide pusher response error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2020-11-10 23:19:08 -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
Ilya Dmitrichenko
2de55060ee
Log unexpected responses
This accomplishes a few long-standing TODO items, but also helps users
in showing exact registry error messages

Signed-off-by: Ilya Dmitrichenko <errordeveloper@gmail.com>
2020-09-03 14:52:11 +01:00
Gaurav Singh
2325182529 docker: fix data race on err
Signed-off-by: Gaurav Singh <gaurav1086@gmail.com>
2020-05-17 09:20:38 -04: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
Josh Dolitsky
d8a0d29c23 Set octet-stream content-type on put request
Signed-off-by: Josh Dolitsky <393494+jdolitsky@users.noreply.github.com>
2020-02-12 11:39:33 -06: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
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
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
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
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
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
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
Derek McGowan
56a35d5cb9
Update docker pusher check tag
Currently pushing a new tag to a manifest which already
exists in the registry skips the tag push because it
only checks that the manifest exists. This updates the
logic to instead check if the tag exists and is at the
same digest.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-11-16 17:29:29 -08:00
Daniel Nephin
2e7f7318cc Normalize 'already exists' errors
and fix some error messages where they were wrong or redundant

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-15 16:46:27 -05: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
Kenfe-Mickaël Laventure
e1eeb0e0a2 Merge pull request #1475 from dmcgowan/content-commit-context
Add context to content commit
2017-09-06 11:04:31 -07:00
Derek McGowan
9613acb2ed
Add context to content commit
Content commit is updated to take in a context, allowing
content to be committed within the same context the writer
was in. This is useful when commit may be able to use more
context to complete the action rather than creating its own.
An example of this being useful is for the metadata implementation
of content, having a context allows tests to fully create
content in one database transaction by making use of the context.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-09-06 10:19:12 -07:00
Derek McGowan
48afd44514
Support blob commit returning a 200 instead of 201
Support registries returning 204 or 200 in place of 201/202.
Ensure body is closed when request is retried.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-09-05 15:02:21 -07:00
Derek McGowan
dee8dc2cda
Add support for content labels on commit
Add commit options which allow for setting labels on commit.
Prevents potential race between garbage collector reading labels
after commit and labels getting set.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-08-11 14:15:20 -07:00
Stephen J Day
a4fadc596b
errdefs: centralize error handling
Now that we have most of the services required for use with containerd,
it was found that common patterns were used throughout services. By
defining a central `errdefs` package, we ensure that services will map
errors to and from grpc consistently and cleanly. One can decorate an
error with as much context as necessary, using `pkg/errors` and still
have the error mapped correctly via grpc.

We make a few sacrifices. At this point, the common errors we use across
the repository all map directly to grpc error codes. While this seems
positively crazy, it actually works out quite well. The error conditions
that were specific weren't super necessary and the ones that were
necessary now simply have better context information. We lose the
ability to add new codes, but this constraint may not be a bad thing.

Effectively, as long as one uses the errors defined in `errdefs`, the
error class will be mapped correctly across the grpc boundary and
everything will be good. If you don't use those definitions, the error
maps to "unknown" and the error message is preserved.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-06-29 15:00:47 -07:00
Phil Estes
e10a9aff7d
Use error interfaces for content/metadata
These interfaces allow us to preserve both the checking of error "cause"
as well as messages returned from the gRPC API so that the client gets
full error reason instead of a default "metadata: not found" in the case
of a missing image.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-06-14 15:55:08 -04:00
Derek McGowan
636a24eef6
Add status tracker for Docker remote push
Update push client to use status tracker

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-06-07 10:59:52 -07:00
Derek McGowan
5615b68f06
Update pusher to use content writer
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-06-07 10:57:00 -07:00
Derek McGowan
735b0e515e
Add push object
Split resolver to only return a name with separate methods
for getting a fetcher and pusher. Add implementation for
push.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-05-23 10:52:51 -07:00