Commit graph

32692 commits

Author SHA1 Message Date
John Howard
c97170d618 Builder: Fix parser directive refactoring
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-05-31 18:48:27 -07:00
Ying Li
d60f182049 Do not log the CA config CA signing key in debug mode.
Signed-off-by: Ying Li <ying.li@docker.com>
2017-05-31 18:15:33 -07:00
Madhu Venugopal
0484bdb6ca Vendoring libnetwork 2e99f06621c23a5f4038968f1af1e28c84e4104e
Fixes #33415
Fixes #33346
Implemented few additional IPVS APIs to be used by other projects

Signed-off-by: Madhu Venugopal <madhu@docker.com>
2017-05-31 16:04:00 -07:00
Brian Goff
4d0888e32b Lock container while connecting to a new network.
`ConnectToNetwork` is modfying the container but is not locking the
object.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-05-31 15:13:04 -04:00
Sebastiaan van Stijn
555bd548ca Merge pull request #33443 from DeliangFan/fix_download_image_fails
Fix downloading image fails when build docker
2017-05-31 21:03:37 +02:00
Sebastiaan van Stijn
7ea0d1ecc6 Merge pull request #33363 from tonistiigi/fix-chunked-build
Fix cancelling builder on chunked requests
2017-05-31 20:18:35 +02:00
Vincent Demeester
41c3c9cc86 Merge pull request #33329 from wenjianhn/EINVAL
Don't log EINVAL when unmount IPC
2017-05-31 11:17:19 -07:00
Sebastiaan van Stijn
316681cd2a Merge pull request #33305 from thaJeztah/suppress-logger-close-error
Don't log error if file is already closed
2017-05-31 17:09:09 +02:00
Kenfe-Mickaël Laventure
7c2f20107a Merge pull request #33249 from ripcurld0/env_validate
Add container environment variables correctly to the health check
2017-05-31 07:35:28 -07:00
Raja Sami
bdc87676bf Increase the Coverage of pkg/platform
Signed-off-by: Raja Sami <raja.sami@tenpearls.com>
2017-05-31 13:26:40 +05:00
Jacob Wen
cfa2591d3f Don't warn if the shm or mquere is not mounted
Fix #33328

Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
2017-05-31 16:19:59 +08:00
vanderliang
cb502cd4e8 Fix downloading image fails when build docker
Generate a token for each download process to avoid token expired.

Closes: #33441

Signed-off-by: vanderliang <lansheng@meili-inc.com>
2017-05-31 14:21:32 +08:00
Lei Jitang
7318eba5b2 Don't create source directory while the daemon is being shutdown, fix #30348
If a container mount the socket the daemon is listening on into
container while the daemon is being shutdown, the socket will
not exist on the host, then daemon will assume it's a directory
and create it on the host, this will cause the daemon can't start
next time.

fix issue https://github.com/moby/moby/issues/30348

To reproduce this issue, you can add following code

```
--- a/daemon/oci_linux.go
+++ b/daemon/oci_linux.go
@@ -8,6 +8,7 @@ import (
        "sort"
        "strconv"
        "strings"
+       "time"

        "github.com/Sirupsen/logrus"
        "github.com/docker/docker/container"
@@ -666,7 +667,8 @@ func (daemon *Daemon) createSpec(c *container.Container) (*libcontainerd.Spec, e
        if err := daemon.setupIpcDirs(c); err != nil {
                return nil, err
        }
-
+       fmt.Printf("===please stop the daemon===\n")
+       time.Sleep(time.Second * 2)
        ms, err := daemon.setupMounts(c)
        if err != nil {
                return nil, err

```

step1 run a container which has `--restart always` and `-v /var/run/docker.sock:/sock`
```
$ docker run -ti --restart always -v /var/run/docker.sock:/sock busybox
/ #

```
step2 exit the the container
```
/ # exit
```
and kill the daemon when you see
```
===please stop the daemon===
```
in the daemon log

