Commit Graph

33964 Commits

Author SHA1 Message Date
fbaec0bb9e Makefile: make help: fix newline wrapping, and missing targets
This patch;

- adds support for multiple newlines
- removes the 1-space indentation of wrapped lines
- allows numerical characters in targets (0-9)

Given these targets:

```Makefile
.PHONY: foobar
foobar: ## runs the foobar lorum ipsum.\nand so pn\nand so on
	echo foobar

.PHONY: e2e-tests
e2e-tests: ## runs the end-to-end tests
	echo e2e-tests
```

Before this change, the output of `make help` was

```
foobar               runs the foobar lorum ipsum.
                      and so pn\nand so on
```

After this change, the output is:

```
foobar               runs the foobar lorum ipsum.
                     and so pn
                     and so on
e2e-tests            runs the end-to-end tests
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 202c9d8c98614e7cce2017f5c99d3d783fe8b509)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 733b86683f347f922affc714d305d9f03fe9b47e
Component: engine
2019-06-18 17:53:17 +01:00
e6d06f7160 Use BuildKit to skip source code COPY if BIND_DIR set
build the final stage of the Dockerfile (including COPY ...) if no BIND_DIR
is used.
if BIND_DIR is used, build the dev stage, thus skipping the COPY.

Original author: @thaJeztah

Signed-off-by: Mohammad Nasirifar <farnasirim@gmail.com>
(cherry picked from commit e6d7df2e5d313800414b955e10a26d6687e7a1bf)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: e5a039169f389120be3fbc2a9db45ef8bc99eae5
Component: engine
2019-06-18 17:53:12 +01:00
7e0220b6d6 Allow to override the Makefile's DOCKER_MOUNT variable
Through the env variable of the same name.

The idea here is pretty simple: I/O perf on native mounted disks
on non-Linux (notably Mac OS) is just terrible, thus making it
a real pain to develop: one has to choose between re-building
the image after every single change (eg to run a test) or just
work directly inside the same container (eg with vim, but even then
one would have to re-configure their dev container every time
it gets destroyed - containers, after all, are not supposed to
be long-lived).

Allowing to override `DOCKER_MOUNT` makes it easy for everyone
to decide what their volume/syncing strategy is; for example
one can choose to use [docker-sync](https://github.com/EugenMayer/docker-sync)

This patch won't change anything for anyone who doesn't
set the `DOCKER_MOUNT` env variable in their environment.

Signed-off-by: Jean Rouge <jer329@cornell.edu>
(cherry picked from commit aea6fdf3d340835a1b0af208839ce42ace3a5b89)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ecc423df7fde7f0edc963f03d70da133f03bb63c
Component: engine
2019-06-18 17:53:08 +01:00
36954599b4 go {build,test}: rm -i option, add go cache volume
Looks like -i (together with DOCKER_INCREMENTAL_BINARY etc)
were used to get faster incremental builds.

Nowdays (since Go 1.10) this is no longer the case, as
go build cache is used [1]. Here's a quote:

> You do not have to use "go test -i" or "go build -i" or
> "go install" just to get fast incremental builds. We will
> not have to teach new users those workarounds anymore.
> Everything will just be fast.

To enable go cache between builds, add a volume for /root/.cache.

[1] https://groups.google.com/forum/#!msg/golang-dev/qfa3mHN4ZPA/X2UzjNV1BAAJ

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit bdcd81d3301a053eefc320de16ac842ec47ed459)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 0f190f798f7b9f90bd008fe8fb0fc087ec965642
Component: engine
2019-06-18 17:53:03 +01:00
800f827460 Merge pull request #199 from thaJeztah/18.09_backport_fix_panic_on_empty_dockerfile
[18.09 backport] fix panic on empty dockerfile
Upstream-commit: 70399c41d321651121a4eb2775c4e7f63796426f
Component: engine
2019-06-18 09:49:05 -07:00
6cdb81566e Merge pull request #202 from thaJeztah/18.09_backport_update_docker_py
[18.09 backport] Update docker-py to 3.7.0
Upstream-commit: 5749d5ae7967038eecd974767142d27652bbbc2f
Component: engine
2019-06-18 09:46:14 -07:00
14405a174e Merge pull request #230 from thaJeztah/18.09_backport_windows_tag
[18.09 backport] Consider WINDOWS_BASE_IMAGE_TAG override when setting Windows base image for tests
Upstream-commit: bb54c5bf2a3ab1c698fda6b3d67773d25755ae45
Component: engine
2019-06-18 09:44:44 -07:00
aa8e14244e Merge pull request #236 from thaJeztah/18.09_backport_thanks_brian_now_im_hungry
[18.09 backport] Fix error handling for bind mount spec parser.
Upstream-commit: 41fbd152739faa225db8c9913e34c663b9202101
Component: engine
2019-06-18 09:43:19 -07:00
28df654a77 Merge pull request #194 from thaJeztah/18.09_backport_bump_containerd_v1.2.6
[18.09 backport] Bump containerd v1.2.6, runc v1.0.0-rc8
Upstream-commit: 3bacaaded9e086ec06fc335146eda614e1110570
Component: engine
2019-06-18 09:41:42 -07:00
a3041ba7dd Test: dockerfiles with no instructions are detected
Signed-off-by: Natasha Jarus <linuxmercedes@gmail.com>
(cherry picked from commit 18c7e8b927928654a67ce5d6637e42932fc3e7df)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: cd084b23f7c3ca38c5d9c15ec16e119d25e5d7af
Component: engine
2019-06-18 13:44:08 +01:00
a439056531 Convert parse errors to more informative format
- Wrap parse errors in errdefs.InvalidParameters
- Include dockerfile in error names

Signed-off-by: Natasha Jarus <linuxmercedes@gmail.com>
(cherry picked from commit 64466b0cd9ff36dc3f123a3a68eae438ac9e8e60)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 7eb0e6a095ac71bfe3e3419cef7d5867fef55f20
Component: engine
2019-06-18 13:44:04 +01:00
cbbe578ba2 bump buildkit 05766c5c21a1e528eeb1c3522b2f05493fe9ac47 (docker-18.09 branch)
- moby/buildkit#952 [18.09 backport] Have parser error on dockerfiles without instructions
  - backport of moby/buildkit#771 Have parser error on dockerfiles without instructions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: a1d76e0585c498f5167b28b9909fd8c88fd3370d
Component: engine
2019-06-18 13:43:59 +01:00
0addc7f6c5 Update docker-py to 3.7.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c0c05affc79b199248b457af16fff61c305b7623)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: b92e9e9da9519efa38d8a5927af668413cf81cd7
Component: engine
2019-06-18 13:42:20 +01:00
8642bba6c4 Network not deleted after stack is removed
Make sure adapter.removeNetworks executes during task Remove
adapter.removeNetworks was being skipped for cases when
isUnknownContainer(err) was true after adapter.remove was executed

This fix eliminates the nil return case forcing the function
to continue executing unless there is a true error

Fixes https://github.com/moby/moby/issues/39225

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
(cherry picked from commit 70fa7b6a3fd9aaada582ae02c50710f218b54d1a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 75887d37e1ddbef579e239ff0b1b7a2508e486fd
Component: engine
2019-06-18 13:34:02 +01:00
ac643ab134 Remove a network during task SHUTDOWN instead of REMOVE to
make sure the LB sandbox is removed when a service is updated
with a --network-rm option

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
(cherry picked from commit 680d0ba4abfb00c8ac959638c72003dba0826b46)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 280b8dff7df137dd21fcf27cacf6d12ed531770a
Component: engine
2019-06-18 13:33:58 +01:00
e00a39ba2b Move serviceRunningTasksCount to integration/internal/swarm
This fix moves multiple places of serviceRunningTasksCount
to one location in integration/internal/swarm, so that
code duplication could be removed.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
(cherry picked from commit e485a60e2bcc59860f387c94f6afaa0130ea7040)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: c087f681d40332bd7d158baf615c03f6a72274f1
Component: engine
2019-06-18 13:33:14 +01:00
e91395081e integration: Corrected service update tests logic
Tests which will re-deploy containers uses function serviceIsUpdated() to
make sure that service update really reached state UpdateStateCompleted.

Tests which will not re-deploy container uses function
serviceSpecIsUpdated to make sure that service version is increased.

Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
(cherry picked from commit b868ada474b5c214ed9bddb792dd36f794dc1fa6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ccc1abea092a54d99dec51345ef9303b4629572d
Component: engine
2019-06-18 13:33:06 +01:00
9d41ea2d82 integration: wait for service update to be completed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 8edcd4c3cd294bf276ffbe29bc58afbb006593b8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2ae0365c99627343d001a24e171fba2aa0fea791
Component: engine
2019-06-18 13:33:02 +01:00
29d8b5118f migrated service integration tests from integration-cli/docker_cli_service_update_test.go to integration/service
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit be151a73f0c0f362ff9775d2ff4d32329c01b8ba)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 4fe4e891723569fde7703747903289883db1dec0
Component: engine
2019-06-18 13:32:59 +01:00
630cd7d11b Merge pull request #257 from thaJeztah/18.09_backport_increase_swarmkit_grpc
[18.09 backport] Increase max recv gRPC message size for nodes and secrets
Upstream-commit: ce2e2b672a7a3510419cb2706edab3fd7f12fd6c
Component: engine
2019-06-17 12:31:27 -07:00
d25b6ea6fd Merge pull request #244 from thaJeztah/18.09_backport_fix_copying
[18.09 backport] image: do actual RootFS.DiffIDs copying in Clone()
Upstream-commit: 423f39ab05d121e1aeb6e59732386fb50c17f49b
Component: engine
2019-06-17 12:30:32 -07:00
2bfd8549de Merge pull request #218 from thaJeztah/18.09_backport_EDGE374_TestDaemonNoSpaceLeftOnDeviceError
[18.09 backport] explicitly set filesystem type for mount to avoid 'invalid argument' error on arm
Upstream-commit: 51ebfcbe423c679f06cfb37f7e6be565e0955639
Component: engine
2019-06-17 12:28:35 -07:00
eae44d6a4c Merge pull request #223 from thaJeztah/18.09_backport_devno
[18.09 backport] bugfix: fetch the right device number which great than 255
Upstream-commit: b236a1e78d35a62b164d00f4e19f59a556da8831
Component: engine
2019-06-17 12:27:17 -07:00
1b706a11a2 Merge pull request #276 from thaJeztah/18.09_backport_enable_new_integration_tests_for_win
[18.09 backport] Enable integrations API tests for Windows CI
Upstream-commit: 49a4899c79f740e5a8e19df62ea341be9d5200be
Component: engine
2019-06-17 12:26:34 -07:00
75aeb78955 Merge pull request #242 from thaJeztah/18.09_swagger_fixes
[18.09 backport] Swagger fixes
Upstream-commit: 556456701d1bd69a20f62d68d22257b8a6ad71c0
Component: engine
2019-06-17 12:24:38 -07:00
6a5e7a9ed6 Merge pull request #263 from thaJeztah/18.09_backport_39290alternate
[18.09 backport] Windows: Don't attempt detach VHD for R/O layers
Upstream-commit: ab9db72ae809597b5fb7a9e245f18fa3f99857ec
Component: engine
2019-06-17 12:23:41 -07:00
7551e66a79 Merge pull request #250 from thaJeztah/18.09_backport_fix_fix_win_tmp
[18.09 backport] Windows CI - Corrected LOCALAPPDATA location
Upstream-commit: d86fe18fc243c9d505403d50264a6db90e68e721
Component: engine
2019-06-17 12:23:09 -07:00
3317a78c8e Merge pull request #237 from thaJeztah/18.09_backport_remove_TestSearchCmdOptions
[18.09 backport] Remove TestSearchCmdOptions test
Upstream-commit: 87c3750877aec0288945231af20362edc26c7a70
Component: engine
2019-06-17 12:16:19 -07:00
b488dc3c6e Merge pull request #246 from thaJeztah/18.09_backport_log-daemon-exit-before-tests-finish
[18.09 backport] Ensure all integration daemon logging happens before test exit
Upstream-commit: 08f6e9c14fd0de408db93914058d75df5b32ac67
Component: engine
2019-06-17 12:15:43 -07:00
a99bdf7fc2 Merge pull request #269 from thaJeztah/18.09_backport_test_fixes
[18.09 backport] Harden TestPsListContainersFilterExited
Upstream-commit: 6799eea8c80b506aeae54c1331b4b2ad834920bd
Component: engine
2019-06-17 12:15:02 -07:00
20e962774c Merge pull request #233 from thaJeztah/18.09_backport_update_seccomp_test_for_aarch64
[18.09 backport] Update TestRunWithDaemonDefaultSeccompProfile for ARM64
Upstream-commit: 6809464a6395699b687fa0f0dfa190aa1d6d6547
Component: engine
2019-06-17 12:13:46 -07:00
0fafb25ad4 Merge pull request #245 from thaJeztah/18.09_backport_allow_version_overwrite
[18.09 backport] Add ability to override the version in make.ps1
Upstream-commit: f07e4693278434c112870d30d80ad984bc79e527
Component: engine
2019-06-17 12:11:50 -07:00
1cd53e2273 Merge pull request #243 from thaJeztah/18.09_skip_test_info_warnings
[18.09 backport] Skip TestInfoAPIWarnings on remote daemons
Upstream-commit: 8ec9dcfad74d349f62233c9ba053535dbd6f1405
Component: engine
2019-06-17 12:11:14 -07:00
422c678575 Merge pull request #262 from kolyshkin/18.09-backport-aufs-lock
[18.09 backport ENGCORE-830] aufs optimizations #39107
Upstream-commit: 95d8b395a981bf09e9c10eac06efed9ed44ee456
Component: engine
2019-06-17 11:57:12 -07:00
0e2a6eacdc Merge pull request #248 from thaJeztah/18.09_backport_aufs_fixes
[18.09 backport ENGCORE-830] layer store optimizations
Upstream-commit: 6b1354c52b94b7ace081d8e36abf71f6056d75f8
Component: engine
2019-06-17 11:56:50 -07:00
2db111a869 bump runc binary v1.0.0-rc8
full diff: 029124da7a...425e105d5a

- opencontainers/runc#2043 Vendor in latest selinux code for keycreate errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 4bc310c11babd2aa635eb08a5bbc198f96bc19b3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 1a1bf23d17e44d22ebec2b1d0e38329bd35b0127
Component: engine
2019-06-14 13:42:53 +02:00
0c07852c42 Update runc 029124da7af7360afa781a0234d1b083550f797c
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
(cherry picked from commit d43a41d7af7c4858e4b2ed41775c34b92cd35179)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: ce875b746bdcc37ff1c92dc181c78ba619d02d24
Component: engine
2019-06-14 13:42:46 +02:00
927d42432e Update containerd v1.2.6
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
(cherry picked from commit 8092cfb6e7396e0c5fc319b86ce9dca2246210f2)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 6ae2ec3fbe75886d8d73f93c46ced33258d86929
Component: engine
2019-06-14 13:42:42 +02:00
c82a61bcb3 Enable integrations API tests for Windows CI
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
(cherry picked from commit 2f22247cad9237d255a4b541a974705802abdad8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 69503ef832fed199e28ccfd731281a4e439a8eeb
Component: engine
2019-06-12 10:15:29 +02:00
223d3e0c75 fix: fix lack of copyUIDGID in swagger.yaml
Signed-off-by: Zhang Yue <zy675793960@yeah.net>
Signed-off-by: zhangyue <zy675793960@yeah.net>
(cherry picked from commit a4f828cb8905f42c8b8975ce88e4d7aa8cd9bf74)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 705cc95eb1247c1983c39477f2ecf5cb4eb5edbb
Component: engine
2019-06-07 14:38:39 +02:00
861c5d670e API: Set format of body parameter in operation PutContainerArchive to "binary"
Signed-off-by: Dominic Tubach <dominic.tubach@to.com>
(cherry picked from commit fa6f63e79b60d971460ee1fb8d449bdccc66cdfe)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: c3bf976a20ae18b628247088ff9935ce615337b8
Component: engine
2019-06-07 14:38:27 +02:00
3e919def47 Update docs to remove restriction of tty resize
Signed-off-by: Adam Dobrawy <naczelnik@jawnosc.tk>
(cherry picked from commit 4898f493d86129684c29d6cdfc6f65b49eb2ed29)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 2d1aa033a38e6a8b44b4a55a9285ebd80908e725
Component: engine
2019-06-07 14:38:21 +02:00
02856b256b API: Move "x-nullable: true" from type PortBinding to type PortMap
Currently the API spec would allow `"443/tcp": [null]`, but what should
be allowed is `"443/tcp": null`
Signed-off-by: Dominic Tubach <dominic.tubach@to.com>
(cherry picked from commit 32b5d296ea5d392c28affe2854b9d4201166bc27)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 3ee1e060fc9a31844064035cc3e8b76fddb8b341
Component: engine
2019-06-07 14:38:18 +02:00
f29ee03a99 API: Change type of RemotrAddrs to array of strings in operation SwarmJoin
Signed-off-by: Dominic Tubach <dominic.tubach@to.com>
(cherry picked from commit d5f6bdb027596b44244a6ce50555664b3a5ee4a7)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: d359834555628f67693cdf7eda246835b659a41c
Component: engine
2019-06-07 14:38:16 +02:00
2271e6653d Harden TestPsListContainersFilterExited
This test runs on a daemon also used by other tests
so make sure we don't get failures if another test
doesn't cleanup or is running in parallel.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 915acffdb4cf95b934dd9872c1f54ea4487819b7)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 05599804157a38db2eda84d3e8060a879b755ab7
Component: engine
2019-06-07 14:32:51 +02:00
0041943819 aufs: retry auplink flush
Running a bundled aufs benchmark sometimes results in this warning:

> WARN[0001] Couldn't run auplink before unmount /tmp/aufs-tests/aufs/mnt/XXXXX  error="exit status 22" storage-driver=aufs

If we take a look at what aulink utility produces on stderr, we'll see:

> auplink:proc_mnt.c:96: /tmp/aufs-tests/aufs/mnt/XXXXX: Invalid argument

and auplink exits with exit code of 22 (EINVAL).

Looking into auplink source code, what happens is it tries to find a
record in /proc/self/mounts corresponding to the mount point (by using
setmntent()/getmntent_r() glibc functions), and it fails.

Some manual testing, as well as runtime testing with lots of printf
added on mount/unmount, as well as calls to check the superblock fs
magic on mount point (as in graphdriver.Mounted(graphdriver.FsMagicAufs, target)
confirmed that this record is in fact there, but sometimes auplink
can't find it. I was also able to reproduce the same error (inability
to find a mount in /proc/self/mounts that should definitely be there)
using a small C program, mocking what `auplink` does:

```c
 #include <stdio.h>
 #include <err.h>
 #include <mntent.h>
 #include <string.h>
 #include <stdlib.h>

