Commit graph

6673 commits

Author SHA1 Message Date
Sebastiaan van Stijn
eb14d936bf
daemon: rename variables that collide with imported package names
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-14 17:22:23 +02:00
Sebastiaan van Stijn
797ec8e913
daemon: rename all receivers to "daemon"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-14 17:22:21 +02:00
Sebastiaan van Stijn
5d040cbd16
daemon: fix capitalization of some functions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-14 17:22:19 +02:00
Sebastiaan van Stijn
eeef12f469
daemon: address some minor linting issues and nits
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-14 17:22:17 +02:00
Brian Goff
ced91bee4b On startup, actually shutdown the container.
When a container is left running after the daemon exits (e.g. the daemon
is SIGKILL'd or crashes), it should stop any running containers when the
daemon starts back up.

What actually happens is the daemon only sends the container's
configured stop signal and does not check if it has exited.
If the container does not actually exit then it is left running.

This fixes this unexpected behavior by calling the same function to shut
down the container that the daemon shutdown process does.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-04-13 14:20:12 -07:00
Shijiang Wei
e9d785ce3f enhance storage-opt validation logic in overlay2 driver
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2020-04-12 23:22:30 +08:00
屈骏
f3c1eec99e add zombie check for container when killing it, alernative fix for #40735.
Signed-off-by: 屈骏 <qujun@tiduyun.com>
2020-04-10 16:46:31 +08:00
Brian Goff
933a87236f Reduce allocations for logfile reader
Before this change, the log decoder function provided by the log driver
to logfile would not be able to re-use buffers, causing undeeded
allocations and memory bloat for dockerd.

This change introduces an interface that allows the log driver to manage
it's memory usge more effectively.
This only affects json-file and local log drivers.

`json-file` still is not great just because of how the json decoder in the
stdlib works.
`local` is significantly improved.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-04-08 12:24:31 -07:00
Carlos de Paula
7ac638f86a Add support to riscv64 to the build scripts
Added riscv64 architecture support to the scripts used to build Docker
and it's dependencies.

Signed-off-by: Carlos de Paula <me@carlosedp.com>
2020-04-03 14:33:32 -03:00
Sebastiaan van Stijn
af0415257e
Merge pull request #40694 from kolyshkin/moby-sys-mount-part-II
switch to moby/sys/{mount,mountinfo} part II
2020-04-02 21:52:21 +02:00
Sebastiaan van Stijn
b6f07fad51
Merge pull request #40712 from vboulineau/bugfix-windows-user-cpu
Fix CPU Stat value UsageInUsermode on Windows
2020-04-02 21:37:57 +02:00
Akihiro Suda
3802830989 cgroup2: implement docker stats
The following fields are unsupported:

* BlkioStats: all fields other than IoServiceBytesRecursive
* CPUStats: CPUUsage.PercpuUsage
* MemoryStats: MaxUsage and Failcnt

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-04-02 17:51:34 +09:00
Kir Kolyshkin
5b658a0348 daemon.overlaySupportsSelinux: simplify check
1. Sscanf is very slow, and we don't use the first two fields -- get rid of it.

2. Since the field we search for is at the end of line and prepended by
   a space, we can just use strings.HaveSuffix.

3. Error checking for bufio.Scanner should be done after the Scan()
   loop, not inside it.

Fixes: 885b29df09
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-31 14:32:42 -07:00
vboulineau
ec16053ccf
Fix UsageInUsermode value on Windows
Looks like a wrong copy-paste using `RuntimeKernel100ns` twice instead of `RuntimeUser100ns`

Signed-off-by: Vincent Boulineau <vincent.boulineau@datadoghq.com>
2020-03-27 16:43:22 +01:00
Brian Goff
7a9cb29fb9 Accept platform spec on container create
This enables image lookup when creating a container to fail when the
reference exists but it is for the wrong platform. This prevents trying
to run an image for the wrong platform, as can be the case with, for
example binfmt_misc+qemu.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-03-20 16:10:36 -07:00
Kir Kolyshkin
39048cf656 Really switch to moby/sys/mount*
Switch to moby/sys/mount and mountinfo. Keep the pkg/mount for potential
outside users.

This commit was generated by the following bash script:

```
set -e -u -o pipefail

for file in $(git grep -l 'docker/docker/pkg/mount"' | grep -v ^pkg/mount); do
	sed -i -e 's#/docker/docker/pkg/mount"#/moby/sys/mount"#' \
		-e 's#mount\.\(GetMounts\|Mounted\|Info\|[A-Za-z]*Filter\)#mountinfo.\1#g' \
		$file
	goimports -w $file
done
```

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-03-20 09:46:25 -07:00
Brian Goff
714cba6740
Merge pull request #38788 from AkihiroSuda/bind-nonrecursive-swarm
service: support --mount type=bind,bind-nonrecursive
2020-03-13 15:42:46 -07:00
Sebastiaan van Stijn
1e078e1ac5
Merge pull request #40666 from AkihiroSuda/prohibit-rootless-systemd-cgroup1
daemon: fail early if rootless && cgroupdriver == "systemd" && cgroup v1
2020-03-13 22:29:04 +01:00
Akihiro Suda
745fa04e52 service: support --mount type=bind,bind-nonrecursive
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-13 19:01:28 +09:00
Akihiro Suda
f073ed4187
Merge pull request #39816 from tao12345666333/rm-systeminfo-error-handler
Remove `SystemInfo()` error handling.
2020-03-13 01:59:13 +09:00
Brian Goff
470d32d32a
Merge pull request #40483 from AkihiroSuda/fuse-overlayfs
new storage driver: fuse-overlayfs
2020-03-11 11:32:37 -07:00
Akihiro Suda
92e7f8f67c daemon: fail early if rootless && cgroupdriver == "systemd" && cgroup v1
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-11 12:49:03 +09:00
Jintao Zhang
18c22f5bc1 fix backingFs assignment
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
2020-03-10 00:03:59 +08:00
Akihiro Suda
5ddbe511a1
Merge pull request #40614 from thaJeztah/more_deprecating
Add warnings for deprecated "cluster" functions, and deprecate API fields
2020-03-06 16:35:42 +09:00
Sebastiaan van Stijn
616e64b42f
API: deprecate /info "ClusterStore" and "ClusterAdvertise" fields
These fields will now be omitted when empty.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-03 18:10:47 +01:00
Sebastiaan van Stijn
a5538c06f9
Add warning about deprecated "cluster" options to "docker info"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-03 18:10:31 +01:00
Akihiro Suda
9a82a9a8ea vendor containerd, BuildKit, protobuf, grpc, and golang.org/x
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-03-03 10:25:20 +09:00
Brian Goff
76e3a49933
Merge pull request #40486 from AkihiroSuda/rootless-cgroup2-systemd
rootless: support `--exec-opt native.cgroupdriver=systemd`
2020-03-02 16:11:21 -08:00
Brian Goff
ce1ceeb257 Add stats options to not prime the stats
Metrics collectors generally don't need the daemon to prime the stats
with something to compare since they already have something to compare
with.
Before this change, the API does 2 collection cycles (which takes
roughly 2s) in order to provide comparison for CPU usage over 1s. This
was primarily added so that `docker stats --no-stream` had something to
compare against.

Really the CLI should have just made a 2nd call and done the comparison
itself rather than forcing it on all API consumers.
That ship has long sailed, though.

With this change, clients can set an option to just pull a single stat,
which is *at least* a full second faster:

Old:
```
time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=false > /dev/null
2>&1

real0m1.864s
user0m0.005s
sys0m0.007s

time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=false > /dev/null
2>&1

real0m1.173s
user0m0.010s
sys0m0.006s
```

New:
```
time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=true > /dev/null
2>&1
real0m0.680s
user0m0.008s
sys0m0.004s

time curl --unix-socket
/go/src/github.com/docker/docker/bundles/test-integration-shell/docker.sock
http://./containers/test/stats?stream=false\&one-shot=true > /dev/null
2>&1

real0m0.156s
user0m0.007s
sys0m0.007s
```

This fixes issues with downstreams ability to use the stats API to
collect metrics.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-02-28 09:54:37 -08:00
Brian Goff
40b2b4b083
Merge pull request #40594 from sfzhu93/Mis_Unlock
daemon/cluster: add a missing Unlock
2020-02-28 09:47:53 -08:00
Sebastiaan van Stijn
39679991f4
Merge pull request #40543 from SamWhited/upstream_logging
Upstream logging changes from Enterprise Edition
2020-02-27 13:54:14 +01:00
Ziheng Liu
83c0bedba9 daemon/cluster: add a missing Unlock
Signed-off-by: Ziheng Liu <lzhfromustc@gmail.com>
2020-02-25 13:55:11 -05:00
Brian Goff
62bd5a33f7
Merge pull request #40137 from fuweid/me-wait-for-remote-containerd-before-reload
daemon: add grpc.WithBlock option
2020-02-21 10:11:10 -08:00
Akihiro Suda
0c6b85717b
Merge pull request #40481 from cpuguy83/stats_use_cond_var
Use condition variable to wake stats collector.
2020-02-21 13:37:14 +09:00
Brian Goff
750f0d1648 Support configuration of log cacher.
Configuration over the API per container is intentionally left out for
the time being, but is supported to configure the default from the
daemon config.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit cbecf48bc352e680a5390a7ca9cff53098cd16d7)
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2020-02-19 17:02:34 -05:00
Brian Goff
e2ceb83a53 Support reads for all log drivers.
This supplements any log driver which does not support reads with a
custom read implementation that uses a local file cache.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit d675e2bf2b75865915c7a4552e00802feeb0847f)
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2020-02-19 17:01:44 -05:00
Akihiro Suda
ca4b51868a rootless: support --exec-opt native.cgroupdriver=systemd
Support cgroup as in Rootless Podman.

