Commit Graph

328 Commits

Author SHA1 Message Date
c8706706f4 Merge pull request #14897 from WeiZhang555/golint-api-types
fix golint warnings/errors on package api/types/
Upstream-commit: 0a0e9701f7bbe58e75eff9d1934fde0a5038ee9c
Component: engine
2015-08-07 10:51:27 -07:00
8778d71536 Merge pull request #14828 from brahmaroutu/lint_graph_tags
/graph/tag fix lint errors/warnings
Upstream-commit: b1009d1fdd551a57e7c266d9cc8122ed3f80aa2c
Component: engine
2015-08-07 10:49:26 -07:00
502a6d4faf fix golint warnings/errors on package api/types/
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
Upstream-commit: 3d6617ffe7d9242107ac09eab4f2d8ce87acb95c
Component: engine
2015-08-07 09:43:43 +08:00
9970a2eed5 registry: Do not push to mirrors
This patch splits LookupEndpoints into LookupPullEndpoints and
LookupPushEndpoints so that mirrors added with --registry-mirror are
skipped in the list returned by LookupPushEndpoints.

Fixes https://github.com/docker/distribution/issues/823

Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: b899977ee283d6bccf35ad9a079ed92a291ad34c
Component: engine
2015-08-06 17:41:59 -04:00
fc48931914 [graph] Use a pipe for downloads to write progress
The process of pulling an image spawns a new goroutine for each layer in the
image manifest. If any of these downloads fail we would stop everything and
return the error, even though other goroutines would still be running and
writing output through a progress reader which is attached to an http response
writer. Since the request handler had already returned from the first error,
the http server panics when one of these download goroutines makes a write to
the response writer buffer.

This patch prevents this crash in the daemon http server by waiting for all of
the download goroutines to complete, even if one of them fails. Only then does
it return, terminating the request handler.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: d80c4244d322fe0a9cbdd996d23e37fb5b089544
Component: engine
2015-08-05 18:13:39 -07:00
9d9a4fd0c0 Merge pull request #15252 from coolljt0725/14765_enable_golint_3
Enable golint in pkg/archive
Upstream-commit: 8534090476b6eae66f1eca81e8bc0e0c61ed7197
Component: engine
2015-08-05 19:27:48 -04:00
65b70bf683 /graph/tag fix lint errors/warnings
Addresses #14756
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
Upstream-commit: d9b261221aa6ada89a2dac3e535cb1d48be37cad
Component: engine
2015-08-05 17:46:41 +00:00
5dd4ca1927 Windows: Fix docker/master daemon compile again
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 67e670b79f1ed372b62058ebadd5821fa85cd737
Component: engine
2015-08-04 19:32:05 -07:00
aa73b79fe2 Merge pull request #14921 from aaronlehmann/int64
Fix uses of "int" where "int64" should be used instead
Upstream-commit: 7374852be9def787921aea2ca831771982badecf
Component: engine
2015-08-04 19:16:13 -07:00
3ba45e7906 Enable golint in pkg/arcive
Signed-off-by: Lei Jitang <leijitang@huawei.com>
Upstream-commit: ba332b7d12fba16e8c604728a44986886eeb07d6
Component: engine
2015-08-04 09:52:54 +08:00
d08d95f41d [graph] Enforce manifest/layer digest verification
We noticed a regression since the 1.7.1 patch after some refactoring. This
patch corrects the behavior and adds integration tests for modified manifest
and rootfs layer blobs.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
Upstream-commit: de52a3bcaa1742054be184cc3465f0933f6d383a
Component: engine
2015-08-03 11:41:23 -07:00
761b152e62 Fix uses of "int" where "int64" should be used instead
Some structures use int for sizes and UNIX timestamps. On some
platforms, int is 32 bits, so this can lead to the year 2038 issues and
overflows when dealing with large containers or layers.

