Commit graph

98 commits

Author SHA1 Message Date
Michael Crosby
2650b1b6ab Check if the container is running if no event
When there is no event for the container it can happen because of a
crash and the container state on the persistent disk will have a
mismatch between what was in `/run` ( machine crash ).

This situation will create an unkillable container in docker because
containerd does not see it and it is not running but docker thinks it is
and you cannot tell it anything different.

This fixes the issue by checking if containerd has the container running
if we do not have an event instead of just returning.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-07-28 11:17:02 -07:00
Lei Jitang
c75de8e33c Fix daemon panic on restoring containers
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-07-26 22:52:52 -04:00
Kenfe-Mickael Laventure
ac068a1f9d Fix missing unlock in libcontainerd.Restore()
This was preventing the "exit" event to be correctly processed during
the restore process without live-restore enabled.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-22 15:21:10 -07:00
Kenfe-Mickael Laventure
5231c55346 Prepend libcontainerd log message with "libcontainerd:"
This will make it easier to pinpoint error messages in the daemon
logs.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-22 15:20:14 -07:00
Kenfe-Mickael Laventure
c02f82756e Update libcontainerd.AddProcess to accept a context
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-19 08:24:39 -07:00
Kenfe-Mickael Laventure
64483c3bda Do not rely on "live" event anymore
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-19 08:24:39 -07:00
Kenfe-Mickael Laventure
29b2714580 Vendor in new containerd
This version introduces the following:
 - uses nanosecond timestamps for event
 - ensure events are sent once their effect is "live"

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-18 11:44:24 -07:00
Tonis Tiigi
0b2023130e Wait for the reader fifo opening to block
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-07-14 10:14:53 -07:00
Antonio Murdaca
0a96ba8a0f Merge pull request #24593 from mlaventure/fix-libcontainerd-data-race
Fix data race in libcontainerd
2016-07-14 17:27:24 +02:00
Kenfe-Mickael Laventure
8e9fbc8f5f Fix data race in libcontainerd
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-13 10:04:42 -07:00
Michael Crosby
a894aec8d8 Add --oom-score-adjust to daemon
This adds an `--oom-score-adjust` flag to the daemon so that the value
provided can be set for the docker daemon's process.  The default value
for the flag is -500.  This will allow the docker daemon to have a
less chance of being killed before containers do.  The default value for
processes is 0 with a min/max of -1000/1000.

-500 is a good middle ground because it is less than the default for
most processes and still not -1000 which basically means never kill this
process in an OOM condition on the host machine.  The only processes on
my machine that have a score less than -500 are dbus at -900 and sshd
and xfce( my window manager ) at -1000.  I don't think docker should be
set lower, by default, than dbus or sshd so that is why I chose -500.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-07-12 15:53:15 -07:00
Tibor Vass
efcf24f0c4 Merge pull request #24156 from Microsoft/jjh/clearbasefs
Windows: Clear volume path for Hyper-V containers
2016-07-07 15:35:14 -07:00
Otto Kekäläinen
644a7426cc Fix spelling in comments, strings and documentation
Signed-off-by: Otto Kekäläinen <otto@seravo.fi>
2016-07-03 20:58:11 +03:00
John Howard
fd4f5c2365 Windows: Ensure VolumePath is not set for Hyper-V containers
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-06-29 16:49:09 -07:00
John Starks
8e34322253 Windows: Disable VM cloning for TP5 image
The Windows TP5 image is not compatible with the Hyper-V isolated
container clone feature. Detect old images and pass a flag specifying that
clone should not be enabled.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-06-24 16:12:44 -07:00
Aaron Lehmann
c9175a6deb Merge pull request #23862 from LK4D4/fix_unused
all: fix usage of some variables
2016-06-23 10:21:10 -07:00
Alexander Morozov
138f9538f3 Merge pull request #23776 from Microsoft/ShutdownError
Windows: Prevent logging errors when shutting down an already shut down container
2016-06-22 12:11:00 -07:00
Alexander Morozov
57e14714ee all: fix usage of some variables
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-06-22 10:40:32 -07:00
Darren Stahl
9aa9bda178 Added stateinfo to WaitExit info to aid debugging daemon hangs
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-06-21 12:41:08 -07:00
Darren Stahl
79060e8212 Windows: Prevent logging errors when shutting down an already shut down container
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-06-20 16:57:08 -07:00
Tibor Vass
a590a6b180 Merge pull request #23532 from swernli/exitCodeFix
Fixing exit code return on error case in Windows.
2016-06-16 19:01:18 -07:00
Stefan J. Wernli
17c1b9c061 Fixing exit code return on error case in Windows.
Right now, if we hit an error retrieving the exit code in HCS process.ExitCode, we return that 0 and that error.  Golang convention says that if an error is returned the other values should not be used, but the caller of ExitCode in libcontainerd has to fall through if an error is received.  Rather than return a success exit code in that failure case, we should return -1 to indicate a generic failure.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-06-14 10:19:55 -07:00
Kenfe-Mickael Laventure
7b2e5216b8 Add support for multiples runtimes
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-14 07:47:31 -07:00
Michael Crosby
3020081e94 Merge pull request #23213 from crosbymichael/restore-option
Add --live-restore flag
2016-06-13 20:57:19 -07:00
Michael Crosby
d705dab1b1 Add --live-restore flag
This flags enables full support of daemonless containers in docker.  It
ensures that docker does not stop containers on shutdown or restore and
properly reconnects to the container when restarted.