Requires cgroup v2 host with crun.
Tested with Ubuntu 19.10 (kernel 5.3, systemd 242), crun v0.12.1.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-02-14 15:32:31 +09:00
Sebastiaan van Stijn
3af8d484b1
Merge pull request #40394 from tao12345666333/reserved-namespace-labels
enforce reserve internal labels.
2020-02-13 01:47:05 +01:00
Sebastiaan van Stijn
58c2615208
Merge pull request #40497 from arkodg/fix-bip-subnet-config
Set the bip network value as the subnet
2020-02-12 12:41:29 +01:00
Jintao Zhang
35d6c1870f enforce reserve internal labels.
The namespaces com.docker.*, io.docker.*, org.dockerproject.*
have been documented to be reserved for Docker's internal use.

Co-Authored-By: Sebastiaan van Stijn <thaJeztah@users.noreply.github.com>
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
2020-02-12 12:03:35 +08:00
Sebastiaan van Stijn
562880b276
Fix more goimports
```
daemon/logger/splunk/splunk_test.go:33: File is not `goimports`-ed (goimports)
        envKey:      "a",
        envRegexKey: "^foo",
        labelsKey:   "b",
        tagKey:      "c",
integration/build/build_test.go:41: File is not `goimports`-ed (goimports)
            rm:      false,
            forceRm: false,
integration/image/remove_unix_test.go:49: File is not `goimports`-ed (goimports)
        Root: d.Root,
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 18:56:25 +01:00
Arko Dasgupta
f800d5f786 Set the bip network value as the subnet
Dont assign the --bip value directly to the subnet
for the default bridge. Instead use the network value
from the ParseCIDR output

Addresses: https://github.com/moby/moby/issues/40392

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2020-02-10 17:38:54 -08:00
Sebastiaan van Stijn
008fc67974
Fluentd: add fluentd-request-ack option
This adds a new `fluentd-request-ack` logging option for the Fluentd
logging driver. If enabled, the server will respond with an acknowledgement.
This option improves the reliability of the message transmission. This
change is not versioned, and affects all API versions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 02:13:24 +01:00
Sebastiaan van Stijn
cc1f3c750e
Fluentd: add fluentd-async option, deprecate fluentd-async-connect
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 02:13:22 +01:00
Sebastiaan van Stijn
a1d4a081dd
Fluentd: extract parsing config, and validate early
This extracts parsing the driver's configuration to a
function, and uses the same function both when initializing
the driver, and when validating logging options.

Doing so allows validating if the provided options are in
the correct format when calling `ValidateOpts`, instead
of resulting in an error when initializing the logging driver.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 02:13:20 +01:00
Sebastiaan van Stijn
8bd4aedb02
Fluentd: sort consts alphabetically
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 02:13:18 +01:00
Sebastiaan van Stijn
ad13a2a4ba
Fluentd: return "invalid parameter" for invalid config options
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 02:13:15 +01:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 00:06:42 +01:00
Akihiro Suda
7418745001 new storage driver: fuse-overlayfs
`fuse-overlayfs` provides rootless overlayfs functionality without depending
on any kernel patch.

Aside from rootless, `fuse-overlayfs` could be potentially used for eliminating
`chown()` calls that happen in userns-remap mode, because `fuse-overlayfs` also
provides shiftfs functionality.

System requirements:
* fuse-overlayfs needs to be installed. Tested with 0.7.6.
* kernel >= 4.18

Unit test: `go test -exec sudo -v ./daemon/graphdriver/fuse-overlayfs`

The implementation is based on Podman's `overlay` driver which supports
both kernel-mode overlayfs and fuse-overlayfs in the single driver instance:
https://github.com/containers/storage/blob/39a8d5ed/drivers/overlay/overlay.go

However, Moby's implementation aims to decouple `fuse-overlayfs` driver from the
kernel-mode driver (`overlay2`) for simplicity.

Fix #40218

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-02-10 23:48:52 +09:00
Brian Goff
e75e6b0e31 Use condition variable to wake stats collector.
Before the collection goroutine wakes up every 1 second (as configured).
This sleep interval is in case there are no stats to collect we don't
end up in a tight loop.

Instead use a condition variable to signal that a collection is needed.
This prevents us from waking the goroutine needlessly when there is no
one looking for stats.

For now I've kept the sleep just moved it to the end of the loop, which
gives some space between collections.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-02-08 11:06:34 -08:00
Brian Goff
f464c31668 Check tmpfs mounts before create anon volume
This makes sure that things like `--tmpfs` mounts over an anonymous
volume don't create volumes uneccessarily.
One method only checks mountpoints, the other checks both mountpoints
and tmpfs... the usage of these should likely be consolidated.

Ideally, processing for `--tmpfs` mounts would get merged in with the
rest of the mount parsing. I opted not to do that for this change so the
fix is minimal and can potentially be backported with fewer changes of
breaking things.
Merging the mount processing for tmpfs can be handled in a followup.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2020-02-04 10:12:05 -08:00
Sebastiaan van Stijn
ca20bc4214
Merge pull request #40007 from arkodg/add-host-docker-internal
Support host.docker.internal in dockerd on Linux
2020-01-27 13:42:26 +01:00
Arko Dasgupta
92e809a680 Support host.docker.internal in dockerd on Linux
Docker Desktop (on MAC and Windows hosts) allows containers
running inside a Linux VM to connect to the host using
the host.docker.internal DNS name, which is implemented by
VPNkit (DNS proxy on the host)

This PR allows containers to connect to Linux hosts
by appending a special string "host-gateway" to --add-host
e.g. "--add-host=host.docker.internal:host-gateway" which adds
host.docker.internal DNS entry in /etc/hosts and maps it to host-gateway-ip

This PR also add a daemon flag call host-gateway-ip which defaults to
the default bridge IP
Docker Desktop will need to set this field to the Host Proxy IP
so DNS requests for host.docker.internal can be routed to VPNkit

Addresses: https://github.com/docker/for-linux/issues/264

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2020-01-22 13:30:00 -08:00
Akihiro Suda
f9d136b6c6
Merge pull request #40307 from dperny/swarm-jobs
Add support for swarm jobs
2020-01-20 12:57:05 +09:00
Sebastiaan van Stijn
be095a1859
Merge pull request #40366 from arkodg/check-cidr-ipv6
Handle the error case when fixed-cidr-ipv6 is empty and ipv6 is enabled
2020-01-14 13:53:45 +01:00
Drew Erny
30d9fe30b1 Add swarm jobs
Adds support for ReplicatedJob and GlobalJob service modes. These modes
allow running service which execute tasks that exit upon success,
instead of daemon-type tasks.

Signed-off-by: Drew Erny <drew.erny@docker.com>
2020-01-13 13:21:12 -06:00
Arko Dasgupta
bdad16b0ee Handle error case when fixed-cidr-ipv6 is empty
When IPv6 is enabled, make sure fixed-cidr-ipv6 is set
by the user since there is no default IPv6 local subnet
in the IPAM

Signed-off-by: Arko Dasgupta <arko.dasgupta@docker.com>
2020-01-13 09:56:41 -08:00
Sebastiaan van Stijn
339fb74cbc
prevent panic if TINI_COMMIT isn't set during build
If TINI_COMMIT isn't set, .go-autogen sets an empty value
as the "expected" commit. Attempting to truncate the value
caused a panic in that situation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-10 15:27:20 +01:00
Sebastiaan van Stijn
e6c1820ef5
Merge pull request #40174 from AkihiroSuda/cgroup2
support cgroup2
2020-01-09 20:09:11 +01:00
Brian Goff
03163f6825
Merge pull request #40291 from akhilerm/privileged-device
35991- make `--device` works at privileged mode
2020-01-02 10:09:31 -08:00
Akhil Mohan
86ebbe16de
remove host directory check
Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
2020-01-02 14:28:51 +05:30
Akihiro Suda
491531c12b cgroup2: mark cpu-rt-{period,runtime} unimplemented
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-01-01 02:58:40 +09:00
Akihiro Suda
19baeaca26 cgroup2: enable cgroup namespace by default
For cgroup v1, we were unable to change the default because of
compatibility issue.

For cgroup v2, we should change the default right now because switching
to cgroup v2 is already breaking change.

See also containers/libpod#4363 containers/libpod#4374

Privileged containers also use cgroupns=private by default.
https://github.com/containers/libpod/pull/4374#issuecomment-549776387

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-01-01 02:58:40 +09:00
Akihiro Suda
612343618d cgroup2: use shim V2
* Requires containerd binaries from containerd/containerd#3799 . Metrics are unimplemented yet.
* Works with crun v0.10.4, but `--security-opt seccomp=unconfined` is needed unless using master version of libseccomp
  ( containers/crun#156, seccomp/libseccomp#177 )
* Doesn't work with master runc yet
* Resource limitations are unimplemented

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2020-01-01 02:58:40 +09:00
Brian Goff
8d2456d1e6
Merge pull request #40246 from thaJeztah/system_windows_cleanup
pkg/system: minor cleanups and remove use of deprecated system.GetOSVersion()
2019-12-19 11:36:29 -08:00
Brian Goff
b95fad8e51
Merge pull request #40263 from thaJeztah/normalize_comments
Normalize comment formatting
2019-12-12 12:06:22 -08:00
Akhil Mohan
35b9e6989f
Make --device flag work in privileged mode
When a container is started in privileged mode, the device mappings
provided by `--device` flag was ignored. Now the device mappings will
be considered even in privileged mode.

Signed-off-by: Akhil Mohan <akhil.mohan@mayadata.io>
2019-12-06 18:43:56 +05:30
wenlxie
03b3ec1dd5
make --device works at privileged mode
Signed-off-by: wenlxie <wenlxie@ebay.com>
2019-12-06 18:17:03 +05:30
Brian Goff
e25754b80c
Merge pull request #40186 from pradipd/default-nat-subnet
Dockerd won't start if a network with the default subnet prefix already exists in HNS.
2019-12-03 09:31:29 -08:00
Sebastiaan van Stijn
f4f56b1197
daemon: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:43:53 +01:00
Sebastiaan van Stijn
ec4bc83258
daemon/graphdriver: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:43:23 +01:00
Sebastiaan van Stijn
6625fa6103
daemon/cluster: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:42:53 +01:00
Sebastiaan van Stijn
ba6bbca89a
daemon/logger: normalize comment formatting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-27 15:42:27 +01:00
Akihiro Suda
a4a0429eec
Merge pull request #40234 from Jonas-Heinrich/40232-comply-with-gelf-spec
Change gelf logger to comply with gelf spec
2019-11-26 12:06:47 +09:00
Akihiro Suda
7bd40b56ef
Merge pull request #40249 from thaJeztah/os_seek_deprecated
remove use of deprecated os.SEEK_END
2019-11-26 12:06:29 +09:00
Akihiro Suda
d2d8e96f51
Merge pull request #39940 from carlosedp/runtime-version
Change version parsing to support alternate runtimes
2019-11-26 09:55:53 +09:00
Sebastiaan van Stijn
6ee536b4a0
daemon: remove use of deprecated os.SEEK_END
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 18:53:03 +01:00
Sebastiaan van Stijn
044b74e33b
daemon: remove use of deprecated system.GetOSVersion()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-25 13:39:50 +01:00
Jonas Heinrich
5c6b913ff1
logger/gelf: Skip empty lines to comply with spec
The [gelf payload specification](http://docs.graylog.org/en/2.4/pages/gelf.html#gelf-payload-specification)
demands that the field `short_message` *MUST* be set by the client library.
Since docker logging via the gelf driver sends messages line by line, it can happen that messages with an empty
`short_message` are passed on. This causes strict downstream processors (like graylog) to raise an exception.

The logger now skips messages with an empty line.

Resolves: #40232
See also: #37572

Signed-off-by: Jonas Heinrich <Jonas@JonasHeinrich.com>
2019-11-25 11:55:15 +01:00
Tõnis Tiigi
d1d5f64766
Merge pull request #40021 from thaJeztah/carry_40017
Use newer x/sys/windows SecurityAttributes struct (carry 40017)
2019-11-21 08:57:22 -08:00
Sebastiaan van Stijn
1086671441
Merge pull request #40212 from olljanat/default-capabilities-to-caps
Move DefaultCapabilities() to caps package
2019-11-17 14:00:06 +01:00
Akihiro Suda
4124e78d57
Merge pull request #40100 from thaJeztah/test_fixes
Some small (test) fixes/improvements
2019-11-16 14:13:35 +09:00
Akihiro Suda
4f8070c84d
Merge pull request #40210 from kolyshkin/ovr-rm-checks
overlay[2]: rm extra checks in init
2019-11-15 22:43:52 +09:00
Olli Janatuinen
1308a3a99f Move DefaultCapabilities() to caps package
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2019-11-14 21:13:16 +02:00
Kir Kolyshkin
e226aea280 overlay[2]: rm fs checks
Now that we do check if overlay is working by performing an actual
overlayfs mount, there's no need in extra checks for the kernel version
or the filesystem type. Actual mount check is sufficient.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-11-14 08:13:12 -08:00
Olli Janatuinen
447a840254 Windows: Use system specific parallelism value on containers restart
Signed-off-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2019-11-11 15:44:47 +02:00
Kir Kolyshkin
649e4c8889 Fix/improve overlay support check
Before this commit, overlay check was performed by looking for
`overlay` in /proc/filesystem. This obviously might not work
for rootless Docker (fs is there, but one can't use it as non-root).

This commit changes the check to perform the actual mount, by reusing
the code previously written to check for multiple lower dirs support.

The old check is removed from both drivers, as well as the additional
check for the multiple lower dirs support in overlay2 since it's now
a part of the main check.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-11-08 11:49:39 -08:00
Kir Kolyshkin
d5687079ad overlay: move supportsMultipleLowerDir to utils
This moves supportsMultipleLowerDir() to overlayutils
so it can be used from both overlay and overlay2.

The only changes made were:
 * replace logger with logrus
 * don't use workDirName mergedDirName constants
 * add mnt var to improve readability a bit

This is a preparation for the next commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-11-08 11:48:47 -08:00
Yong Tang
f09dc2f4fc Fix docker crash when creating namespaces with UID in /etc/subuid and /etc/subgid
This fix tries to address the issue raised in 39353 where
docker crash when creating namespaces with UID in /etc/subuid and /etc/subgid.

The issue was that, mapping to `/etc/sub[u,g]id` in docker does not
allow numeric ID.

This fix fixes the issue by probing other combinations (uid:groupname, username:gid, uid:gid)
when normal username:groupname fails.

This fix fixes 39353.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2019-11-07 20:17:11 +00:00
Pradip Dhara
89c6febfc2 Dockerd won't start if a network with the default subnet prefix already exists in HNS.
Signed-off-by: Pradip Dhara <pradipd@microsoft.com>
2019-11-06 10:54:28 -08:00
Brian Goff
47c5c67ed8
Merge pull request #40032 from jmartin84/fix-grpc-withdialer-deprecation-warning
Fix grpc withdialer deprecation warning
2019-11-05 12:20:33 -08:00
Sebastiaan van Stijn
9a7e96b5b7
Rename "v1" to "statsV1"
follow-up to 27552ceb15, where this
was left as a review comment, but the PR was already merged.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-01 16:18:06 +01:00
Tõnis Tiigi
64fd3dc0d5
Merge pull request #40157 from lzhfromustc/GL_2test
awslogs & archive: prevent 2 goroutine leaks in test functions
2019-10-31 11:24:41 -07:00
Sebastiaan van Stijn
27552ceb15
bump containerd/cgroups 5fbad35c2a7e855762d3c60f2e474ffcad0d470a
full diff: c4b9ac5c76...5fbad35c2a

- containerd/cgroups#82 Add go module support
- containerd/cgroups#96 Move metrics proto package to stats/v1
- containerd/cgroups#97 Allow overriding the default /proc folder in blkioController
- containerd/cgroups#98 Allows ignoring memory modules
- containerd/cgroups#99 Add Go 1.13 to Travis
- containerd/cgroups#100 stats/v1: export per-cgroup stats

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-31 01:09:12 +01:00
Ziheng Liu
d7bc994a08 awslogs & archive: prevent 2 goroutine leaks in test functions
Signed-off-by: Ziheng Liu <lzhfromustc@gmail.com>
2019-10-29 17:03:38 -04:00
Wei Fu
9f73396dab daemon: add grpc.WithBlock option
WithBlock makes sure that the following containerd request is reliable.

In one edge case with high load pressure, kernel kills dockerd, containerd
and containerd-shims caused by OOM. When both dockerd and containerd
restart, but containerd will take time to recover all the existing
containers. Before containerd serving, dockerd will failed with gRPC
error. That bad thing is that restore action will still ignore the
any non-NotFound errors and returns running state for
already stopped container. It is unexpected behavior. And
we need to restart dockerd to make sure that anything is OK.

It is painful. Add WithBlock can prevent the edge case. And
n common case, the containerd will be serving in shortly.
It is not harm to add WithBlock for containerd connection.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-10-25 12:19:35 +08:00
Sebastiaan van Stijn
6b91ceff74
Use hcsshim osversion package for Windows versions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-22 02:53:00 +02:00
Sebastiaan van Stijn
9d726f1c18
Add GoDoc to fix linting validation
The validate step in CI was broken, due to a combination of
086b4541cf, fbdd437d29,
and 85733620eb being merged to master.

```
api/types/filters/parse.go:39:1: exported method `Args.Keys` should have comment or be unexported (golint)
func (args Args) Keys() []string {
^
daemon/config/builder.go:19:6: exported type `BuilderGCFilter` should have comment or be unexported (golint)
type BuilderGCFilter filters.Args
     ^
daemon/config/builder.go:21:1: exported method `BuilderGCFilter.MarshalJSON` should have comment or be unexported (golint)
func (x *BuilderGCFilter) MarshalJSON() ([]byte, error) {
^
daemon/config/builder.go:35:1: exported method `BuilderGCFilter.UnmarshalJSON` should have comment or be unexported (golint)
func (x *BuilderGCFilter) UnmarshalJSON(data []byte) error {
^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-21 21:36:22 +02:00
Tibor Vass
c4cf72bad3
Merge pull request #39964 from thaJeztah/bump_golangci_lint
bump golangci-lint v1.20.0
2019-10-21 10:57:02 -07:00
Sebastiaan van Stijn
5003128854
Merge pull request #40082 from thaJeztah/is_windows_const
daemon: add "isWindows" const
2019-10-19 01:17:24 +02:00
Sebastiaan van Stijn
4addf7ab1c
Merge pull request #39979 from tiborvass/fix-buildkit-prunegc-filter-config
daemon/config: fix filter type in BuildKit GC config
2019-10-18 22:44:48 +02:00
Sebastiaan van Stijn
1741d669b3
daemon: suppress logs in unit tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:57:56 +02:00
Sebastiaan van Stijn
af3bbcc00c
aufs: SA4011: did you mean to break out of the outer loop? (staticcheck)
As caught by staticcheck (after disabling the default exclusion rules);

Based on the comment, this break was indeed meant to break the
loop and return the error.

```
daemon/graphdriver/aufs/mount.go:54:4: SA4011: ineffective break statement. Did you mean to break out of the outer loop? (staticcheck)
			break
			^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:46:00 +02:00
Sebastiaan van Stijn
6d9c219c54
daemon: S1033: unnecessary guard around call to delete (gosimple)
```
daemon/container_operations.go:787:2: S1033: unnecessary guard around call to delete (gosimple)
	if _, ok := container.NetworkSettings.Networks[n.ID()]; ok {
	^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:45:46 +02:00
Sebastiaan van Stijn
cba180cac9
graphdriver/btrfs: SA4003: no value of type uint64 is less than 0 (staticcheck)
```
daemon/graphdriver/btrfs/btrfs.go:609:5: SA4003: no value of type uint64 is less than 0 (staticcheck)
	if driver.options.size <= 0 {
	   ^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:45:39 +02:00
Sebastiaan van Stijn
1f7beb8594
daemon/events/testutils: remove redundant variable
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:45:35 +02:00
Sebastiaan van Stijn
94647b5d86
graphdriver/aufs: SA4021: x = append(y) is equivalent to x = y (staticcheck)
```
daemon/graphdriver/aufs/aufs_test.go:746:8: SA4021: x = append(y) is equivalent to x = y (staticcheck)
	ids = append(ids[2:])
	      ^
```

Also pre-allocating the ids slice while we're at it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-18 00:45:29 +02:00
Sebastiaan van Stijn
05469b5fa2
daemon: add "isWindows" const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-17 23:49:43 +02:00
Justin Cormack
f681590a25
Merge pull request #40081 from thaJeztah/http_constants
Use http constants for HTTP methods and status codes
2019-10-17 11:30:26 -07:00
Justin Cormack
dde030a6b1
Merge pull request #40083 from thaJeztah/daemon_consts
daemon: use constants for AppArmor and Seccomp
2019-10-17 11:12:37 -07:00
Sebastiaan van Stijn
58a6faab4c
daemon/top_unix_test: cleanup test cases and use subtests
The t.Log() caused some unneeded noise; changing these
tests to us subtests instead, so that we can track them
more easily.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-16 03:55:54 +02:00
Sebastiaan van Stijn
2030daf2ee
TestParseInitVersion: add some additional tests
Also slightly harden parseInitVersion

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-16 03:54:14 +02:00
Grant Millar
df7b8f458a daemon: Use short libnetwork ID in exec-root & update libnetwork
Signed-off-by: Grant Millar <rid@cylo.io>
2019-10-15 11:40:24 +01:00
Drew Erny
f36042d259 Add support for sending down service Running and Desired task counts
Adds a new ServiceStatus field to the Service object, which includes the
running and desired task counts. This new field is gated behind a
"status" query parameter.

Signed-off-by: Drew Erny <drew.erny@docker.com>
2019-10-14 10:43:00 -05:00
Sebastiaan van Stijn
133eddaee8
Merge pull request #39987 from devonestes/fix-splunk-ack
Add ability to handle index acknowledgment with splunk log driver
2019-10-14 03:02:35 +02:00
Sebastiaan van Stijn
717575b585
daemon: make supportsSeccomp a const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 19:16:31 +02:00
Sebastiaan van Stijn
a33cf495f2
daemon: use constants for AppArmor profiles
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 19:16:12 +02:00
Sebastiaan van Stijn
9c590ed5c5
daemon/logger/splunk: use constants for http methods
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-13 19:11:26 +02:00
Justen Martin
3b49bd1d84
replaced call to deprecated grpc method WithDialer with WithContextDialer
Signed-off-by: Justen Martin <jmart@the-coder.com>
2019-10-10 15:34:42 -05:00
Tibor Vass
b3be2802d4
Merge pull request #39713 from thaJeztah/containerd_1.3
bump containerd and dependencies to v1.3.0
2019-10-08 10:43:56 -07:00
Kir Kolyshkin
8663d09334 devmapper: fix unit test
It has been pointed out that sometimes device mapper unit tests
fail with the following diagnostics:

> --- FAIL: TestDevmapperSetup (0.02s)
>    graphtest_unix.go:44: graphdriver: loopback attach failed
>    graphtest_unix.go:48: loopback attach failed

The root cause is the absence of udev inside the container used
for testing, which causes device nodes (/dev/loop*) to not be
created.

The test suite itself already has a workaround, but it only
creates 8 devices (loop0 till loop7). It might very well be
the case that the first few devices are already used by the
system (on my laptop 15 devices are busy).

The fix is to raise the number of devices being manually created.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-10-07 13:21:14 -07:00
Derek McGowan
bc5484d2dd
bump moby/buildkit f7042823e340d38d1746aa675b83d1aca431cee3
full diff: 588c73e1e4...f7042823e3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

fix daemon for changes in containerd registry configuration

Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>

Update buildernext and daemon for buildkit update

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-10-04 15:05:35 -07:00
Akihiro Suda
de5a67156b
Merge pull request #39082 from ehazlett/opts-for-create
Add NewContainerOpts to libcontainerd.Create
2019-10-04 08:20:47 +09:00
Tõnis Tiigi
cd19a333c8
Merge pull request #39837 from kdomanski/linked-ipv6
include IPv6 address of linked containers in /etc/hosts
2019-10-03 11:54:02 -07:00
Sebastiaan van Stijn
37760f0c2b
Merge pull request #39974 from cpuguy83/fix_windows_file_handles
Use FILE_SHARE_DELETE for log files on Windows.
2019-10-03 20:10:29 +02:00
Evan Hazlett
35ac4be5d5 add NewContainerOpts to libcontainerd.Create
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2019-10-03 11:45:41 -04:00
Tibor Vass
85733620eb daemon/config: add MarshalJSON for future proofing
If anything marshals the daemon config now or in the future
this commit ensures the correct canonical form for the builder
GC policies' filters.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-10-03 00:10:00 +00:00
Tibor Vass
fbdd437d29 daemon/config: fix filter type in BuildKit GC config
For backwards compatibility, the old incorrect object format for
builder.GC.Rule.Filter still works but is deprecated in favor of array of
strings akin to what needs to be passed on the CLI.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-10-03 00:09:58 +00:00
Jason A. Donenfeld
c3a0a37446
Use newer x/sys/windows SecurityAttributes struct
This struct now has a properly typed member, so use the properly typed
functions with it.

Also update the vendor directory and hope nothing explodes.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-10-02 21:12:23 +02:00
Tibor Vass
9732185e07
Merge pull request #39144 from kunalkushwaha/builder-entitilement-confg
builder entitlements configuration added.
2019-09-30 13:43:27 -07:00
Tibor Vass
b6684a403c
Merge pull request #39985 from thaJeztah/inline_proxyenv
daemon/info: remove use of docker/go-connections
2019-09-26 11:53:12 -07:00
Sebastiaan van Stijn
2c6d368992
Merge pull request #39975 from tiborvass/homedir-less-deps
homedir: remove idtools and libcontainer's user package dependencies
2019-09-26 20:49:39 +02:00
Tibor Vass
39e6def219
Merge pull request #39177 from pricec/image-variant
Add variant to image.Image and legacy builder
2019-09-26 11:14:41 -07:00
Kunal Kushwaha
8b7bbf180f builder entitlements configutation added.
buildkit supports entitlements like network-host and security-insecure.
this patch aims to make it configurable through daemon.json file.
by default network-host is enabled & secuirty-insecure is disabled.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
2019-09-26 16:59:44 +09:00
John Howard
8988448729 Remove refs to jhowardmsft from .go code
Signed-off-by: John Howard <jhoward@microsoft.com>
2019-09-25 10:51:18 -07:00
Devon Estes
cb2a36a89c Add ability to handle index acknowledgment with splunk log driver
Previously there was no way for the splunk log driver to work if index
acknowledgment was set on the HEC, and it would in fact fail silently.
This will now allow users to specify if index acknowledgment is set and
will work with that setting.

Signed-off-by: Devon Estes <devon.c.estes@gmail.com>
2019-09-25 13:37:34 +02:00
Sebastiaan van Stijn
0f0e3163b5
daemon/info: remove use of docker/go-connections
The `docker/go-connections` package was only used for a quite generic utility.

This patch removes the use of the package by replacing the `GetProxyEnv` utility with
a local function that's based on the one in golang.org/x/net/http/httpproxy:
c21de06aaf/http/httpproxy/proxy.go (L100-L107)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-25 11:00:40 +02:00
Chris Price
c21a3cf432 Add variant to image.Image and legacy builder
This commit adds the image variant to the image.(Image) type and
updates related functionality. Images built from another will
inherit the OS, architecture and variant.

Note that if a base image does not specify an architecture, the
local machine's architecture is used for inherited images. On the
other hand, the variant is set equal to the parent image's variant,
even when the parent image's variant is unset.

The legacy builder is also updated to allow the user to specify
a '--platform' argument on the command line when creating an image
FROM scratch. A complete platform specification, including variant,
is supported. The built image will include the variant, as will any
derived images.

Signed-off-by: Chris Price <chris.price@docker.com>
2019-09-24 22:18:16 +00:00
Sebastiaan van Stijn
30c5ec4365
Merge pull request #39949 from thaJeztah/carry_39413
Adding ability to change max download attempts (carry 39413)
2019-09-24 18:22:12 +02:00
Tibor Vass
a8608b5b67 homedir: remove idtools and libcontainer's user package dependencies
About github.com/opencontainers/runc/libcontainer/user:

According to 195d8d544a
this package has two functions:
- Have a static implementation of user lookup, which is now supported in the
  os/user stdlib package with the osusergo build tag, but wasn't at the time.
- Have extra functions that os/user doesn't have, but none of those are used
  in homedir.

Since https://github.com/moby/moby/pull/11287, homedir depended directly on
libcontainer's user package for CurrentUser().
This is being replaced with os/user.Current(), because all of our static
binaries are compiled with the osusergo tag, and for dynamic libraries it
is more correct to use libc's implementation than parsing /etc/passwd.

About github.com/docker/docker/pkg/idtools:

Only dependency was from GetStatic() which uses idtools.LookupUID(uid).
The implementation of idtools.LookupUID just calls to
github.com/opencontainers/runc/libcontainer/user.LookupUid or fallbacks
to exec-ing to getent (since https://github.com/moby/moby/pull/27599).

This patch replaces calls to homedir.GetStatic by homedir.Get(), opting out
of supporting nss lookups in static binaries via exec-ing to getent for
the homedir package.

If homedir package users need to support nss lookups, they are advised
to compile dynamically instead.

Signed-off-by: Tibor Vass <tibor@docker.com>
2019-09-24 00:32:13 +00:00
Brian Goff
a5f237c2b5 Use FILE_SHARE_DELETE for log files on Windows.
This fixes issues where one goroutine tries to delete or rename a file
while another goroutine has the file open (e.g. a log reader).

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2019-09-23 16:45:07 -07:00
Akihiro Suda
610551e039
Merge pull request #38930 from daym/fewer-modprobes
Use fewer modprobes
2019-09-24 02:37:58 +09:00
Brian Goff
a36dfe758d
Merge pull request #39969 from kolyshkin/log-max-file-1-follow
logger: fix follow logs for max-file=1
2019-09-23 08:46:07 -07:00
Danny Milosavljevic
074eca1d79
Use fewer modprobes
Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org>
2019-09-21 11:21:18 +02:00
Kir Kolyshkin
9cd24ba605 logger: fix follow logs for max-file=1
In case jsonlogfile is used with max-file=1 and max-size set,
the log rotation is not perfomed; instead, the log file is closed
and re-open with O_TRUNC.

This situation is not handled by the log reader in follow mode,
leading to an issue of log reader being stuck forever.

This situation (file close/reopen) could be handled in waitRead(),
but fsnotify library chose to not listen to or deliver this event
(IN_CLOSE_WRITE in inotify lingo).

So, we have to handle this by checking the file size upon receiving
io.EOF from the log reader, and comparing the size with the one received
earlier. In case the new size is less than the old one, the file was
truncated and we need to seek to its beginning.

Fixes #39235.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-20 16:09:39 -07:00
Samuel Karp
fd94bae0b8
awslogs: fix flaky TestLogBlocking unit test
TestLogBlocking is intended to test that the Log method blocks by
default.  It does this by mocking out the internals of the
awslogs.logStream and replacing one of its internal channels with one
that is controlled by the test.  The call to Log occurs inside a
goroutine.  Go may or may not schedule the goroutine immediately and the
blocking may or may not be observed outside the goroutine immediately
due to decisions made by the Go runtime.  This change adds a small
timeout for test failure so that the Go runtime has the opportunity to
run the goroutine before the test fails.

Signed-off-by: Samuel Karp <skarp@amazon.com>
2019-09-20 16:06:54 -07:00
Lukas Heeren
ce61a1ed98
Adding ability to change max download attempts
Moby works perfectly when you are in a situation when one has a good and stable
internet connection. Operating in area's where internet connectivity is likely
to be lost in undetermined intervals, like a satellite connection or 4G/LTE in
rural area's, can become a problem when pulling a new image. When connection is
lost while image layers are being pulled, Moby will try to reconnect up to 5 times.
If this fails, the incompletely downloaded layers are lost will need to be completely
downloaded again during the next pull request. This means that we are using more
data than we might have to.

Pulling a layer multiple times from the start can become costly over a satellite
or 4G/LTE connection. As these techniques (especially 4G) quite common in IoT and
Moby is used to run Azure IoT Edge devices, I would like to add a settable maximum
download attempts. The maximum download attempts is currently set at 5
(distribution/xfer/download.go). I would like to change this constant to a variable
that the user can set. The default will still be 5, so nothing will change from
the current version unless specified when starting the daemon with the added flag
or in the config file.

I added a default value of 5 for DefaultMaxDownloadAttempts and a settable
max-download-attempts in the daemon config file. It is also added to the config
of dockerd so it can be set with a flag when starting the daemon. This value gets
stored in the imageService of the daemon when it is initiated and can be passed
to the NewLayerDownloadManager as a parameter. It will be stored in the
LayerDownloadManager when initiated. This enables us to set the max amount of
retries in makeDownoadFunc equal to the max download attempts.

I also added some tests that are based on maxConcurrentDownloads/maxConcurrentUploads.

You can pull this version and test in a development container. Either create a config
`file /etc/docker/daemon.json` with `{"max-download-attempts"=3}``, or use
`dockerd --max-download-attempts=3 -D &` to start up the dockerd. Start downloading
a container and disconnect from the internet whilst downloading. The result would
be that it stops pulling after three attempts.

Signed-off-by: Lukas Heeren <lukas-heeren@hotmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-19 13:51:40 +02:00
Sebastiaan van Stijn
bd7180fcf9
cluster/controllers/plugin: remove unused Controller.taskID (unused)
```
daemon/cluster/controllers/plugin/controller.go:37:2: U1000: field `taskID` is unused (unused)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:49 +02:00
Sebastiaan van Stijn
3926b5f09d
structcheck: nolint for false positives
```
builder/fscache/fscache.go:505:2: `src` is unused (structcheck)
builder/fscache/fscache.go:507:2: `cached` is unused (structcheck)

daemon/graphdriver/vfs/quota_linux.go:9:2: `quotaCtl` is unused (structcheck)
daemon/graphdriver/vfs/quota_linux.go:10:2: `quotaOpt` is unused (structcheck)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:44 +02:00
Sebastiaan van Stijn
9c701fdb6b
logger/journald: U1000: field mu is unused (unused)
this looks to be a false positive, but this field is not
used if journald is not supported, which may be the cause

```
daemon/logger/journald/journald.go:21:2: U1000: field `mu` is unused (unused)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:42 +02:00
Kir Kolyshkin
7b6201f032
daemon/logger/BenchmarkCopy: don't call t.Fatal from a goroutine
staticcheck go linter says:

> daemon/logger/copier_test.go:451:2: SA2002: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (staticcheck)

What it doesn't say is why. The reason is, t.Fatal() calls t.FailNow(),
which is expected to stop test execution right now. It does so by
calling runtime.Goexit(), which, unless called from a main goroutine,
does not stop test execution.

Anyway, long story short, if we don't care much about stopping the test
case immediately, we can just replace t.Fatalf() with t.Errorf() which
still marks the test case as failed, but won't stop it immediately.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:38 +02:00
Sebastiaan van Stijn
2c31edbbb6
unconvert: remove unnescessary conversions
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:33 +02:00
Kir Kolyshkin
04129678a6
jsonfilelog_test: check err from open before close
Fix warnings like this one:

> daemon/logger/jsonfilelog/jsonfilelog_test.go:191:3: SA5001: should check returned error before deferring file.Close() (staticcheck)
> 		defer file.Close()
>		^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:30 +02:00
Kir Kolyshkin
7b0e0335bc
Fix some inefassign warnings
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:29 +02:00
Kir Kolyshkin
365a63a573
daemon/graphdriver/copy: rm dead code
Here, err is never non-nil as it was checked earlier.

Fixes the following linter warning:

> daemon/graphdriver/copy/copy.go:136:10: nilness: impossible condition: nil != nil (govet)
>		if err != nil {
>		       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:23 +02:00
Kir Kolyshkin
58ac4bd938
daemon/checkpoint: rm extra checks
In this code, err is already checked to be nil (or non-nil), so no need
to repeat extra checks.

Fixes the following govet warnings:

> daemon/checkpoint.go:38:12: nilness: tautological condition: nil == nil (govet)
> 		case err == nil:
> 		         ^
> daemon/checkpoint.go:45:12: nilness: tautological condition: nil == nil (govet)
> 		case err == nil && stat.IsDir():
> 		         ^
> daemon/checkpoint.go:47:12: nilness: tautological condition: nil == nil (govet)
> 		case err == nil:
> 		         ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:22 +02:00
Kir Kolyshkin
3ef7f7c650
daemon/monitor: rm redundant if
The last check for err != nil is not needed as err is always non-nil
there. Remove the check.

Also, no need to explicitly define `var err error` here.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-18 12:57:21 +02:00
Sebastiaan van Stijn
07ff4f1de8
goimports: fix imports
Format the source according to latest goimports.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:56:54 +02:00
Sebastiaan van Stijn
56e690f340
cluster/executor: remove unused containerConfig.endpoint()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:48 +02:00
Sebastiaan van Stijn
f6f58f3858
daemon.getEndpointInNetwork() is only used on Windows
```
13:06:14 daemon/network.go:964:6: U1000: func `getEndpointInNetwork` is unused (unused)
13:06:14 func getEndpointInNetwork(name string, n libnetwork.Network) (libnetwork.Endpoint, error) {
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:46 +02:00
Sebastiaan van Stijn
41cfcac7fc
DriverBenchDiffApplyN: ignore empty branch (staticcheck)
suppressing the "SA9003: empty branch (staticcheck)" instead of commenting-out
or removing these lines because removing/commenting these lines causes a ripple
effect of changes, and there's still a to-do below.

```
13:06:14 daemon/graphdriver/graphtest/graphbench_unix.go:175:3: SA9003: empty branch (staticcheck)
13:06:14 		if applyDiffSize != diffSize {
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:43 +02:00
Sebastiaan van Stijn
5ded7886c3
daemon/cluster: fix unused context (staticcheck)
```
daemon/cluster/nodes.go:69:36: SA4009: argument ctx is overwritten before first use (staticcheck)
13:06:14 	return c.lockedManagerAction(func(ctx context.Context, state nodeState) error {
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:42 +02:00
Sebastiaan van Stijn
8695176d11
daemon/seccomp_linux.go: fix error-capitalization (golint)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:55:40 +02:00
Carlos Eduardo
400af1717c Merge branch 'master' into runtime-version
Signed-off-by: Carlos de Paula <me@carlosedp.com>
2019-09-15 13:51:36 -04:00
Carlos de Paula
1a96cf95ca Parse runtime name
Signed-off-by: Carlos de Paula <me@carlosedp.com>
2019-09-15 12:33:52 -04:00
Carlos de Paula
4ab1e808d1 Change version parsing to support alternate runtimes
Signed-off-by: Carlos de Paula <me@carlosedp.com>
2019-09-17 07:06:19 -03:00
Sebastiaan van Stijn
a9aeda8343
Rename some references to docker.exe to dockerd.exe
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-11 15:16:27 +02:00
Sebastiaan van Stijn
cd9e4ec240
Merge pull request #39852 from thaJeztah/detect_invalid_linked_container
Return "invalid parameter" when linking to non-existing container
2019-09-11 09:51:10 +02:00
Vincent Demeester
cd14846d0c
Merge pull request #39818 from thaJeztah/fix_awslogs_linting
awslogs: fix linting issues, and small refactoring
2019-09-11 09:14:38 +02:00
Kirill Kolyshkin
e222d2d9e0
Merge pull request #39706 from thaJeztah/consistent_signature
container.ConfigFilePath: use same signature on Windows
2019-09-11 04:32:30 +03:00
Sebastiaan van Stijn
422067ba7b
Return "invalid parameter" when linking to non-existing container
Trying to link to a non-existing container is not valid, and should return an
"invalid parameter" (400) error. Returning a "not found" error in this situation
would make the client report the container's image could not be found.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-10 23:06:56 +02:00
Sebastiaan van Stijn
6c75c86240
Windows: skip flaky TestLogBlocking
This test frequently fails on Windows RS1 (mainly), so skipping it
for now on Windows;

```
ok  	github.com/docker/docker/daemon/logger	0.525s	coverage: 43.0% of statements
time="2019-09-09T20:37:35Z" level=info msg="Trying to get region from EC2 Metadata"
time="2019-09-09T20:37:36Z" level=info msg="Log stream already exists" errorCode=ResourceAlreadyExistsException logGroupName= logStreamName= message= origError="<nil>"
--- FAIL: TestLogBlocking (0.02s)
    cloudwatchlogs_test.go:313: Expected to be able to read from stream.messages but was unable to
time="2019-09-09T20:37:36Z" level=error msg=Error
time="2019-09-09T20:37:36Z" level=error msg="Failed to put log events" errorCode=InvalidSequenceTokenException logGroupName=groupName logStreamName=streamName message="use token token" origError="<nil>"
time="2019-09-09T20:37:36Z" level=error msg="Failed to put log events" errorCode=DataAlreadyAcceptedException logGroupName=groupName logStreamName=streamName message="use token token" origError="<nil>"
time="2019-09-09T20:37:36Z" level=info msg="Data already accepted, ignoring error" errorCode=DataAlreadyAcceptedException logGroupName=groupName logStreamName=streamName message="use token token"
FAIL
coverage: 78.2% of statements
FAIL	github.com/docker/docker/daemon/logger/awslogs	0.630s
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-09 23:50:04 +02:00
Brian Goff
00c9e7720b
Merge pull request #39677 from kolyshkin/lost-ctx
daemon/ProcessEvent: make sure to cancel the contexts
2019-09-04 13:28:06 -07:00
Sebastiaan van Stijn
e128f17508
Rename variable for consistency
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-03 10:51:45 +02:00
Sebastiaan van Stijn
6e5a304675
container.ConfigFilePath: use same signature on Windows
This made my IDE unhappy; `ConfigFilePath` is an exported function, so
it makes sense to use the same signature for both Linux and Windows.

This patch also adds error handling (same as on Linux), even though the
current implementation will never return an error (it's good practice
to handle errors, so I assumed this would be the right approach)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-03 10:51:43 +02:00
Kir Kolyshkin
2e0cafb01b
awslogs: refactor create()
Get rid of too many nested if statements. Remove the redundand check for
err != nil, fixing the following lint issue:

> daemon/logger/awslogs/cloudwatchlogs.go:452:10: nilness: tautological condition: non-nil != nil (govet)
> 		if err != nil {
> 		       ^

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-09-03 10:39:10 +02:00
Sebastiaan van Stijn
ef2872132d
awslogs: replace deprecated session.New() with session.NewSession()
```
16:04:35 daemon/logger/awslogs/cloudwatchlogs.go:312:25: SA1019: session.New is deprecated: Use NewSession functions to create sessions instead. NewSession has the same functionality as New except an error can be returned when the func is called instead of waiting to receive an error until a request is made.  (staticcheck)
16:04:35 	return ec2metadata.New(session.New())
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-03 10:39:08 +02:00
Sebastiaan van Stijn
54d021ef8f
awslogs: remove unused eventBuffer update
We return immediately after this, so no need to update eventBuffer:

```
16:04:35 daemon/logger/awslogs/cloudwatchlogs.go:554:5: SA4006: this value of `eventBuffer` is never used (staticcheck)
16:04:35 				eventBuffer = eventBuffer[:0]
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-03 10:39:06 +02:00
Kamil Domański
186e22d26e include IPv6 address of linked containers in /etc/hosts
Signed-off-by: Kamil Domański <kamil@domanski.co>
2019-08-31 22:13:58 +02:00
Sebastiaan van Stijn
1250e42a43
daemon:containerStart() fix unhandled error for saveApparmorConfig
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-29 20:28:58 +02:00
Jintao Zhang
9134130b39 Remove SystemInfo() error handling.
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com>
2019-08-29 07:44:39 +08:00
Tibor Vass
32688a47f3
Merge pull request #39699 from thaJeztah/mkdirall_dropin
Allow system.MkDirAll() to be used as drop-in for os.MkDirAll()
2019-08-27 16:27:53 -07:00
Akihiro Suda
cd1356d9ea
Merge pull request #39578 from rgulewich/cgroupns-test-req
Fix running in privileged mode against a daemon with --default-cgroupns-mode=host
2019-08-25 10:46:46 +09:00
Rob Gulewich
530f2d65c3 Explicity set Cgroup NS mode to "host" when running privileged
Signed-off-by: Rob Gulewich <rgulewich@netflix.com>
2019-08-23 11:27:27 -07:00
Derek McGowan
477bf1e413
Fix overlay2 busy error on mount
When mounting overlays which have children, enforce that
the mount is always performed as read only. Newer versions
of the kernel return a device busy error when a lower directory
is in use as an upper directory in another overlay mount.

Adds committed file to indicate when an overlay is being used
as a parent, ensuring it will no longer be mounted with an
upper directory.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-08-21 15:03:52 -07:00
Yong Tang
d7b484c99d
Merge pull request #39749 from yanghaichao12/dev190815
fix docker rmi stucking
2019-08-20 10:09:01 -07:00
Tibor Vass
c139ede2a1
Merge pull request #39710 from thaJeztah/cleanup_initBridgeDriver
initBridgeDriver: minor cleanup and linting fixes
2019-08-19 13:25:11 -07:00
Haichao Yang
d3f64846a2 fix docker rmi stucking
Signed-off-by: Haichao Yang <yang.haichao@zte.com.cn>
2019-08-19 18:28:37 +08:00
Brian Goff
c2f70da793
Merge pull request #38859 from kolyshkin/journald
Fixes for reading journald logs
2019-08-09 10:22:40 -07:00
Sebastiaan van Stijn
1ea8b413d1
initBridgeDriver: minor cleanup and linting fixes
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-09 18:34:35 +02:00
Deep Debroy
4d5b6260bc Fix regression in handling of NotFound err during startup
Signed-off-by: Deep Debroy <ddebroy@docker.com>
2019-08-08 16:58:52 -07:00
Sebastiaan van Stijn
e554ab5589
Allow system.MkDirAll() to be used as drop-in for os.MkDirAll()
also renamed the non-windows variant of this file to be
consistent with other files in this package

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-08 15:05:49 +02:00
Sebastiaan van Stijn
3a4b51ebb8
Merge pull request #39681 from seemethere/only_add_btrfs_when_needed_please
Remove btrfs_noversion build tag, no longer needed
2019-08-07 10:19:56 +02:00
Eli Uriegas
e665263b10
daemon: Remove btrfs_noversion build flag
btrfs_noversion was added in d7c37b5a28
for distributions that did not have the `btrfs/version.h` header file.

Seeing how all of the distributions we currently support do have the
`btrfs/version.h` file we should probably just remove this build flag
altogether.

Signed-off-by: Eli Uriegas <eli.uriegas@docker.com>
2019-08-06 22:55:29 +00:00
Kir Kolyshkin
53cbf1797b daemon/ProcessEvent: make sure to cancel the contexts
Reported by govet linter:

> daemon/monitor.go:57:9: lostcancel: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak (govet)
> 			ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
> 			     ^
> daemon/monitor.go:128:9: lostcancel: the cancel function returned by context.WithTimeout should be called, not discarded, to avoid a context leak (govet)
> 			ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
> 			     ^

Fixes: b5f288 ("Handle blocked I/O of exec'd processes")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-08-05 19:22:23 -07:00
Sebastiaan van Stijn
73c1dae86d
zfs: fix incorrect permissions (staticcheck)
```
13:06:14 daemon/graphdriver/zfs/zfs.go:57:50: SA9002: file mode '600' evaluates to 01130; did you mean '0600'? (staticcheck)
13:06:14 	file, err := os.OpenFile("/dev/zfs", os.O_RDWR, 600)
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-06 00:46:47 +02:00
Sebastiaan van Stijn
e0b10ddcf6
Merge pull request #39646 from ydcool/master
Cast Dev and Rdev of Stat_t to uint64 for mips
2019-08-05 12:03:20 +02:00
Kir Kolyshkin
20a0e58a79 journald/read: fix/unify errors
1. Use "in-place" variables for if statements to limit their scope to
   the respectful `if` block.

2. Report the error returned from sd_journal_* by using CErr().

3. Use errors.New() instead of fmt.Errorf().

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-08-02 10:02:35 -07:00
Kir Kolyshkin
dd4bfe30a8 journald: fix for --tail 0
From the first glance, `docker logs --tail 0` does not make sense,
as it is supposed to produce no output, but `tail -n 0` from GNU
coreutils is working like that, plus there is even a test case
(`TestLogsTail` in integration-cli/docker_cli_logs_test.go).

Now, something like `docker logs --follow --tail 0` makes total
sense, so let's make it work.

(NOTE if --tail is not used, config.Tail is set to -1)

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-08-02 10:02:35 -07:00
Kir Kolyshkin
b73fb8fd5d journald/read: avoid piling up open files
If we take a long time to process log messages, and during that time
journal file rotation occurs, the journald client library will keep
those rotated files open until sd_journal_process() is called.

By periodically calling sd_journal_process() during the processing
loop we shrink the window of time a client instance has open file
descriptors for rotated (deleted) journal files.

This code is modelled after that of journalctl [1]; the above explanation
as well as the value of 1024 is taken from there.

[v2: fix CErr() argument]

[1] https://github.com/systemd/systemd/blob/dc16327c48d/src/journal/journalctl.c#L2676
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2019-08-02 10:02:35 -07:00