The daemon can't restart again and fail with `can't create unix socket /var/run/docker.sock: is a directory`.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2017-05-30 22:59:51 -04:00
Sebastiaan van Stijn
75e685d620 Merge pull request #33387 from cpuguy83/go1.8.3
Bump go to go1.8.3
2017-05-31 02:18:09 +02:00
Kenfe-Mickaël Laventure
4f55e390c4 Merge pull request #33419 from runcom/fix-reaper-containerd
libcontainerd: fix reaper goroutine position
2017-05-30 10:55:38 -07:00
Brian Goff
114652ab86 Check signal is unset before using user stopsignal
This fixes an issue where if a stop signal is set, and a user sends
SIGKILL, `container.ExitOnNext()` is not set, thus causing the container
to restart.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-05-30 13:04:36 -04:00
Vincent Demeester
6629f1d0e7 Merge pull request #33360 from aaronlehmann/vendor-swarmkit-7e096ced
Vendor swarmkit 7e096ced
2017-05-30 09:59:48 -07:00
Brian Goff
0c7c900e9e Bump go to go1.8.3
Note that go1.8.2 contains a security fix (CVE-2017-8932).

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-05-30 10:15:59 -04:00
Sebastiaan van Stijn
4bf8714fac Merge pull request #33311 from msabansal/dnssearch
Adding support for DNS search on RS1
2017-05-30 13:09:18 +02:00
Sebastiaan van Stijn
599f207b45 Merge pull request #33411 from vdemeester/move-configdir-away
Move cli.Configdir away (in `flags`).
2017-05-30 11:49:40 +02:00
Tõnis Tiigi
6f46afd978 Merge pull request #33413 from flx42/fix-plugin-retry
Do not reuse a http.Request after a failure in callWithRetry
2017-05-29 17:30:51 -07:00
Vincent Demeester
71d60ec0eb
Move cli.Configdir away (in flags).
This makes integration not depend anymore of `cli` and thus not
require `cobra` and other packages to compile.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-05-29 16:22:33 -07:00
Sebastiaan van Stijn
07b51ed300 Don't log error if file is already closed
When closing the log-file, and the file is already
closed, there's no need to log an error.

This patch adds a `closed` boolean to check if the
file was closed, and if so, skip closing the file.
This prevents errors like this being logged:

    level=error msg="Error closing logger: invalid argument"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-05-29 17:42:37 +02:00
Sebastiaan van Stijn
d192db0d93 Merge pull request #33423 from gesellix/swagger-docs-typo
Fix typo in swagger doc
2017-05-29 15:58:50 +02:00
Sebastiaan van Stijn
79b19c2e16 Merge pull request #33257 from mtesselH/master
Add CreatedAt filed to volume. Display when volume is inspected.
2017-05-29 10:48:07 +01:00
Vincent Demeester
c12becaca7 Merge pull request #33422 from cpuguy83/dont_unmount_all_the_things
Don't unmount entire plugin manager tree on remove
2017-05-28 19:25:12 -07:00
Tobias Gesellchen
56da4f2fb2 Fix typo in swagger doc
Signed-off-by: Tobias Gesellchen <tobias@gesellix.de>
2017-05-27 22:37:36 +02:00
Brian Goff
db5f31732a Don't unmount entire plugin manager tree on remove
This was mistakenly unmounting everything under `plugins/*` instead of
just `plugins/<id>/*` anytime a plugin is removed.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-05-27 12:30:37 -04:00
Antonio Murdaca
27087eacbf
libcontainerd: fix reaper goroutine position
It has observed defunct containerd processes accumulating over
time while dockerd was permanently failing to restart containerd.
Due to a bug in the runContainerdDaemon() function, dockerd does not clean up
its child process if containerd already exits very soon after the (re)start.

The reproducer and analysis below comes from docker 1.12.x but bug
still applies on latest master.

- from libcontainerd/remote_linux.go:

  329 func (r *remote) runContainerdDaemon() error {
   :
   :      // start the containerd child process
   :
  403     if err := cmd.Start(); err != nil {
  404             return err
  405     }
   :
   :      // If containerd exits very soon after (re)start, it is
possible
   :      // that containerd is already in defunct state at the time
when
   :      // dockerd gets here. The setOOMScore() function tries to
write
   :      // to /proc/PID_OF_CONTAINERD/oom_score_adj. However, this
fails
   :      // with errno EINVAL because containerd is defunct. Please see
   :      // snippets of kernel source code and further explanation
below.
   :
  407     if err := setOOMScore(cmd.Process.Pid, r.oomScore); err != nil
{
  408             utils.KillProcess(cmd.Process.Pid)
   :
   :              // Due to the error from write() we return here. As
the
   :              // goroutine that would clean up the child has not
been
   :              // started yet, containerd remains in the defunct
state
   :              // and never gets reaped.
   :
  409             return err
  410     }
   :
  417     go func() {
  418             cmd.Wait()
  419             close(r.daemonWaitCh)
  420     }() // Reap our child when needed
   :
  423 }

This is the kernel function that gets invoked when dockerd tries to
write
to /proc/PID_OF_CONTAINERD/oom_score_adj.

- from fs/proc/base.c:

 1197 static ssize_t oom_score_adj_write(struct file *file, ...
 1198                                         size_t count, loff_t
*ppos)
 1199 {
   :
 1223         task = get_proc_task(file_inode(file));
   :
   :          // The defunct containerd process does not have a virtual
   :          // address space anymore, i.e. task->mm is NULL. Thus the
   :          // following code returns errno EINVAL to dockerd.
   :
 1230         if (!task->mm) {
 1231                 err = -EINVAL;
 1232                 goto err_task_lock;
 1233         }
   :
 1253 err_task_lock:
   :
 1257         return err < 0 ? err : count;
 1258 }

The purpose of the following program is to demonstrate the behavior of
the oom_score_adj_write() function in connection with a defunct process.

$ cat defunct_test.c

\#include <unistd.h>

main()
{
    pid_t pid = fork();

    if (pid == 0)
        // child
        _exit(0);

    // parent
    pause();
}

$ make defunct_test
cc     defunct_test.c   -o defunct_test

$ ./defunct_test &
[1] 3142

$ ps -f | grep defunct_test | grep -v grep
root      3142  2956  0 13:04 pts/0    00:00:00 ./defunct_test
root      3143  3142  0 13:04 pts/0    00:00:00 [defunct_test] <defunct>

$ echo "ps 3143" | crash -s
  PID    PPID  CPU       TASK        ST  %MEM     VSZ    RSS  COMM
  3143   3142   2  ffff880035def300  ZO   0.0       0      0
defunct_test

$ echo "px ((struct task_struct *)0xffff880035def300)->mm" | crash -s
$1 = (struct mm_struct *) 0x0
                          ^^^ task->mm is NULL

$ cat /proc/3143/oom_score_adj
0

$ echo 0 > /proc/3143/oom_score_adj
-bash: echo: write error: Invalid argument"

---

This patch fixes the above issue by making sure we start the reaper
goroutine as soon as possible.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2017-05-27 15:13:59 +02:00
Felix Abecassis
62871ef2fa Do not reuse a http.Request after a failure in callWithRetry
Closes: #33412

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-05-26 18:02:31 -07:00
Akihiro Suda
bde4c89351 Merge pull request #33409 from alfred-landrum/image-prune-panic
prevent image prune panic
2017-05-27 09:37:27 +09:00
Alfred Landrum
32da2a4234
prevent image prune panic
Signed-off-by: Alfred Landrum <alfred.landrum@docker.com>
2017-05-26 12:54:39 -07:00
Marianna
a46f757c40 Add CreatedAt filed to volume. Display when volume is inspected.
Closes #32663 by adding CreatedAt field when volume is created.
Displaying CreatedAt value when volume is inspected
Adding tests to verfiy the new field is correctly populated

Signed-off-by: Marianna <mtesselh@gmail.com>

Moving CreatedAt tests from the CLI

Moving the tests added for the newly added CreatedAt field for Volume, from CLI to API tests

Signed-off-by: Marianna <mtesselh@gmail.com>
2017-05-26 11:47:02 -07:00
Vincent Demeester
e925820bfd Merge pull request #33384 from Microsoft/jjh/sandboxpath
Windows: Remove unused SandboxPath
2017-05-25 11:21:15 -07:00
Vincent Demeester
a2f3f6660d Merge pull request #33320 from sbko/33138-generic-api-error-messages
Stop referring CLI flags in error messages if API client is unknown
2017-05-25 10:48:29 -07:00
Vincent Demeester
8d20641d43 Merge pull request #33061 from dnephin/refactor-builder-probe-cache
[Builder] Refactor builder probe cache and container backend
2017-05-25 10:10:49 -07:00
Wentao Zhang
02ce73f62e Fix when containerd restarted, event handler may exit
Description:
Kill docker-containerd continuously, and use kill -SIGUSR1 <dockerpid>
to check docker callstacks. And we will find that event
handler: startEventsMonitor or handleEventStream will exit.

This will only happen when system is busy, containerd need more time to
startup, and the monitor gorotine maybe exit.

Signed-off-by: Wentao Zhang <zhangwentao234@huawei.com>
2017-05-25 17:32:05 +08:00
Aaron Lehmann
da3c3ec145 Merge pull request #33292 from keloyang/attach-restart-check
Add a restarting check to ContainerAttach
2017-05-24 18:30:05 -07:00
Sebastiaan van Stijn
c22ad736aa Merge pull request #33365 from darrenstahlmsft/revendorGowinio
Update go-winio to v0.4.2
2017-05-24 22:08:59 +01:00
John Howard
2f038c2586 Windows: Remove unused SandboxPath
Signed-off-by: John Howard <jhoward@microsoft.com>
2017-05-24 13:44:35 -07:00
Brian Goff
e4abe7c2ce Merge pull request #33376 from nhorman/keepalive
Ensure that a device mapper task is referenced until task is complete
2017-05-24 15:57:04 -04:00
Tõnis Tiigi
ffd3d6ccd9 Merge pull request #33358 from vdemeester/fix-integration-request-package
Fix `request.SockRequestRaw` error check
2017-05-24 11:49:34 -07:00
Vincent Demeester
08894a7f23 Merge pull request #33095 from chrisdias/chrisdias/multistagebuild
syntax highlighting: support FROM...AS for multi stage build
2017-05-24 11:35:17 -07:00
Sebastiaan van Stijn
4050e3061c Merge pull request #33167 from utzb/rpmbuilds
adding rpm builds for ppc64le and s390x
2017-05-24 17:24:23 +01:00
Neil Horman
d764d8b166 Ensure that a device mapper task is referenced until task is complete
DeviceMapper tasks in go use SetFinalizer to clean up C construct
counterparts in the C LVM library.  While thats well and good, it relies
heavily on the exact interpretation of when the golang garbage collector
determines that an object is unreachable is subject to reclaimation.
While common sense would assert that for stack variables (which these DM
tasks always are), are unreachable when the stack frame in which they
are declared returns, thats not the case.  According to this:

https://golang.org/pkg/runtime/#SetFinalizer

The garbage collector decides that, if a function calls into a
systemcall (which task.run() always will in LVM), and there are no
subsequent references to the task variable within that stack frame, then
it can be reclaimed.  Those conditions are met in several devmapper.go
routines, and if the garbage collector runs in the middle of a
deviceMapper operation, then the task can be destroyed while the
operation is in progress, leading to crashes, failed operations and
other unpredictable behavior.

The fix is to use the KeepAlive interface:

https://golang.org/pkg/runtime/#KeepAlive

The KeepAlive method is effectively an empy reference that fools the
garbage collector into thinking that a variable is still reachable.  By
adding a call to KeepAlive in the task.run() method, we can ensure that
the garbage collector won't reclaim a task object until its execution
within the deviceMapper C library is complete.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
2017-05-24 11:11:23 -04:00
Darren Stahl
3f13107223 Update go-winio to v0.4.2
Signed-off-by: Darren Stahl <darst@microsoft.com>
2017-05-23 18:27:50 -07:00
Tonis Tiigi
23628bd7ef Fix cancelling builder on chunked requests
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2017-05-23 16:29:13 -07:00
Aaron Lehmann
10df99f9ae Vendor swarmkit 7e096ced
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
2017-05-23 15:01:35 -07:00
Vincent Demeester
45e0376ea3
Fix request.SockRequestRaw error check
We should check for error before reading the response (response can be
nil, and thus this would panic)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-05-23 12:48:22 -07:00
Daniel Nephin
19f3b0715c Extract imageProber and ContainerBackend from Builder
Extract a common function for builder.createContainer
Extract imageCache for doing cache probes
Removes the cacheBuested field from Builder
Create a new containerManager class which reduces the interface between the
builder and managing containers to 3 functions (from 6)

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-05-23 15:12:58 -04:00