Consistently use int64 to store sizes and UNIX timestamps in
api/types/types.go. Update related to code accordingly (i.e.
strconv.FormatInt instead of strconv.Itoa).

Use int64 in progressreader package to avoid integer overflow when
dealing with large quantities. Update related code accordingly.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: 1f61084d83aea37b212468aaa975020094b7f7c9
Component: engine
2015-07-31 16:31:40 -07:00
03122f024f Merge pull request #15144 from aaronlehmann/graph-cleanup
Documentation improvements and code cleanups for graph package
Upstream-commit: 8f2dca538619372663a94bc5141dbc7f121defb8
Component: engine
2015-07-31 15:11:34 -07:00
c5a5900eb9 Documentation improvements and code cleanups for graph package
Expand the godoc documentation for the graph package.

Centralize DefaultTag in the graphs/tag package instead of defining it
twice.

Remove some unnecessary "config" structs that are only used to pass
a few parameters to a function.

Simplify the GetParentsSize function - there's no reason for it to take
an accumulator argument.

Unexport some functions that aren't needed outside the package.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: d4836cd7ec1c085c5a5caa7eb7f5eda4ace10eb6
Component: engine
2015-07-30 14:27:10 -07:00
3c8e934faf Simplify and fix os.MkdirAll() usage
TL;DR: check for IsExist(err) after a failed MkdirAll() is both
redundant and wrong -- so two reasons to remove it.

Quoting MkdirAll documentation:

> MkdirAll creates a directory named path, along with any necessary
> parents, and returns nil, or else returns an error. If path
> is already a directory, MkdirAll does nothing and returns nil.

This means two things:

1. If a directory to be created already exists, no error is returned.

2. If the error returned is IsExist (EEXIST), it means there exists
a non-directory with the same name as MkdirAll need to use for
directory. Example: we want to MkdirAll("a/b"), but file "a"
(or "a/b") already exists, so MkdirAll fails.

The above is a theory, based on quoted documentation and my UNIX
knowledge.

3. In practice, though, current MkdirAll implementation [1] returns
ENOTDIR in most of cases described in #2, with the exception when
there is a race between MkdirAll and someone else creating the
last component of MkdirAll argument as a file. In this very case
MkdirAll() will indeed return EEXIST.

Because of #1, IsExist check after MkdirAll is not needed.

Because of #2 and #3, ignoring IsExist error is just plain wrong,
as directory we require is not created. It's cleaner to report
the error now.

Note this error is all over the tree, I guess due to copy-paste,
or trying to follow the same usage pattern as for Mkdir(),
or some not quite correct examples on the Internet.

[v2: a separate aufs commit is merged into this one]

[1] https://github.com/golang/go/blob/f9ed2f75/src/os/path.go

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
Upstream-commit: a83a76934787a20e96389d33bd56a09369f9b808
Component: engine
2015-07-30 11:48:08 -07:00
e1b2148585 /graph fix lin errors/warnings
Addresses #14756
Signed-off-by: Srini Brahmaroutu <srbrahma@us.ibm.com>
Upstream-commit: 1d6e44311916b26e1cd128e96ea9f0e5ede5f9df
Component: engine
2015-07-29 20:59:36 +00:00
67bf5ba305 Replace GenerateRandomID with GenerateNonCryptoID
This allow us to avoid entropy usage in non-crypto critical places.

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: 6bca8ec3c9ccc169c53b3d7060fe5c8ba8670aac
Component: engine
2015-07-28 22:31:01 -07:00
0fccf757d0 Format times in inspect command with a template as RFC3339Nano
In 1.6.2 we were decoding inspect API response into interface{}.
time.Time fields were JSON encoded as RFC3339Nano in the response
and when decoded into interface{} they were just strings so the inspect
template treated them as just strings.
From 1.7 we are decoding into types.ContainerJSON and when the template
gets executed it now gets a time.Time and it's formatted as
2015-07-22 05:02:38.091530369 +0000 UTC.
This patch brings back the old behavior by typing time.Time fields
as string so they gets formatted as they were encoded in JSON -- RCF3339Nano

