Commit Graph

32987 Commits

Author SHA1 Message Date
96e23c4152 pkg/mount/mountinfo_linux: parser speed up
The mountinfo parser implemented via `fmt.Sscanf()` is slower than the one
using `strings.Split()` and `strconv.Atoi()`. This rewrite helps to speed it
up to a factor of 8x, here is a result from go bench:

> BenchmarkParsingScanf-4      	     300	  22294112 ns/op
> BenchmarkParsingSplit-4      	    3000	   2780703 ns/op

I tried other approaches, such as using `fmt.Sscanf()` for the first
three (integer) fields and `strings.Split()` for the rest, but it slows
things down considerably:

> BenchmarkParsingMixed-4      	    1000	   8827058 ns/op

Note the old code uses `fmt.Sscanf`, when a linear search for '-' field,
when a split for the last 3 fields. The new code relies on a single
split.

I have also added more comments to aid in future development.

Finally, the test data is fixed to now have white space before the first field.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: c611f18a7f16d8aa878a5a5c7537d23a0937c40a
Component: engine
2018-04-19 14:49:42 -07:00
cd146e5f0d getSourceMount(): simplify
The flow of getSourceMount was:
 1 get all entries from /proc/self/mountinfo
 2 do a linear search for the `source` directory
 3 if found, return its data
 4 get the parent directory of `source`, goto 2

The repeated linear search through the whole mountinfo (which can have
thousands of records) is inefficient. Instead, let's just

 1 collect all the relevant records (only those mount points
   that can be a parent of `source`)
 2 find the record with the longest mountpath, return its data

This was tested manually with something like

```go
func TestGetSourceMount(t *testing.T) {
	mnt, flags, err := getSourceMount("/sys/devices/msr/")
	assert.NoError(t, err)
	t.Logf("mnt: %v, flags: %v", mnt, flags)
}
```

...but it relies on having a specific mount points on the system
being used for testing.

[v2: add unit tests for ParentsFilter]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: 871c957242df9f8c74faf751a2f14eb5178d4140
Component: engine
2018-04-19 14:49:17 -07:00
7e50bdbeb9 daemon.cleanupMounts(): use mount.SingleEntryFilter
Use mount.SingleEntryFilter as we're only interested in a single entry.

Test case data of TestShouldUnmountRoot is modified accordingly, as
from now on:

1. `info` can't be nil;

2. the mountpoint check is not performed (as SingleEntryFilter
   guarantees it to be equal to daemon.root).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: d3ebcde82aae79be8cbecab365367b17adac4b3e
Component: engine
2018-04-19 14:48:25 -07:00
a97e7a41c8 pkg/mount: implement/use filter for mountinfo parsing
Functions `GetMounts()` and `parseMountTable()` return all the entries
as read and parsed from /proc/self/mountinfo. In many cases the caller
is only interested only one or a few entries, not all of them.

One good example is `Mounted()` function, which looks for a specific
entry only. Another example is `RecursiveUnmount()` which is only
interested in mount under a specific path.

This commit adds `filter` argument to `GetMounts()` to implement
two things:
 1. filter out entries a caller is not interested in
 2. stop processing if a caller is found what it wanted

`nil` can be passed to get a backward-compatible behavior, i.e. return
all the entries.

A few filters are implemented:
 - `PrefixFilter`: filters out all entries not under `prefix`
 - `SingleEntryFilter`: looks for a specific entry

Finally, `Mounted()` is modified to use `SingleEntryFilter()`, and
`RecursiveUnmount()` is using `PrefixFilter()`.

Unit tests are added to check filters are working.

[v2: ditch NoFilter, use nil]
[v3: ditch GetMountsFiltered()]
[v4: add unit test for filters]
[v5: switch to gotestyourself]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Upstream-commit: bb934c6aca3e77541dd4fd51b9ab2706294dadda
Component: engine
2018-04-19 14:48:09 -07:00
8348a70a7d Migrate test-integration-cli experimental plugin tests to integration
All `plugins` tests that require an `ExperimentalDaemon` are migrated
to `integration/plugin/*` and start an experimental daemon to test on
it.