int main(int argc, char **argv)
{
	FILE *fp;
	struct mntent m, *p;
	char a[4096];
	char buf[4096 + 1024];
	int found =0, lines = 0;

	if (argc != 2) {
		fprintf(stderr, "Usage: %s <mountpoint>\n", argv[0]);
		exit(1);
	}

	fp = setmntent("/proc/self/mounts", "r");
	if (!fp) {
		err(1, "setmntent");
	}
	setvbuf(fp, a, _IOLBF, sizeof(a));
	while ((p = getmntent_r(fp, &m, buf, sizeof(buf)))) {
		lines++;
		if (!strcmp(p->mnt_dir, argv[1])) {
			found++;
		}
	}
	printf("found %d entries for %s (%d lines seen)\n", found, argv[1], lines);
	return !found;
}
```

I have also wrote a few other C proggies -- one that reads
/proc/self/mounts directly, one that reads /proc/self/mountinfo instead.
They are also prone to the same occasional error.

It is not perfectly clear why this happens, but so far my best theory
is when a lot of mounts/unmounts happen in parallel with reading
contents of /proc/self/mounts, sometimes the kernel fails to provide
continuity (i.e. it skips some part of file or mixes it up in some
other way). In other words, this is a kernel bug (which is probably
hard to fix unless some other interface to get a mount entry is added).

Now, there is no real fix, and a workaround I was able to come up
with is to retry when we got EINVAL. It usually works on the second
attempt, although I've once seen it took two attempts to go through.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit ae431b10a9508e2bf3b1782e9d435855e3e13977)
Upstream-commit: c303e63ca6c3d25d29b8992451898734fa6e4e7c
Component: engine
2019-06-05 11:51:00 -07:00
c70089ebb3 aufs.Cleanup: optimize
Do not use filepath.Walk() as there's no requirement to recursively
go into every directory under mnt -- a (non-recursive) list of
directories in mnt is sufficient.

With filepath.Walk(), in case some container will fail to unmount,
it'll go through the whole container filesystem which is both
excessive and useless.

This is similar to commit f1a459229724f5e8e440b49f ("devmapper.shutdown:
optimize")

While at it, raise the priority of "unmount error" message from debug
to a warning. Note we don't have to explicitly add `m` as unmount error (from
pkg/mount) will have it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 8fda12c6078ed5c86be0822a7a980c6fbc9220bf)
Upstream-commit: b85d4a4f09badf40201ef7fcbd5b930de216190d
Component: engine
2019-06-05 11:51:00 -07:00
3b8f3b67f2 aufs: optimize lots of layers case
In case there are a big number of layers, so that mount data won't fit
into a single memory page (4096 bytes on most platforms, which is good
enough for about 40 layers, depending on how long graphdriver root path
is), we supply additional layers with O_REMOUNT, as described in aufs
documentation.

Problem is, the current implementation does that one layer at a time
(i.e. there is one mount syscall per each additional layer).

Optimize the code to supply as many layers as we can fit in one page
(basically reusing the same code as for the original mount).

Note, per aufs docs, "[a]t remount-time, the options are interpreted
in the given order, e.g. left to right" so we should be good.

Tested on an image with ~100 layers.

Before (35 syscalls):
> [pid 22756] 1556919088.686955 mount("none", "/mnt/volume_sfo2_09/docker-aufs/aufs/mnt/a86f8c9dd0ec2486293119c20b0ec026e19bbc4d51332c554f7cf05d777c9866", "aufs", 0, "br:/mnt/volume_sfo2_09/docker-au"...) = 0 <0.000504>
> [pid 22756] 1556919088.687643 mount("none", "/mnt/volume_sfo2_09/docker-aufs/aufs/mnt/a86f8c9dd0ec2486293119c20b0ec026e19bbc4d51332c554f7cf05d777c9866", 0xc000c451b0, MS_REMOUNT, "append:/mnt/volume_sfo2_09/docke"...) = 0 <0.000105>
> [pid 22756] 1556919088.687851 mount("none", "/mnt/volume_sfo2_09/docker-aufs/aufs/mnt/a86f8c9dd0ec2486293119c20b0ec026e19bbc4d51332c554f7cf05d777c9866", 0xc000c451ba, MS_REMOUNT, "append:/mnt/volume_sfo2_09/docke"...) = 0 <0.000098>
> ..... (~30 lines skipped for clarity)
> [pid 22756] 1556919088.696182 mount("none", "/mnt/volume_sfo2_09/docker-aufs/aufs/mnt/a86f8c9dd0ec2486293119c20b0ec026e19bbc4d51332c554f7cf05d777c9866", 0xc000c45310, MS_REMOUNT, "append:/mnt/volume_sfo2_09/docke"...) = 0 <0.000266>

After (2 syscalls):
> [pid 24352] 1556919361.799889 mount("none", "/mnt/volume_sfo2_09/docker-aufs/aufs/mnt/8e7ba189e347a834e99eea4ed568f95b86cec809c227516afdc7c70286ff9a20", "aufs", 0, "br:/mnt/volume_sfo2_09/docker-au"...) = 0 <0.001717>
> [pid 24352] 1556919361.801761 mount("none", "/mnt/volume_sfo2_09/docker-aufs/aufs/mnt/8e7ba189e347a834e99eea4ed568f95b86cec809c227516afdc7c70286ff9a20", 0xc000dbecb0, MS_REMOUNT, "append:/mnt/volume_sfo2_09/docke"...) = 0 <0.001358>

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit d58c434bffef76e48bff75ede290937874488dd3)
Upstream-commit: 75488521735325e4564e66d9cf9c2b1bc1c2c64b
Component: engine
2019-06-05 11:51:00 -07:00
5ada897229 aufs: add lock around mount
Apparently there is some kind of race in aufs kernel module code,
which leads to the errors like:

[98221.158606] aufs au_xino_create2:186:dockerd[25801]: aufs.xino create err -17
[98221.162128] aufs au_xino_set:1229:dockerd[25801]: I/O Error, failed creating xino(-17).
[98362.239085] aufs au_xino_create2:186:dockerd[6348]: aufs.xino create err -17
[98362.243860] aufs au_xino_set:1229:dockerd[6348]: I/O Error, failed creating xino(-17).
[98373.775380] aufs au_xino_create:767:dockerd[27435]: open /dev/shm/aufs.xino(-17)
[98389.015640] aufs au_xino_create2:186:dockerd[26753]: aufs.xino create err -17
[98389.018776] aufs au_xino_set:1229:dockerd[26753]: I/O Error, failed creating xino(-17).
[98424.117584] aufs au_xino_create:767:dockerd[27105]: open /dev/shm/aufs.xino(-17)

So, we have to have a lock around mount syscall.

While at it, don't call the whole Unmount() on an error path, as
it leads to bogus error from auplink flush.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 5cd62852fa199f272b542d828c8c5d1db427ea53)
Upstream-commit: bb4b9fe29eba57ed71d8105ec0e5dacc8e72129e
Component: engine
2019-06-05 11:51:00 -07:00
5db6e4ad9b aufs: aufsMount: better errors for unix.Mount()
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 5873768dbe3be2733874b8cf68cb492817f81a94)
Upstream-commit: 4ab3020e8df18b5c12c668df6ef3e21b648ce04b
Component: engine
2019-06-05 11:51:00 -07:00