Signed-off-by: Antonio Murdaca <runcom@linux.com>
Upstream-commit: c9207bc0aa57745876a3422d2cbc290be7c53da8
Component: engine
2015-07-26 15:25:08 +02:00
7e6fe45a4f Use notary library for trusted image fetch and signing
Add a trusted flag to force the cli to resolve a tag into a digest via the notary trust library and pull by digest.
On push the flag the trust flag will indicate the digest and size of a manifest should be signed and push to a notary server.
If a tag is given, the cli will resolve the tag into a digest and pull by digest.
After pulling, if a tag is given the cli makes a request to tag the image.

Use certificate directory for notary requests

Read certificates using same logic used by daemon for registry requests.

Catch JSON syntax errors from Notary client

When an uncaught error occurs in Notary it may show up in Docker as a JSON syntax error, causing a confusing error message to the user.
Provide a generic error when a JSON syntax error occurs.

Catch expiration errors and wrap in additional context.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: ed13c3abfb242905ec012e8255dc6f26dcf122f6
Component: engine
2015-07-24 14:08:20 -07:00
4d9279a3fb Improve documentation and golint compliance of registry package
* Add godoc documentation where it was missing

* Change identifier names that don't match Go style, such as INDEX_NAME

* Rename RegistryInfo to PingResult, which more accurately describes
  what this structure is for. It also has the benefit of making the name
  not stutter if used outside the package.

Updates #14756

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: 4fcb9ac40ce33c4d6e08d5669af6be5e076e2574
Component: engine
2015-07-24 11:55:07 -07:00
f7a16948b8 Do Docker edits so we can use the new distribution code
Signed-off-by: Doug Davis <dug@us.ibm.com>
Upstream-commit: b874ef8f43754e5c0fe40b90c3533db93491753e
Component: engine
2015-07-23 10:24:46 -07:00
e87491eb72 Avoid redundant HEAD requests for identical layers on push
pushV2Tag already deduplicates layers, but the scope of this
deduplication is only for a particular tag. If we are pushing all tags
in a repository, we may check layers several times. Fix this by moving
the layersSeen map from the pushV2Tag function to the v2Pusher struct.

In addition to avoiding some useless round-trips, this makes the "docker
push" output less confusing. It formerly could contain many repeated
lines like:

    124e2127157f: Image already exists
    124e2127157f: Image already exists
    ...

Add test coverage based on the "docker push" output: a hash should not
appear multiple times when pushing multiple tags.

Fixes #14873

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: 810d3b2642d4a82dc186d6eff8c2e487ee624bc5
Component: engine
2015-07-22 17:54:20 -07:00
9fcd71bb97 graph: isolate the (dis)assembly logic
with the current duplication of code in the grap.go split-up, this puts
all assembly/disassembly logic into isolated functions

Signed-off-by: Vincent Batts <vbatts@redhat.com>
Upstream-commit: 22347fdb636c0b7936c87f6cf422a2e4a30adf9e
Component: engine
2015-07-22 11:36:15 -04:00
bef6397e67 graph: use tar archive entries for TarLayer
if there is a tar-data.json.gz present for an image layer, then use it
to create the tar archive, instead of the traditional graphdriver Diff.

Signed-off-by: Vincent Batts <vbatts@redhat.com>

Conflicts:
	graph/graph.go
Upstream-commit: 5a00326d29efb161826ef13dfd63ed2732017cd1
Component: engine
2015-07-22 11:36:15 -04:00
3f77e8bf68 graph: variablize file names
and add a comment.. :-)

Signed-off-by: Vincent Batts <vbatts@redhat.com>

Conflicts:
	graph/graph.go
Upstream-commit: ba1f76cbfa2c137abfbc607725460e376e6f44d3
Component: engine
2015-07-22 11:36:15 -04:00
910418adbc graph: preserve tar archive entries
Preserve the entries from the tar archive for layers added to the graph.