The end goal being to remove the `experimental` build.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 69bab3832ce1d72dd1d3ed2f2b53143ec9ff102c
Component: engine
2018-04-19 11:57:28 +02:00
f766069f3c Merge pull request #36684 from cpuguy83/bump_containerd_client
Bump containerd client
Upstream-commit: 8bb5a28eed5eba5651c6e48eb401c03be938b4c1
Component: engine
2018-04-19 10:38:43 +02:00
1a74ffcae2 Merge pull request #36865 from vdemeester/integration-move-swarm-plugin-test
Migrate TestAPISwarmServicesPlugin to integration
Upstream-commit: f1783da7361ab3dc985df12446357e6c4c9ef388
Component: engine
2018-04-18 21:15:59 -07:00
21ab0afd1a Merge pull request #36894 from cpuguy83/bump_x_net
Bump golang.org/x/net to go1.10 release commit
Upstream-commit: f0b2f9362fbd6be58404b9d6bc3de53c6bc884e9
Component: engine
2018-04-18 18:04:51 -07:00
5eb096d4f8 Merge pull request #36848 from cpuguy83/libcontainerd_client_locking
Relax some libcontainerd client locking
Upstream-commit: 69a5611dde5b46785c8f071a744f5b4b7547d5b9
Component: engine
2018-04-18 16:47:23 -07:00
320288f128 Merge pull request #36637 from cpuguy83/no_global_driver_store
No global volume driver store
Upstream-commit: 6cd806aa53de41e6f04346150d08e19ec63311e0
Component: engine
2018-04-18 16:32:23 -04:00
c5fc4e9f5a Bump golang.org/x/net to go1.10 release commit
The primary need for this is x/net/context now is just a type alias to
the stdlib context package.
This makes issues with conflicts between "golang.org/x/net/context" and
the stdib "context" go away (primarily a concern in interface
definitions/implementations).

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 848ef1da8b0d1c01a84fbe215f24f00fa741690d
Component: engine
2018-04-18 15:57:24 -04:00
a6beebd548 Migrate TestAPISwarmServicesPlugin to integration
Also starts to create more "poll/check" function to `internal/test/daemon`.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: aa0db6f9e1d0fd0420271f419d0d225089a95bbd
Component: engine
2018-04-18 16:18:53 +02:00
a90ad7bf98 Merge pull request #36832 from vdemeester/integration-daemon-api-helpers
More integration-cli/integration refactoring + request package
Upstream-commit: 25ff68a80f315a5e0a4526cc15a1ece83843ae2b
Component: engine
2018-04-18 16:12:14 +02:00
a1bdeeb8dc Merge pull request #36858 from j-haj/36414-standardize_build_paths
Standardize artefact path for all build stages
Upstream-commit: 4923f8cc639e1ab01a251429495920e516ef779f
Component: engine
2018-04-18 06:58:38 -04:00
c48e2f3808 Bump SwarmKit to 9c2aa152c3054371b833483a7ddad8d15052ec4f
Relevant changes:

- docker/swarmkit#2551 RoleManager will remove deleted nodes from the cluster membership
- docker/swarmkit#2574 Scheduler/TaskReaper: handle unassigned tasks marked for shutdown
- docker/swarmkit#2561 Avoid predefined error log
- docker/swarmkit#2557 Task reaper should delete tasks with removed slots that were not yet assigned
- docker/swarmkit#2587 [fips] Agent reports FIPS status
- docker/swarmkit#2603 Fix manager/state/store.timedMutex

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 333b2f28fef4ba857905e7263e7b9bbbf7c522fc
Component: engine
2018-04-17 13:44:49 -07:00
856b3acadf Remove use of global volume driver store
Instead of using a global store for volume drivers, scope the driver
store to the caller (e.g. the volume store). This makes testing much
simpler.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 977109d808ae94eb3931ae920338b1aa669f627e
Component: engine
2018-04-17 14:07:08 -04:00
e2550466e7 Rename volumedrivers package to drivers
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: b047f675ea958fa730f4bf56f909faceb9636506
Component: engine
2018-04-17 14:06:53 -04:00
8f56510165 Remove old/uneeded volume migration from vers 1.7
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 0023abbad34282762d5bd17302776d2a8521fffc
Component: engine
2018-04-17 14:06:53 -04:00
27a6dfb147 Move direct volume driver interaction to store
Since the volume store already provides this functionality, we should
just use it rather than duplicating it.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 63826e291ba3b88443b64802084bbb3931857b56
Component: engine
2018-04-17 14:06:53 -04:00
c9ce394894 Relax global client lock on containerd restore.
This unblocks the client to take other restore requests and makes sure
that a long/stuck request can't block the client forever.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Upstream-commit: 806700e410a1b30aa1033d71d825e57880c75298
Component: engine
2018-04-17 12:07:06 -04:00
a05c5e914a Move integration-cli/request to internal/test/request…
… and change a bit the method signature

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 42f6fdf059807ecbe66cce90676021363a541154
Component: engine
2018-04-17 16:25:59 +02:00
3d6d872b1c Add api helpers to internal/test/daemon.Daemon
Porting helpers from `integration-cli/daemon.Daemon` to this struct
and use the API instead of the cli.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 9722214c8add2a83f6c4974848139cadc79d9f0e
Component: engine
2018-04-17 16:24:31 +02:00
f4e6667402 Standardize artefact path for all build stages
Update all build stages to output artefacts to /build

