Commit graph

6388 commits

Author SHA1 Message Date
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
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
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
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
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
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
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