With these entries and relative filesystem path, the tar archives can be
reassembled later.

Signed-off-by: Vincent Batts <vbatts@redhat.com>
Upstream-commit: 5d9f06599c4f0cde9ad266dff77e797ea99c3ac3
Component: engine
2015-07-22 11:36:15 -04:00
b70343dc2b Fixing Image struct to no longer use Graph.
Signed-off-by:  John Howard <jhoward@microsoft.com>
Upstream-commit: 9001ea26e7821239207586ad23c78c67d6926bfc
Component: engine
2015-07-20 13:59:53 -07:00
4cbf8e8120 Merge pull request #13681 from tiborvass/carry-11784
Carry 11784: rmi dangling is unsafe when pulling
Upstream-commit: 7f353a11e4d40d08d1bd15df24c87a95d8cd9a02
Component: engine
2015-07-17 16:17:18 -07:00
371476f565 fix 8926: rmi dangling is unsafe when pulling
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 1b67c38f6f4a709e1d159445b56f0beee8cfad3a
Component: engine
2015-07-17 11:39:57 -04:00
e2d31e5c38 graph: clarify the need for named error
Signed-off-by: Vincent Batts <vbatts@redhat.com>
Upstream-commit: a40e337882dfe3f34af44a9f2aec2ed96dcce455
Component: engine
2015-07-17 10:01:52 -04:00
8755c824aa Merge pull request #14664 from calavera/fix_load_tag_with_digest
Check if a tag name to load is a valid digest.
Upstream-commit: 212525f951d9c92ad4cbf7628e7024930da080ac
Component: engine
2015-07-16 12:46:05 -07:00
98b526f041 Check if a tag name to load is a valid digest.
Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 1ec25653d87fa86517a319992ee89eb3e5ee1223
Component: engine
2015-07-16 10:53:56 -07:00
1492d5ce64 Update graph to use vendored distribution client for the v2 codepath
Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 19515a7ad859b28c474d81e756ac245afcd968e3
Component: engine
2015-07-16 13:13:47 -04:00
0a78587632 remove pkg/transport and use the one from distribution
Signed-off-by: Tibor Vass <tibor@docker.com>
Upstream-commit: 276c640be4b4335e3b8d684cb3562a56d3337b39
Component: engine
2015-07-16 13:13:46 -04:00
89b6e2370a Merge pull request #14661 from LK4D4/vet_warns
Fix some formatting calls
Upstream-commit: cd642973fa50531d3da6c13eb0255b6f4cc8aa9c
Component: engine
2015-07-15 16:41:18 -07:00
46a0415407 Fix some formatting calls
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
Upstream-commit: a5142f6ac31c6c21b96c6895fff525c46e8056a6
Component: engine
2015-07-15 12:25:50 -07:00
06996e8f7f Set canonical name correctly
Currently canonical name gets set to the local name and displayed in the errors.
Canonical name should be the unique and canonical name for an image.
Use docker.io as the canonical domain for images on the public registry.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 7f48cd7dce6fdc077bcde0962e0aa0e73fb63225
Component: engine
2015-07-14 17:45:49 -07:00
1296feade8 Windows: Graph driver implementation
Signed-off-by: John Howard <jhoward@microsoft.com>
Upstream-commit: 52f4d09ffb376ffaa6677cb1e0413c6a97f53f24
Component: engine
2015-07-10 14:33:11 -07:00
017d6047d5 added ability to iterate over all indexes and use index.Iterate() instead of ReadDir() to walk over the graph
Signed-off-by: Roman Strashkin <roman.strashkin@gmail.com>
Upstream-commit: cc955ae73c8aa234e0c41bdb65f111be79b32b90
Component: engine
2015-07-07 22:13:28 +03:00
36eb2b9f9d Fix duplicate layers in manifest
Currently the layer array is initialized with the first layer then the first layer is appened to the layer list. Adding the first layer twice causes the layer to appear twice in the manifest, making a duplicate push and pull attempt occur.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
Upstream-commit: 35081ea4b6711b1cfccb67b0f0d691b7adc85ff6
Component: engine
2015-07-06 17:31:06 -07:00
842ad32482 Replace latest log by logrus
Related to #11618 and #11614

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 10e114fb956db1b1a8bc9308cc6d14cbf30a5bab
Component: engine
2015-07-02 16:11:52 +02:00
205cf6d70e Attempt to protect on disk image store with mutex
During `(*Graph).Register, there was no protection on adding new layers
concurrently. In some cases, this resulted in corruption of a layer by creating
the directory but not the underlying data. This manifested in several different
IO errors reported in the client.  This attempts to fix this by adding a mutex
by Image ID to protect the Register operation.

We do not completely understand the root cause of this corruption other than
the result is somehow tied to this particular function.  This fix has been
confirmed to address the issue through testing.

Unfortunately, this fix does not address existing corruption. The user will
have to remove and re-pull the corrupt layer to stop the error from happening
in the future. This change only ensures that the layer will not become corrupt.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: 7eac23cf8de08f281c84c36390f734dbaef8c69a
Component: engine
2015-06-25 20:16:37 -07:00
35e8f92672 Remove dead code
Signed-off-by: Antonio Murdaca <runcom@linux.com>
Upstream-commit: 927d13bc3c2030bb0e0429dbc500f13d72e7ccf6
Component: engine
2015-06-20 19:14:15 +02:00
b387e8ade7 Merge pull request #13575 from mattmoor/consistent-push-fallback
Make v2 push have v1-fallback behavior consistent with pull.
Upstream-commit: d86345b9f722c187afd4af8a92583fc07506b5d9
Component: engine
2015-06-17 13:41:58 -07:00
0b8d2a4fe1 Merge pull request #13870 from lindenlab/pull-single-tag
Only request a single repository tag when pulling a specific image:tag
Upstream-commit: c107e9d7903d148692f9e727bf6d5ce6e88e2f72
Component: engine
2015-06-17 15:29:39 -04:00
2d2c80b6fc Merge pull request #13975 from stevvooe/move-setup-init-layer
Move graph.SetupInitLayer to daemon package where it is used
Upstream-commit: a27d8f9aa4dbdbad5bbfd83c8d8321e7a976305c
Component: engine
2015-06-16 22:37:51 -04:00
fe0ca49e61 Move graph.SetupInitLayer to daemon package where it is used
An inspection of the graph package showed this function to be way out of place.
It is only depended upon by the daemon code. The function prepares a top-level
readonly layer used to provide a consistent runtime environment for docker
images.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Upstream-commit: b7f887a9a24a2df61fa53612ae42b7e9d62fe858
Component: engine
2015-06-16 16:50:56 -07:00
d527901687 Merge pull request #13685 from yuchangchun1/tag_regx
add a more accurate error description for invalid tag name
Upstream-commit: ba9db62e68581b2f9187b15b13150396961e23e9
Component: engine
2015-06-16 16:33:17 -07:00
8810db85be Merge pull request #13198 from rhvgoyal/extend-docker-inspect
docker-inspect: Extend docker inspect to export image metadata related to graph driver
Upstream-commit: e69df2589c1220217054abdc6a361b55990b3c0b
Component: engine
2015-06-16 15:03:14 -05:00
4dbf1e0f71 Only pulling single repository tag on pull for a specific tag. extending TestGetRemoteTags unit test
Splitting out GetRemoteTag from GetRemoteTags.  Adding registry.ErrRepoNotFound error

Signed-off-by: Don Kjer <don.kjer@gmail.com>
Upstream-commit: b349a74c71fb072f9f23f508b8c698d0590abb12
Component: engine
2015-06-16 07:10:09 +00:00