Signed-off-by: Jeff Hajewski <jeff.hajewski@gmail.com>
Upstream-commit: 00555f7b261111084b966920da607a504b068953
Component: engine
2018-04-17 09:08:25 -05:00
a425bbca33 Move fakecontext, fakegit and fakestorage to internal/test
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 062564084a22f71cf5807ae5dfad7d29afb12e04
Component: engine
2018-04-17 09:53:09 +02:00
b77fed9a5f Merge pull request #36866 from fntlnz/poule-assign-pr-fntlnz
Add myself to poule to get 2w/old PRs
Upstream-commit: 13771fede318028d67e5d521bb97bcb54a4aaec5
Component: engine
2018-04-16 18:32:32 -07:00
f4b8a312a4 Merge pull request #36841 from yongtang/02222018-tag-test
Migrate image tag tests from integration-cli to api tests
Upstream-commit: abb1661907fa5e831872a7f99f1af2dcc88724bf
Component: engine
2018-04-16 17:53:48 -07:00
84f41cfc7e Merge pull request #36838 from vdemeester/integration-fixtures-refactoring
Clean some integration-cli/fixtures package/files
Upstream-commit: f9c4e630269be438cddfe843c727c21c3343f1c2
Component: engine
2018-04-16 17:49:29 -07:00
e26e074b4e Add myself to poule to get 2w/old PRs
Signed-off-by: Lorenzo Fontana <lo@linux.com>
Upstream-commit: 691e0c06cef55a455d72a4d1ec9dc4d072cf5e3b
Component: engine
2018-04-16 18:33:21 +02:00
c2c6cea1b0 Clean some integration-cli/fixtures package/files
- Move go package used by both `integration-cli` and `integration` to
  `internal/test/fixtures`.
- Remove fixtures that are not used anymore (moved to `docker/cli` a
  while ago) : deploy, notary, secrets.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 5f56503f583f21d655394f755f71849381bd58c7
Component: engine
2018-04-16 10:48:58 +02:00
bd6e299583 Small daemon refactoring and add swarm init/join helpers
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 239a8a518904dfb51fe62087d8702519c20ce808
Component: engine
2018-04-16 10:20:10 +02:00
1b1d5ffe90 Merge pull request #36862 from yongtang/04152018-container.Create
Some enhancement in integration tests
Upstream-commit: ea579a6194525ce3b98eba04f74de19a106bf918
Component: engine
2018-04-15 09:12:52 -07:00
fe0deb4aa6 Merge pull request #36738 from Microsoft/jjh/getlayerpath
Windows: Add GetLayerPath implementation in graphdriver
Upstream-commit: 5c2e6064a1c5cb816081958e5a7079bc6b474940
Component: engine
2018-04-14 09:59:38 -07:00
691aeed45e Some enhancement in integration tests
This fix converts some `client.ContainerCreate` to `container.Create`,
and removes some unneeded `name` fields when test containers are created.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: ab9bb47b05b1dde445a5e4ba78ae97303208dc8b
Component: engine
2018-04-14 16:52:02 +00:00
566b2857cf Merge pull request #35739 from thaJeztah/bump-go-1.10
Bump Golang to 1.10.1
Upstream-commit: 61138fb5fc0f5fc1799cabfa86d28fb88a0f472c
Component: engine
2018-04-13 13:56:38 -10:00
fce8015aac Merge pull request #36845 from medakk/refactor-daemon
Refactor code in cmd/dockerd/daemon.go
Upstream-commit: 3881f1a5219ba5d0a1ed54121ba20cd1700fec52
Component: engine
2018-04-13 15:26:48 -07:00
10abb9454f Migrate image tag tests from integration-cli to api tests
This fix migrates image tag tests from integration-cli to api tests.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Upstream-commit: 9bcb960508a6066811cffcca1e35ca44d7f1cf94
Component: engine
2018-04-13 14:46:40 +00:00
af04bf6300 Move and refactor integration-cli/registry to internal/test
- Move the code from `integration-cli` to `internal/test`.
- Use `testingT` and `assert` when creating the registry.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Upstream-commit: 66de2e6e3b6d927a3396743cd7c363aa9f7b776e
Component: engine
2018-04-13 10:45:34 +02:00
1fe7cf068a Merge pull request #36840 from cpuguy83/bump_libnetwork
Bump libnetwork commit
Upstream-commit: 544ec0994f3979314b0c3a892a4e352145d0cc0b
Component: engine
2018-04-13 13:54:52 +09:00
21cd6af613 Merge pull request #36778 from odg0318/master
Using authorization plugin, I changed Content-Type check routine.
Upstream-commit: ff6a103067dec1eec6de023ec813355c419246f6
Component: engine
2018-04-12 17:39:38 -07:00
32a14263cf Merge pull request #35831 from anusha-ragunathan/splunk_partial
Improve partial message support in logger
Upstream-commit: 9689059b5636f23d77cc3ac29ee41c6fabff81ec
Component: engine
2018-04-12 17:38:27 -07:00
97ccb57a9f Merge pull request #36727 from tiborvass/fix-master-ci-gitcommit
ci: quote bash variable
Upstream-commit: f238bfda902d8193dd2d33bb334cd2419ffa5578
Component: engine
2018-04-12 14:06:22 -07:00
3d3a3ad156 hack/make.ps1: fix Validate-PkgImports
In Go 1.10.1, the Deps for pkg\tarsum\tarsum_test.go are empty ([]) and
the PowerShell script ends up setting its import list to a string value
of False instead of an empty array. This can be remedied by forcing the
result to be an array, by concatenating to an empty array (@() + ...)