This is not the default because of backwards compat but should be the
desired outcome for people running containers in prod.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-06-13 19:16:26 -07:00
Sebastiaan van Stijn
50c7bcac1e Merge pull request #23443 from swernli/servicing-async
Updating call sequence for servicing Windows containers
2016-06-13 19:49:23 +02:00
Antonio Murdaca
44ccbb317c *: fix logrus.Warn[f]
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-06-11 19:42:38 +02:00
Stefan J. Wernli
f2ad7be2c4 Updating call sequence for servicing Windows containers
This change adjusts the calling pattern for servcing containers to use waiting on the process instead of expecting start to block.  This is safer, as it avoids timeouts in the start code path for the potentially expensive update operation.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-06-10 15:19:10 -07:00
Kenfe-Mickael Laventure
64a91ee74e Increase containerd start-timeout to 2 minutes
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
(cherry picked from commit 4251e1e99e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-06-10 16:22:19 +02:00
Jannick Fahlbusch
e3490cdcc0 Fix some typos
Signed-off-by: Jannick Fahlbusch <git@jf-projects.de>
2016-06-08 21:59:34 +02:00
Thomas Leonard
b6c7becbfe
Add support for user-defined healthchecks
This PR adds support for user-defined health-check probes for Docker
containers. It adds a `HEALTHCHECK` instruction to the Dockerfile syntax plus
some corresponding "docker run" options. It can be used with a restart policy
to automatically restart a container if the check fails.

The `HEALTHCHECK` instruction has two forms:

* `HEALTHCHECK [OPTIONS] CMD command` (check container health by running a command inside the container)
* `HEALTHCHECK NONE` (disable any healthcheck inherited from the base image)

The `HEALTHCHECK` instruction tells Docker how to test a container to check that
it is still working. This can detect cases such as a web server that is stuck in
an infinite loop and unable to handle new connections, even though the server
process is still running.

When a container has a healthcheck specified, it has a _health status_ in
addition to its normal status. This status is initially `starting`. Whenever a
health check passes, it becomes `healthy` (whatever state it was previously in).
After a certain number of consecutive failures, it becomes `unhealthy`.

The options that can appear before `CMD` are:

* `--interval=DURATION` (default: `30s`)
* `--timeout=DURATION` (default: `30s`)
* `--retries=N` (default: `1`)

The health check will first run **interval** seconds after the container is
started, and then again **interval** seconds after each previous check completes.

If a single run of the check takes longer than **timeout** seconds then the check
is considered to have failed.

It takes **retries** consecutive failures of the health check for the container
to be considered `unhealthy`.

There can only be one `HEALTHCHECK` instruction in a Dockerfile. If you list
more than one then only the last `HEALTHCHECK` will take effect.

The command after the `CMD` keyword can be either a shell command (e.g. `HEALTHCHECK
CMD /bin/check-running`) or an _exec_ array (as with other Dockerfile commands;
see e.g. `ENTRYPOINT` for details).

The command's exit status indicates the health status of the container.
The possible values are:

- 0: success - the container is healthy and ready for use
- 1: unhealthy - the container is not working correctly
- 2: starting - the container is not ready for use yet, but is working correctly

If the probe returns 2 ("starting") when the container has already moved out of the
"starting" state then it is treated as "unhealthy" instead.

For example, to check every five minutes or so that a web-server is able to
serve the site's main page within three seconds:

    HEALTHCHECK --interval=5m --timeout=3s \
      CMD curl -f http://localhost/ || exit 1

To help debug failing probes, any output text (UTF-8 encoded) that the command writes
on stdout or stderr will be stored in the health status and can be queried with
`docker inspect`. Such output should be kept short (only the first 4096 bytes
are stored currently).

When the health status of a container changes, a `health_status` event is
generated with the new status. The health status is also displayed in the
`docker ps` output.

Signed-off-by: Thomas Leonard <thomas.leonard@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-06-02 23:58:34 +02:00
Alexander Morozov
cb36dddad1 Merge pull request #23148 from mlaventure/wait-for-containerd-before-restarting-it
Wait for containerd to die before restarting it
2016-06-01 10:35:31 -07:00
Brian Goff
bcf0c8ca28 Merge pull request #23142 from Microsoft/ExtraCleanup
Windows: Remove a double free on hcs container handle
2016-06-01 11:09:06 -04:00
Kenfe-Mickael Laventure
ce160b37e1 Wait for containerd to die before restarting it
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-01 07:45:03 -07:00
Vincent Demeester
c7aba69cc1 Merge pull request #22989 from Microsoft/StartCleanup
Windows: Adding missing cleanup call when container start fails
2016-06-01 15:42:47 +02:00
Daniel Nephin
8b5e5c6195 Set --state-dir on containerd.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2016-05-31 11:48:05 -07:00
Darren Stahl
c8454394f7 Windows: Remove a double free on hcs container handle
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-05-31 10:25:38 -07:00
Darren Stahl
054992e291 Windows: Adding missing cleanup call when container start fails
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-05-31 10:19:05 -07:00
Darren Stahl
717209c9ff Fix a leaked process handle of the first container to start on Windows
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-05-25 21:33:50 -07:00
John Starks
6508c015fe Windows: Use image version, not OS version for TTY fixup
A previous change added a TTY fixup for stdin on older Windows versions to
work around a Windows issue with backspace/delete behavior. This change
used the OS version to determine whether to activate the behavior.
However, the Windows bug is actually in the image, not the OS, so it
should have used the image's OS version.

This ensures that a Server TP5 container running on Windows 10 will have
reasonable console behavior.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-05-25 12:22:52 -07:00
John Howard
c7ee503082 Merge pull request #22958 from Microsoft/hcs_rpc
Windows: Use the new HCS RPC API
2016-05-25 09:25:22 -07:00
Darren Stahl
959c1a52bf Change Docker to use the new HCS RPC API
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-05-24 16:36:51 -07:00
Vincent Demeester
86a7632d63 Merge pull request #22091 from amitkris/build_solaris
Get the Docker Engine to build clean on Solaris
2016-05-24 21:41:36 +02:00
Alexander Morozov
d7dfe9103b Merge pull request #22541 from crosbymichael/graph-restore
Implement graph driver restore on reboot
2016-05-23 22:57:23 -07:00
Amit Krishnan
86d8758e2b Get the Docker Engine to build clean on Solaris
Signed-off-by: Amit Krishnan <krish.amit@gmail.com>
2016-05-23 16:37:12 -07:00
Michael Crosby
31e903b0e1 Remove restart test
This test is not applicable anymore now that containers are not stopped
when the daemon is restored.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-05-23 15:57:23 -07:00
Michael Crosby
009ee16bef Restore ref count
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-05-23 15:57:23 -07:00
John Starks
f124829c9b Windows: Work around Windows BS/DEL behavior
In Windows containers in TP5, DEL is interpreted as the delete key, but
Linux generally interprets it as backspace. This prevents backspace from
working when using a Linux terminal or the native console terminal
emulation in Windows.

To work around this, translate DEL to BS in Windows containers stdin when
TTY is enabled. Do this only for builds that do not have the fix in
Windows itself.

Signed-off-by: John Starks <jostarks@microsoft.com>
2016-05-20 19:04:20 -07:00
Stefan J. Wernli
a5b64f2847 Fixing Windows update logic.
Removing the call to Shutdown from within Signal in order to rely on waitExit handling the exit of the process.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-05-12 17:45:53 -07:00
Alexander Morozov
e811e9784f Merge pull request #22544 from Microsoft/jjh/terminate
Windows: Terminate on failed shutdown, fixes dockerd deadlock
2016-05-12 14:46:56 -07:00