Signed-off-by: John Stephens <johnstep@docker.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ec3f9230d70506c536a24e844da0f0b3af9b43f6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ee508d47c3917b423b6caae0ad2867c4f6ffe696
Component: engine
2018-04-12 13:37:10 -07:00
ea19201d03 archive/tar: vendor again
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 7b30fd0e1d8bc77f0556181c82f85d046b058f27)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 66720189e04d50ef06c12d1ffbbfebf41caa2ae3
Component: engine
2018-04-12 13:36:58 -07:00
c7b8d02f5e Update logger adapter test to avoid race
Add synchronization around adding logs to a plugin
and reading those logs. Without the follow configuration,
a race occurs between go routines to add the logs into
the plugin and read the logs out of the plugin. This
adds a function to synchronize the action to avoid the
race.
Removes use of file for buffering, instead buffering whole
messages so log count can be checked discretely.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: c208f1c8a8d57f9a7f48f63345e77146774aa7a6
Component: engine
2018-04-12 13:35:15 -07:00
869a49d9be Set format in archiver
Prevent changing the tar output by setting the format to
PAX and keeping the times truncated.
Without this change the archiver will produce different tar
archives with different hashes with go 1.10.
The addition of the access and changetime timestamps would
also cause diff comparisons to fail.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: fb170206ba12752214630b269a40ac7be6115ed4
Component: engine
2018-04-12 13:34:33 -07:00
49ee24ad6b Fix tarsum for go 1.10
Remove invalid flush commands, flush should only occur when file
has been completely written. This is already handle, remove these calls.
Ensure data gets written after EOF in correct order and before close.
Remove gname and uname from sum for hash compatibility.
Update tarsum tests for gname/uname removal.
Return valid length after eof.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a422774e593b33bd287d9890544ad9e09b380d8c
Component: engine
2018-04-12 13:34:14 -07:00
f2f6aa148e Remove patched "archive/tar" package
This fix is now upstream in Go 1.10

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 950a1aa3170cedabd904cdcfcfa70c7d551a5e16
Component: engine
2018-04-12 13:33:33 -07:00
91c1ef0fbf Bump Golang to 1.10.1, alpine 3.7
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: be8885525c4d1ef4a13bbd6396f60e8657bc5573
Component: engine
2018-04-12 13:30:01 -07:00
ee6e3cbd82 Refactor code in cmd/dockerd/daemon.go
Signed-off-by: Karthik Karanth <karanth.karthik@gmail.com>
Upstream-commit: 05346355dbd4300a21bfd64cda93ea6c5aef0cf0
Component: engine
2018-04-13 00:14:20 +05:30
a9398df305 Merge pull request #36595 from runcom/oom-docker-cp-authz
copy: avoid using all system memory with authz plugins
Upstream-commit: 76e47a08c5bb52b4a6ac95d2f90888c0e50bb85b
Component: engine
2018-04-12 13:42:56 -04:00