Commit Graph

466 Commits

Author SHA1 Message Date
Justin Terry (VM)
a4f7b3758e Add support for TaskDelete event on exec in RuntimeV2
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-02-12 15:50:21 -08:00
Kevin Parsons
225d9b120c Fix LCOW layer ordering
Due to an error in the OCI specf for layerFolders, the runhcs shim was
passing the layers for LCOW in reverse order. This fixes the ordering
by simply removing the code which reversed the layers for LCOW.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
2019-02-07 17:27:01 -08:00
Michael Crosby
2dacef07ca Add shim skeleton code
This allows runtime authors to quickly bootstrap new shim
implementations.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-02-06 15:03:02 -05:00
Michael Crosby
6b25c1e45c
Merge pull request #2970 from Random-Liu/fix-exec-race-condition
Fix exec race condition
2019-02-01 16:08:41 -05:00
Justin Terry (VM)
dfcc5942f1 Fix deadlock in Windows runhcs shim exec
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-02-01 10:58:01 -08:00
Lantao Liu
952d58297d Add a separate lock for pid.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-02-01 08:48:26 -08:00
Lantao Liu
9777d76890 Revert "use state machine management for exec.Pid()"
This reverts commit bbc2a995f9.

Signed-off-by: Lantao Liu <lantaol@google.com>
2019-01-31 18:59:34 -08:00
Justin Terry (VM)
6ed293ba94 Fix bug in shim path lookup
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-28 14:04:14 -08:00
Justin Terry (VM)
d63099c4a6 Allow matching shim path side by side with containerd
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-28 12:49:14 -08:00
Justin Terry (VM)
764afa0d18 Include extension for shim binary format on Windows
Use full name including extension for shim binary format on Windows in order to
match any stat path faster without a fallback.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-28 12:42:08 -08:00
Michael Crosby
85aa8ad361 Move task events to runc v2 shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-01-25 14:15:43 -05:00
Phil Estes
f63d28984c
Merge pull request #2939 from jterry75/bug_publishstart
Implement the Runtime v2 Shim async task model for runhcs
2019-01-25 12:39:48 -05:00
Michael Crosby
f444696989 Return out of windows signal handler
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-01-23 16:06:49 -05:00
Lantao Liu
26ab393e7d Use context.Background for O_NONBLOCK OpenFifo.
Signed-off-by: Lantao Liu <lantaol@google.com>
2019-01-23 10:18:54 -08:00
Wei Fu
132ee9b826 fix: linter issue
megacheck, gosimple and unused has been deprecated and subsumed by
staticcheck. And staticcheck also has been upgraded. we need to update
code for the linter issue.

close: #2945

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2019-01-23 22:54:51 +08:00
Michael Crosby
35582cb7a3
Merge pull request #2899 from fuweid/proposal-add-Add-method-in-PlatformRuntime
runtime: add Add/Delete method in PlatformRuntime interface
2019-01-22 13:48:39 -05:00
Justin Terry (VM)
6468619d73 Implement the Runtime v2 Shim async task model for runhcs
Changes the requirement of a Runtime v2 shim in order to avoid race conditions
between shim and shim client sending async events. Places a requirement of what
events and what order a shim must comply to.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-17 14:56:37 -08:00
John Howard
4ef9bf5c84 Windows: Publish exit status correctly in TaskExit
Signed-off-by: John Howard <jhoward@microsoft.com>

Before this change, the shim was only publishing a non-zero exit status
(exit code) in the case that the process.Wait() call failed. This
grabs the exit status correctly when process.Wait() succeeds too.
2019-01-15 11:12:27 -08:00
Phil Estes
33b56e253e
Merge pull request #2927 from jterry75/bug_io_relay_close
Fix issue in runhcs shim CloseIO
2019-01-15 09:59:09 -05:00
John Howard
e30bba53ff
Merge pull request #2926 from jterry75/bug_argon_mount
Fix runhcs shim bug in Create with "len(Rootfs) == 0"
2019-01-14 15:26:32 -08:00
Justin Terry (VM)
c5a8c9fc12 Fix issue in runhcs shim CloseIO
The call was closing all upstream IO when a shim.CloseIO call was made rather
than just the Stdin as it is supposed to.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-14 13:31:28 -08:00
Justin Terry (VM)
31616e7945 Fix runhcs shim bug in Create with "len(Rootfs) == 0"
Rootfs length can be set to zero if the upstream caller fully manages storage
and mounts on their own. In this case just treat the bundle as a fully complete
OCI spec and run it without doing any storage work in the shim.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-14 13:24:15 -08:00
Justin Terry (VM)
bcd4cc51c8 Fixes a bug in runhcs shim Exec.Pid
When an exec occurs the pid was not properly updated on the in memory state
value causing many queries to see a 0.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-14 13:18:02 -08:00
Michael Crosby
fcf5462d49
Merge pull request #2914 from jterry75/runhcs_runtime_opts
Update runhcs options to include CRI Sandbox support
2019-01-07 11:54:41 -05:00
Justin Terry (VM)
bc76e01a87 Update runhcs options to include CRI Sandbox support
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-04 14:37:10 -08:00
Justin Terry (VM)
dee0945e18 Fix spurious ttrpc client shutdown error log on success
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2019-01-03 13:44:29 -08:00
Wei Fu
568b5be936 runtime: add Add/Delete method in PlatformRuntime interface
The two new method Add/Delete can allow custom plugin to add or migrate
existing task into major Runtime plugin.

close: #2888

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2018-12-29 13:56:38 +08:00
Phil Estes
47b328aab7
Merge pull request #2897 from crosbymichael/atomic-delete
Ensure bundle removal is atomic
2018-12-21 08:27:43 -05:00
Michael Crosby
36e4dc603e Ensure bundle removal is atomic
This makes bundle removal atomic by first renaming the bundle and
working directories to a hidden path before removing the underlying
directories.

Closes #2567
Closes #2327

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-12-20 13:45:18 -05:00
Phil Estes
06e04bc5a9
Merge pull request #2830 from Ace-Tang/support_cr_without_image
cr: support checkpoint/restore without image
2018-12-20 13:24:37 -05:00
Justin Terry (VM)
0ec6526fd3 Update the delete docs for Runtime V2 on Windows
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-12-17 13:26:57 -08:00
Justin Cormack
8be05eb237
Fix freebsd build
This brings freebsd in line with Darwin, ie it builds, but some parts may not yet
be fully functional. There is now a WIP `runc` port for FreeBSD at
https://github.com/clovertrail/runc/tree/1501-SupportOnFreeBSD so should be able
to test further.

Signed-off-by: Justin Cormack <justin@specialbusservice.com>
2018-12-16 14:27:42 +00:00
Michael Crosby
a2a4241979 Add timeout and cancel to shim fifo open
There is still a special case where the client side fails to open or
load causes things to be slow and the shim can lock up when this
happens.  This adds a timeout to the context for this case to abort fifo
creation.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-12-13 14:43:41 -05:00
Michael Crosby
3ae8e8a30b Add shim config for shim binary options
Fixes #2855

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-12-05 13:14:26 -05:00
Michael Crosby
66c20f2b75 Update runc to 96ec2177ae841256168fcf76954f7177af
This fixes a regression in runc that didn't allow signals being sent to
paused containers.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-12-04 11:21:20 -05:00
Lantao Liu
79499980e4 Kill should still work in stopped state.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-12-03 16:57:20 -08:00
Ace-Tang
6593399e9f cr: support checkpoint/restore without image
support checkpoint without committing a checkpoint dir into a
checkpoint image and restore without untar image into checkpoint
directory. support for both v1 and v2 runtime

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-11-29 10:19:39 +08:00
Phil Estes
9e372ff01d
Merge pull request #2836 from jterry75/exe_search_path
Cache shim v2 exec.LookPath results
2018-11-28 11:51:03 +00:00
Justin Terry (VM)
09bf314bfd Cache shim v2 exec.LookPath results
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-11-27 15:11:04 -08:00
Phil Estes
dcb82064d3
Merge pull request #2826 from lifubang/statemachineforpid
Fixes: shim service event blocked when waiting for IO finished
2018-11-27 15:46:28 -05:00
Michael Crosby
3eae8b9c3f
Merge pull request #2631 from masters-of-cats/shim-io-redirect
Use named pipes for shim logs
2018-11-27 10:44:00 -05:00
Ace-Tang
fd16bf6d46 runtimev2: add image-path and work-path for c/r
add ImagePath and WorkPath for checkpoint process, add CriuImagePath
and CriuWorkPath for create process in runtime v2 protobuf

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-11-24 23:08:25 +08:00
Ace-Tang
83ebcf9992 runtimev1: add image-path and work-path for c/r
add ImagePath and WorkPath for checkpoint process, add CriuImagePath
and CriuWorkPath for create process in runtime v1 protobuf

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-11-24 23:08:25 +08:00
Lifubang
bbc2a995f9 use state machine management for exec.Pid()
Signed-off-by: Lifubang <lifubang@acmcoder.com>
2018-11-23 17:46:32 +08:00
Phil Estes
181a522142
Merge pull request #2807 from lifubang/shimlockwhenstdinclose
fix pipe in broken may cause shim lock forever
2018-11-20 22:38:22 +08:00
Lantao Liu
7d91d631e0 Lock KillAll.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-11-19 15:19:35 -08:00
Lifubang
e76a8879eb fix pipe in broken may cause shim lock forever for runtime v1
Signed-off-by: Lifubang <lifubang@acmcoder.com>
2018-11-19 09:25:43 +08:00
Lifubang
b3438f7a6f fix pipe in broken may cause shim lock forever for runtime v2
Signed-off-by: Lifubang <lifubang@acmcoder.com>
2018-11-19 09:02:49 +08:00
Phil Estes
d8621e258c
Merge pull request #2800 from crosbymichael/revert-dropped
Revert v2 dropped events
2018-11-17 09:01:58 +08:00
Michael Crosby
d48d7464ad
Merge pull request #2773 from crosbymichael/state-locking
Fix process locking and state management
2018-11-16 14:15:04 -05:00
Michael Crosby
956e49a36b Revert v2 dropped events
Partial revert of #2748

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-11-16 11:34:15 -05:00
Julia Nedialkova
1d4105cacf Use named pipes for shim logs
Relating to issue [#2606](https://github.com/containerd/containerd/issues/2606)

Co-authored-by: Oliver Stenbom <ostenbom@pivotal.io>
Co-authored-by: Georgi Sabev <georgethebeatle@gmail.com>
Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Danail Branekov <danailster@gmail.com>

Signed-off-by: Oliver Stenbom <ostenbom@pivotal.io>
Signed-off-by: Georgi Sabev <georgethebeatle@gmail.com>
Signed-off-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Signed-off-by: Danail Branekov <danailster@gmail.com>
2018-11-16 16:11:43 +02:00
Justin Terry (VM)
8e25ca6bf0 Revendor github.com/sirupsen/logrus to v1.0.3
logrus v1.0.3 was the first release that include the change in
terminal_windows.go that stops exec'ing "cmd ver" to obtain the version
information and rather uses the x/sys/crypto/terminal.IsTerminal on the
console fd. On Windows this is a significant performance difference to
avoid the additional process activation of the "cmd ver" for each
invocation of the shim/runhcs executables.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-11-13 09:27:29 -08:00
Michael Crosby
96d30788e1
Merge pull request #2770 from Random-Liu/partial-revert-#2748
Partially revert the event discard change in #2748.
2018-11-09 15:57:33 -05:00
Michael Crosby
831a41b958 Fix process locking and state management
There were races with the way process states.  This displayed in ways,
especially around pausing the container for atomic operations.  Users
would get errors like, cannnot delete container in paused state and
such.

This can be eaisly reproduced with `docker` and the following command:

```bash
> (for i in `seq 1 25`; do id=$(docker create  alpine usleep 50000);docker start $id;docker commit $id;docker wait $id;docker rm $id; done)
```

This two issues that this fixes are:

* locks must be held by the owning process, not the state operations.
* If a container ends up being paused but before the operation
completes, the process exists, make sure we resume the container before
setting the the process as exited.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-11-09 11:40:37 -05:00
Ace-Tang
c4feaa75cf fix: fix failed to get container-shim relation with io.containerd.runc.v1
add '-id' flag when start container with io.containerd.runc.v1 shim, or user
can not get container-shim relation from 'ps -ef',like

```
/usr/bin/containerd-shim-runc-v1 -namespace default -address
/run/containerd/containerd.sock -publish-binary /usr/bin/containerd
```

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-11-09 11:01:35 +08:00
Lantao Liu
c524b9ce41 Partially revert the event discard change in #2748.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-11-08 14:47:32 -08:00
Wei Fu
38d7d59e8a enhance: update v1/v2 runtime
1. avoid dead lock during kill, fetch allProcesses before handle events
2. use argu's ctx instead of context.Backgroud() in openlog

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2018-11-06 22:48:43 +08:00
Justin Terry (VM)
a33ad40245 Implement io.containerd.runhcs.v1 shim log opts
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-11-05 09:08:48 -08:00
Justin Terry (VM)
ec3dbd155e Add io.containerd.runhcs.v1 shim proto options
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-11-05 09:08:48 -08:00
Michael Crosby
232a063496 Increase reaper buffer size and non-blocking send
Fixes #2709

This increases the buffer size for process exit subscribers. It also
implements a non-blocking send on the subscriber channel.  It is better
to drop an exit even than it is to block a shim for one slow subscriber.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-10-29 16:46:58 -04:00
Ace-Tang
c206da7957 optimize shim lock in runtime v1
apply lock only around process map of shim service, avoid lock affect
other procs operations.

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-10-25 15:27:46 +08:00
Ace-Tang
7b1b16b741 runtime-v2: add validation for runtime name
add validation for runtime name, if runtime name is invalid,
containerd will got panic.

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-10-19 15:19:45 +08:00
Wei Fu
accadd7118 fixtypo: misspell in runtime package
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2018-10-18 23:21:05 +08:00
Justin Terry (VM)
3f1d9b2c4f Revendor github.com/Microsoft/hcsshim
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-15 13:38:24 -07:00
Justin Terry (VM)
ab2031236a Add blocking buffered writes to shim
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-02 11:10:43 -07:00
Justin Terry (VM)
beb1f432be Review fixes
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-02 11:10:43 -07:00
Justin Terry (VM)
2ddbb2db05 Handle shim delete workdir on Windows
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-02 11:10:43 -07:00
Justin Terry (VM)
b8945d35f5 Decrease shim timeout on pipe not found
On Windows because of the way the log pipe is forwarded to the shim there is a
condition where the pipe listener may not yet be active when a client tries to
connect. To handle this case we allow polling on the file and rety on pipe not
found. This limits the pipe not found retry to 5 seconds but leaves the connect
timeout alone as if there is a listener we want to connect to it normally.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-02 11:10:43 -07:00
Justin Terry (VM)
ddbeb3f7c7 Adds Windows shim reconnect logs support
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-10-02 11:10:37 -07:00
Justin Terry (VM)
81eb40fabf Adds containerd-shim-runhcs verbose logging support
Revendors to Microsoft/hcsshim v0.7.5 that added support for logging all
runhcs.exe commands via Windows named pipes. This now launches all runhcs.exe
commands and forwards debug logging to the containerd-shim-runhcs log when
with --debug.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-27 07:46:09 -07:00
Justin Terry (VM)
772644e978 Fixes containerd-shim-runhcs State on exec id
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-27 07:46:09 -07:00
Justin Terry (VM)
83437ef646 Fixes containerd-shim-runhcs Delete on exec id
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-27 07:46:09 -07:00
Justin Terry (VM)
84aa0bfde6 Forward containerd debug to shim invocation
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-27 07:46:01 -07:00
Michael Crosby
87d1118a0f
Merge pull request #2605 from lifubang/runafterstart
fix delete running bundle dir when ctr t start a container again
2018-09-21 14:22:33 -04:00
Lifubang
557e8e0b0d fix delete running bundle dir when run t start cmd again
Signed-off-by: Lifubang <lifubang@acmcoder.com>

code optimization after review

Signed-off-by: Lifubang <lifubang@acmcoder.com>
2018-09-21 06:33:23 +08:00
Justin Terry (VM)
547bb94e4b Fix ctr run for Windows containers
1. Fixes bugs in ctr run that were introduced by 1d9b969
2. Adds support for the --isolated flag that runs Windows HyperV
cotainers instead of process isolated containers on Windows.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-20 14:28:36 -07:00
Justin Terry (VM)
7768ab1b5e Update runhcs-shim to use go-bindings
Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-20 10:40:33 -07:00
John Howard
2586f3fbb9 boltdb/bolt --> go.etcd.io/bbolt
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-09-12 15:23:57 -07:00
Phil Estes
ed2bf6dd8a
Merge pull request #2624 from Ace-Tang/fix_delete_lock
fix: modify lock location of exec delete avoid exec hang
2018-09-11 10:26:32 -04:00
Ace-Tang
079292e3fc fix: modify lock location of exec delete
func (e *execProcess) delete(ctx context.Context) error {
    e.wg.Wait()
...
}
delete exec process will wait for io copy finish, if wait here,
other process can not get lock of shim service.

1. apply lock around s.transition() calls in the Delete methods.
2. put lock after wait io copy in exec Delete.

Signed-off-by: Ace-Tang <aceapril@126.com>
2018-09-11 13:22:59 +08:00
Michael Crosby
12c877f57a
Merge pull request #2618 from crosbymichael/no-stdin
Don't provide IO when it's not set
2018-09-10 11:26:49 -04:00
Michael Crosby
c48cafea40
Merge pull request #2619 from nashasha1/fix/typo-in-runtime
Fix some typo in runtime and snapshots
2018-09-10 09:32:34 -04:00
Xiaodong Zhang
e6d787172c Fix some typo in runtime and snapshots
Signed-off-by: Xiaodong Zhang <a4012017@sina.com>
2018-09-08 08:31:42 +08:00
Michael Crosby
906acb18b6 Don't provide IO when it's not set
This makes sure that runc does not get any valid IO for the pipe.  Some
builds and other containers will be stuck if they inspect stdin
expecially and its a pipe but not connected to any user input.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-09-07 18:30:31 -04:00
Justin Terry (VM)
ef910311e8 Add a Windows section for Linux oci on LCOW
When creating a default OCI spec on Windows that is targeting the LCOW
platform it needs to contain a Windows section as well. This adds the
Windows section by default. It also protects against this case for all
OCI creation that doesnt use the OCI package in the runhcs-shim.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-09-06 11:05:45 -07:00
Claudia Beresford
32e6aa742b Fix teeny tiny typos
Signed-off-by: Claudia Beresford <cberesford@pivotal.io>
2018-09-05 14:44:44 +01:00
yanxuean
517930187e remove useless parameter from newTask
Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
2018-09-04 10:59:00 +08:00
Lantao Liu
7a4e0806c2 Fix runc state error handling.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-08-30 10:47:04 -07:00
Tom Godkin
b5ccc66c2c Do not kill all on task delete by default
- Still KillAll if the task uses the hosts pid namespace
 - Test for both host pid namespace and normal cases

Co-authored-by: Oliver Stenbom <ostenbom@pivotal.io>
Co-authored-by: Georgi Sabev <georgethebeatle@gmail.com>
Signed-off-by: Oliver Stenbom <ostenbom@pivotal.io>
2018-08-30 15:58:33 +01:00
Michael Crosby
2205e8d67a Improve shim locking
Only lock around shim state and not on actions

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-29 11:22:02 -04:00
Michael Crosby
d50e25360c Add context cancel for epoll
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-29 10:44:47 -04:00
Justin Terry (VM)
0110b3c0bc Introduce the Windows lcow diff/snaphotter
Implements the Windows lcow differ/snapshotter responsible for managing
the creation and lifetime of lcow containers on Windows.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-28 13:51:04 -07:00
Derek McGowan
ce1161f806
Merge pull request #2551 from crosbymichael/stdin-block
Don't block on STDIN open
2018-08-28 10:24:05 -07:00
Derek McGowan
be42d777ff
Merge pull request #2575 from crosbymichael/workdir
Remove and create workdir if state dir does not exist
2018-08-27 16:19:25 -07:00
Michael Crosby
ac78a5b615 Remove and create workdir if state dir does not exist
This is the case where the work dir could still exist if a machine
reboots, reseting the state dir.  On container creation, we should just
clear out the work dir.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-27 18:18:50 -04:00
Justin Terry (VM)
e88ec1f1a6 Fix incorrect ID usage in Windows runtime v2
Sometimes the wrong ID was being used because its not correct to assume
that ExecID is always set. The assumption was that for API's where it is
not an exec ID == ExecID but thats not true. ExecID == "" if it is not
an exec. This uses the correct ID in all cases.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-27 11:08:12 -07:00
Michael Crosby
bc1ff51411 Don't block on STDIN open
This was found testing other runtime shims that are faster than runc(no
containerization).  This is a race that can cause the shim to block
forever.  It's not an issue for out/err because we open both sides of
the pipe, but for stdin, it expects the client to have it opened.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-27 10:44:53 -04:00
Justin Terry (VM)
019b0c34de Introduce containerd-shim-runhcs-v1 on Windows
Implements the containerd-shim-runhcs-v1 shim on Windows for the runtime
v2 shim API.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-22 08:15:43 -07:00
Justin Terry (VM)
8362d9aa48 switch shim log Windows client/server direction
Switches the client/server direction of the shim-log pipe on Windows so
that the shim is the listener. This allows the containerd client to
reconnect as needed to the log streams.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-08 12:58:45 -07:00
Michael Crosby
6ba4ddfdda Add shim log pipe for log forwarding to the daemon
A fifo on unix or named pipe on Windows will be provided to the shim.
It can be located inside the `cwd` of the shim named "log".
The shims can use the existing `github.com/containerd/containerd/log` package to log debug messages.
Messages will automatically be output in the containerd's daemon logs with the correct fiels and runtime set.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-07 15:31:00 -04:00
Justin Terry (VM)
dcb905701c Adds retry support to Windows AnonDialer
Adds retry support to AnonDialer if the pipe does not exist. This will
retry up to the timeout for the pipe to exist and connect. This solves
the race between the containerd-shim-* start command and the
reinvocation.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-08-01 13:22:25 -07:00
Justin Terry (VM)
9f13b74f4a Runtime v2 absolute shim path to executable
Fixes an issue where the runtime v2 was not using an absolute path to
the executable but setting the .Dir field on the exec.Cmd. This causes
the executable to need to be relative to .Dir but no shim is actually
copied to the bundle directory that its work dir is set to.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-07-31 15:07:55 -07:00
Michael Crosby
23fbdbaf13 Cleanup workdirs on manager load
This cleans up persistent work dirs on TaskManager boot.  These dirs can
be left behind in a machine reboot.  The state in /run will not exist
but the work dir in the root does, we should cleanup work dirs when
tasks are not loaded.

This also improves error handling that would prevent the task manager
from loading when a single task fails to load or cleanup.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-30 10:21:04 -04:00
Derek McGowan
362405f7b5
Merge pull request #2495 from jterry75/runtime_v2_windows
Adds runtime v2 support for Windows shim's
2018-07-27 11:24:34 -07:00
Justin Terry (VM)
af1b6a026e Review feedback.
1. Moves the log message for each socket to the appropriate _unix and
_windows.go
2. Replaces all reference to Abstract Socket for Windows.
3. Adds support for ctrl+c on Windows to exit a shim.

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-07-27 09:49:33 -07:00
Michael Crosby
13549f7a07 Abstract to SocketAddress
This updates some methods for cross platform use as well as unifying
_unix files.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-27 12:39:53 -04:00
Michael Crosby
9d72b4543b Handle windows signals
Since windows does not require a signal handler, we just block on the
channel forever so that it does not exit.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-26 11:24:20 -04:00
Michael Crosby
f15a1170d3 Add windows publisher
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-26 11:21:50 -04:00
Justin Terry (VM)
d3e0c163f8 Adds runtime v2 support for Windows shim's
Implements the various requirements for the runtime v2 code to abstract
away the unix/linux code into the appropriate platform level
abstractions to use the runtime v2 on Windows as well.

Adds support in the Makefile.windows to actually build the runtime v2
code for Windows by setting a shell environment BUILD_WINDOWS_V2=1
before calling make. (Note this disables the compilation of the Windows
runtime v1)

Signed-off-by: Justin Terry (VM) <juterry@microsoft.com>
2018-07-25 14:09:26 -07:00
Michael Crosby
710df57854 Fast path bundle cleanup on load
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-25 14:37:56 -04:00
Michael Crosby
0d52c71c80
Merge pull request #2474 from dmcgowan/lease-expiration
Improved lease management
2018-07-20 16:54:17 -04:00
Michael Crosby
17ab11a236 Fixes for runtimev2 and checkpoint restore
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-20 12:09:29 -04:00
Michael Crosby
d53a96fbe4 Add comments for oci protos
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-18 15:12:18 -04:00
Derek McGowan
8cf3fad8d4
Add leases manager interface
Add leases manager to the leases package and use the
interface on the client and service.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-07-18 10:43:37 -07:00
Michael Crosby
026b7d922f Add README.md to runtime v2
This readme specifies shim api and authoring docs.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-18 12:08:11 -04:00
Michael Crosby
fd31052d9c Add oom events to shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 16:52:05 -04:00
Michael Crosby
7e49c601a8 Add shim start for shim creation
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 10:21:29 -04:00
Michael Crosby
da1b5470cd Runtime v2
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 10:21:29 -04:00
Michael Crosby
08150bfe76 Update ttrpc for containerd repo
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-28 09:53:40 -04:00
Michael Crosby
68e144c637 Set shim max procs via env var
This sets the shim's max procs to 2, like we already have hard coded in
the shim, with the env var so that it is set at go runtime boot.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-06-26 10:49:59 -04:00
Evan Hazlett
a435f2886c separate proc interfaces into standalone package
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-06-07 10:03:15 -04:00
Evan Hazlett
821c8eaa91
runtime/linux/shim -> runtime/shim
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-06-06 14:35:06 -04:00
Evan Hazlett
cae94b930d linux -> runtime/linux
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-05-30 09:23:10 -04:00
Michael Crosby
c87ed12da5 Move restart pkg to runtime
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-22 17:13:40 -04:00
Michael Crosby
ceae112f7d Rename Runtime to PlatformRuntime
This renames the runtime interface to PlatformRuntime to denote the
layer at which the runtime is being abstracted.  This should be used to
abstract different platforms that vary greatly and do not have full
compat with OCI based binary runtimes.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-05-16 09:36:05 -04:00
Kunal Kushwaha
b12c3215a0 Licence header added
Signed-off-by: Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
2018-02-19 10:32:26 +09:00
Michael Crosby
95d4f53fbe Delete task on dead shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-02-06 12:46:06 -05:00
Lantao Liu
71e42bf65c Lock task list properly.
Signed-off-by: Lantao Liu <lantaol@google.com>
2017-12-03 21:20:01 +00:00
Michael Crosby
5fd0415985 Add comments and fix common lint issues
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-20 13:19:14 -04:00
Jess
061c719209 ListPids returns process ID and other info
Signed-off-by: Jess <jessica.valarezo@docker.com>
2017-10-10 22:57:15 +00:00
Michael Crosby
451421b615 Comment more packages to pass go lint
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-02 13:54:56 -04:00
Michael Crosby
d67763d922 Add wait API endpoint for waiting on process exit
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-09-21 15:03:58 -04:00
Michael Crosby
d22160c28e Vendor typeurl package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-09-19 09:43:55 -04:00
Michael Crosby
697dcdd407 Refactor task service metrics
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-09-05 17:26:26 -04:00
Kenfe-Mickael Laventure
3f34c421d3
Add missing "/tasks/exec-started" event topic
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-29 08:27:44 -07:00
Kenfe-Mickael Laventure
d541567119
Handle SIGKILL'ed shim while daemon is running
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-29 08:27:44 -07:00
Kenfe-Mickael Laventure
8a1b03e525
Add ExitedAt to process proto definition
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-21 08:18:02 -07:00
Michael Crosby
4950c26757 Revert "Wait for client side copy goroutines to start"
This reverts commit 06dc87ae59.

Revert "Change oom metric to const"

This reverts commit e800f08f9f.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-18 16:20:02 -04:00
Michael Crosby
e800f08f9f Change oom metric to const
This removes the metric vec that was holding onto all task id and
namespace combinations forever, until containerd was restarted.  This
was causing a memory leak with many task.

This also removes the shim cmd where the `Args` is quite large from the
reaper after the shim has been started cutting down on another leak.

This is the first pass through the reaper but more code is required to
fix all the issues when commands are added.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-17 16:23:20 -04:00
Michael Crosby
9f13b414b9 Return exit status from Wait of stopped process
This changes Wait() from returning an error whenever you call wait on a
stopped process/task to returning the exit status from the process.

This also adds the exit status to the Status() call on a process/task so
that a user can Wait(), check status, then cancel the wait to avoid
races in event handling.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-03 17:22:33 -04:00
Michael Crosby
a2a3451925 Implement Exec + Start for tasks service
This splits up the exec creation and start in the tasks service

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-02 13:50:08 -04:00
Kenfe-Mickael Laventure
674b460d5a
Move typeurl registrations to runtime package
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-21 18:19:51 +02:00
Kenfe-Mickael Laventure
61fbd2311c
windows: Refactor whole code
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-20 18:39:46 +02:00
Derek McGowan
a8504277cc Merge pull request #1209 from stevvooe/remove-errors
linux, linux/shim: remove error definitions
2017-07-18 19:18:23 -07:00
Stephen J Day
6d0bcd5aec
linux, linux/shim: remove error definitions
Since we now have a common set of error definitions, mapped to existing
error codes, we no longer need the specialized error codes used for
interaction with linux processes. The main issue was that string
matching was being used to map these to useful error codes. With this
change, we use errors defined in the `errdefs` package, which map
cleanly to GRPC error codes and are recoverable on either side of the
request.

The main focus of this PR was in removin these from the shim. We may
need follow ups to ensure error codes are preserved by the `Tasks`
service.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2017-07-18 15:56:49 -07:00
Kenfe-Mickael Laventure
e4beb7c554
Use constants for runtime event topics
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-18 14:19:48 +02:00
Kenfe-Mickael Laventure
88c1db5ca5
Move taskList to the runtime package
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-07-13 13:53:22 +02:00
Michael Crosby
6578565216 Use event service post for shim events
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-07 16:30:57 -07:00
Michael Crosby
f93bfb6233 Add Exec IDs
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-06 15:23:08 -07:00
Michael Crosby
a60511d5aa Use typeurl package for spec types
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-07-05 15:37:26 -07:00
Michael Crosby
72831b6985 Use Any instead of []byte
This allows us to get the fully TypeURL for consuming code.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:32:45 -07:00
Michael Crosby
82d0208aaa Implement options for runtime specific settings
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-29 15:32:45 -07:00
Michael Crosby
e2d5522435 Change ListProcesses to ListPids
These rpcs only return pids []uint32 so should be named that way in
order to have other rpcs that list Processes such as Exec'd processes.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-28 16:10:41 -07:00
Michael Crosby
040558cf81 Remove runtime.Event types
This uses the events service types for runtime events

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-28 10:47:22 -07:00
Michael Crosby
7c8acca29a Move runtime interfaces to runtime package
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-28 10:10:59 -07:00
Michael Crosby
e115b52ce2 Remove containerd files
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-11-07 13:10:09 -08:00
Michael Crosby
97c3c3847a Refactor epoll monitor for generic use
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-09-22 14:03:45 -07:00
Kenfe-Mickael Laventure
db9aed5a97 Use uint32 as Event's Status type everywhere
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-19 12:01:34 -07:00
Kenfe-Mickael Laventure
600b4d1154 Remove containerd as subreaper
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-16 13:38:17 -07:00
Kenfe-Mickael Laventure
85050da1e0 Update ExitStatusFile correctly if process died while daemon was down
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-16 13:30:16 -07:00
Kenfe-Mickael Laventure
f7de90516f Add missing printf parameter when starttime write fails
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-12 09:32:51 -07:00
Kenfe-Mickael Laventure
3281909583 Handle shim being sigkilled while containerd is down
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-08 14:37:55 -07:00
Kenfe-Mickael Laventure
fe5f3d5581 Add proper handling for SIGKILL'ed shim
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-09-07 10:30:02 -07:00
Kenfe-Mickaël Laventure
526a861988 Avoid panicing if cmd.Start() from container.createCmd() failed (#305)
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-08-26 10:56:18 -07:00
Kenfe-Mickaël Laventure
0ac3cd1be1 Fix shim deadlock when joining an existing pid namespace (#290)
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-15 11:49:43 -07:00
Kenfe-Mickaël Laventure
90f827ca10 Streamline events (#287)
* Sync process.State() with the matching events

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Allow requesting events for a specific container

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Sync container state retrieval with other events

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Let containerd take care of calling runtime delete on exit

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Take care of possible race in TestBusyboxTopExecTopKillInit

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-13 11:01:07 -07:00
Kenfe-Mickaël Laventure
6dd2f1c422 Merge pull request #281 from mlaventure/use-protobuf-timestamp
Use protobuf timestamp
2016-07-05 13:37:41 -07:00
Kenfe-Mickaël Laventure
af3c4bd9c5 Merge pull request #276 from resouer/fix-fd
Fix controlPipe is not closed
2016-07-05 11:25:07 -07:00
Kenfe-Mickaël Laventure
3104c6b537 Merge pull request #284 from coolljt0725/set_default_shim
set default shim if shim is nil for backward compatibility
2016-07-05 11:23:53 -07:00
Lei Jitang
0b15e03da0 set default shim if shim is nil for backward compatibility
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-07-05 09:14:20 -04:00
Lei Jitang
bce8df5498 Fix attach to old running container after restart
Get the control pipe of old running container on
containerd restarting.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
2016-07-04 04:19:18 -04:00
Kenfe-Mickael Laventure
d8b9559d8e Handle case where shim is reaped before the call to the runtime start
This avoid erroring out with a false positive

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-07-01 11:26:20 -07:00
Kenfe-Mickael Laventure
3dfa04b2f4 Log runtime error message on delete error
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-30 14:09:04 -07:00
Harry Zhang
2ef56b2ee8 Fix fd leak
Signed-off-by: Harry Zhang <harryzhang@zju.edu.cn>
Signed-off-by: Harry Zhang <harryz@hyper.sh>
2016-06-29 03:35:27 -04:00
Michael Crosby
654c537d38 Call start in containerd
This fixes a sync issue when the containerd api returns after a
container has started.  It fixes it by calling the runtime start inside
containerd after the oom handler has been setup.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-06-27 10:49:20 -07:00
bin liu
004efe5991 fix typos
Signed-off-by: bin liu <liubin0329@gmail.com>
2016-06-22 14:23:32 +08:00
Julio Montes
0227e9fb94 Micro Benchmarks: multiples runtimes (#268)
* Micro benchmarks: use container.Runtime to kill container

Signed-off-by: Julio Montes <julio.montes@intel.com>

* Micro benchmarks: add support for multiples runtimes

Signed-off-by: Julio Montes <julio.montes@intel.com>
2016-06-16 14:39:19 -07:00
boucher
a135e1093d Support the new --empty-ns flags in RunC for checkpoint/restore.
Signed-off-by: Ross Boucher <rboucher@gmail.com>
2016-06-09 16:49:26 -04:00
Kenfe-Mickaël Laventure
8040df4e89 New oom sync (#257)
* Vendor in runc afaa21f79ade3b2e99a68f3f15e7219155aa4662

This updates the Dockerfile to use go 1.6.2 and install pkg-config are
both are now needed by runc.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Add support for runc create/start operation

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Remove dependency on runc state directory for OOM handler

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Add OOM test

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-09 13:33:26 -07:00
Ross Boucher
cf554d59dd Store the checkpoint and restore logs in the same directory as the (#253)
checkpoint image itself.

Signed-off-by: Ross Boucher <rboucher@gmail.com>
2016-06-07 14:05:22 -07:00
Kenfe-Mickaël Laventure
16a8dfe6a8 Add support for updating Kernel Memory Limits (#256)
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-06 11:26:07 -07:00
Kenfe-Mickaël Laventure
5624732128 Add golint to test (#255)
* Add a new lint rule to the Makefile

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Fix linter errors

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>

* Allow replacing the default apt mirror

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-06-03 15:00:49 -07:00
Anusha Ragunathan
24144682a0 Micro benchmarks for containerd. (#244)
This is the first in a series of micro benchmarks for containerd.
Performance measurement will use containerd objects and methods
that are not dependent on the grpc API and dont require the daemon
to the running. Test will require containerd-shim and runc.

The motivation is to understand the baseline performance at the lowest
containerd layer. A natural extension to this effort would be to write
macro benchmarks which would include API and daemon.

Note:
- Currently measures only one workload (busybox sh) start times. Will
add other bundles and args soon.
- Can use integration-test utils for bundle processing. However, json
marshal/unmarshal is currently timing out standard benchmark times. So
going with default spec for now.

Sample run:
BenchmarkBusyboxSh-4    / # / # / #        2     576013841 ns/op
ok      github.com/docker/containerd/runtime    1.800s

Signed-off-by: Anusha Ragunathan <anusha@docker.com>
2016-05-27 10:35:42 -07:00
Ross Boucher
e756ae42d1 Add support for specifying a checkpoint directory. (#245)
Signed-off-by: Ross Boucher <rboucher@gmail.com>
2016-05-25 17:42:37 -07:00
Amit Krishnan
62e1370f91 containerd build clean on Solaris (#203)
* containerd build clean on Solaris

Signed-off-by: Amit Krishnan <krish.amit@gmail.com>

* Vendor golang.org/x/sys

Signed-off-by: Amit Krishnan <krish.amit@gmail.com>
2016-05-19 10:12:50 -07:00
Doug Davis
8ffaa02cd9 Add a better error msg
See https://github.com/docker/docker/issues/22643 for an example
where we get an error running a cmd but there's no output so `b`
is an empty string, which means the user doesn't see any interesting
error message to help them.

This PR will send back the `err` and `b` so that between those two
bits of info they should get something more than a blank string.

Signed-off-by: Doug Davis <dug@us.ibm.com>
2016-05-18 13:52:57 -07:00
Kenfe-Mickael Laventure
1ebdf69a58 Use the new runtime update command to process UpdateResources requests
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-05-09 11:21:45 -07:00
Kenfe-Mickael Laventure
7979ac24fe Fix restore to correctly set the exec timeout value (containerd)
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-05-02 14:04:14 -07:00
Kenfe-Mickael Laventure
7279ff91c4 Add missing shim value when saving container state.json (containerd)
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-05-02 14:02:52 -07:00
Michael Crosby
847690583f Remove sigchld reaper from containerd process
Because we are launching alot of different runc commands to do
operations there is a race between doing a `cmd.Wait()` and getting the
sigchld and reaping it.  We can remove the sigchild reaper from
containerd as long as we make sure we reap the shim process if we are
the parent, i.e. not restored.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-27 16:02:03 -07:00
Michael Crosby
db789045bd Update runc in dockerfile for new commands
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-26 15:06:25 -07:00
Michael Crosby
9ed8422e8c Use runc events --stats for collecting stats
runc `events --stats` now has stable output so we don't need to bind to
libcontainer directly to get stats output for the containers.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-26 14:57:30 -07:00
Michael Crosby
c2df6e08cf Use runc for getting list of processes
runc now has a `ps` command with json output to support listing all the
processes inside a container.  We no longer need to use libcontainer
directly for doing this.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-26 14:40:05 -07:00
Michael Crosby
f7f4d8677f Remove windows code and simplify linux
Windows will not use containerd and its just unused code and unneed
complexity to keep it all around.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-26 14:10:41 -07:00
Michael Crosby
31270bba69 Remove windows files
Windows is not going to use containerd because there is already a
similar implementation on windows.  This removes all the windows files
because there is no reason to keep this overhead when its not going to
be used.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-26 14:10:33 -07:00
Michael Crosby
79c35e0306 Merge pull request #218 from crosbymichael/bump_runc
Update runc and runtime-specs dependencies
2016-04-26 14:05:44 -07:00
Michael Crosby
7a1d28e42b Bump runc and runtime-specs deps
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-26 13:38:36 -07:00
HuKeping
ca7c504068 Bugfix: ctr container list can not get the proper status of container
Prior to this patch, when list containers by "ctr containers" or
"ctr containers xxx", it will not get the proper status of conatinser(s).

That was caused by the wrong implementation of State() for structure process,
it only send a signal "0" to ping the "init" process and do nothing.

Since the OCI/runc has implemented an interface Status(), we can use that.
And I think this is more compatible with the design for containerd:
- containerd -> runtime -> fun()

Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-04-26 07:04:26 -04:00
HuKeping
9d30093505 Interface: introduce status to runtime container
Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-04-22 16:09:50 -04:00
Kenfe-Mickaël Laventure
b31b8a611e Merge pull request #157 from mYmNeo/binary-path
let user to specify the shim name or path
2016-04-21 00:31:14 +10:00
Kenfe-Mickael Laventure
07646a7150 Return runtime output on checkpoint operation errors
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-04-17 12:01:19 -07:00
mYmNeo
4eb27a5926 let user to specify the shim name or path
Signed-off-by: mYmNeo <thomassong@tencent.com>
2016-04-06 14:42:47 +08:00
Michael Crosby
ae107f688e Change sleep to 15ms
This is currently the optimal value for this setting based on runc start
times.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-05 14:07:26 -07:00
Michael Crosby
3742ae3ec8 Add timeout flag for container start times
This currently depends on a runc PR:

https://github.com/opencontainers/runc/pull/703

We need this pr because we have to SIGKILL runc and the container root
dir will still be left around.

As for the containerd changes this adds a flag to containerd so that you
can configure the timeout without any more code changes.  It also adds
better handling in the error cases and will kill the containerd-shim and
runc ( as well as the user process if it exists ) if the timeout is hit.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-04-05 13:38:49 -07:00
Michael Crosby
cb3c208a4d Merge pull request #172 from mlaventure/better-error-for-pause-and-resume
Return the runtime error message on failed pause and resume calls
2016-04-01 14:25:52 -07:00
Michael Crosby
47f239706c Add no pivot root support
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-30 21:52:15 -07:00
Kenfe-Mickael Laventure
fd888e8f34 Return the runtime error message on failed pause and resume calls
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-03-29 11:40:05 -07:00
Kenfe-Mickael Laventure
f07c5ac52a Ensure that runtimeArgs always get passed down to the oci runtime
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-03-29 10:32:37 -07:00
Kenfe-Mickael Laventure
3f388f8638 Take runtimeArgs in account when loading containers state
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-03-25 11:03:11 -07:00
Michael Crosby
6e4d5b385c Add runtimeArgs to pass to shim
This allows you to pass options like:

```bash
containerd --debug --runtime-args "--debug" --runtime-args
"--systemd-cgroup"
```

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-24 13:31:27 -07:00
Tonis Tiigi
bbf760ee6f Add prefixes to external errors
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-22 19:38:22 -07:00
Michael Crosby
142e22a4dc Merge pull request #149 from mlaventure/fix-vet-errors
Fix go vet errors
2016-03-22 10:54:08 -07:00
Kenfe-Mickael Laventure
514ca2d407 Fix go vet errors
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-03-22 09:47:03 -07:00
Tibor Vass
2406bbc1ca Factor out some leftover direct references to runc binary
Signed-off-by: Tibor Vass <tibor@docker.com>
2016-03-22 12:01:25 -04:00
Tibor Vass
b0681dd523 Have containerd-shim filename depend on containerd filename
If containerd binary is renamed to docker-containerd, then it should
invoke the docker-containerd-shim binary.

Signed-off-by: Tibor Vass <tibor@docker.com>
2016-03-21 21:33:35 -04:00
Tonis Tiigi
f9ecd09f4f Retry on pidfile read error
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-18 09:22:13 -07:00
Michael Crosby
6ba5767b70 Return errors from shim in log
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-17 14:44:03 -07:00
Michael Crosby
366dcc08fa Add specific error message for missing shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-17 14:13:08 -07:00
Tonis Tiigi
edd3265858 Raise pidfile wait timeout
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-16 17:45:51 -07:00
Michael Crosby
e637c1ea80 Update specs imports for specs-go
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-15 11:31:32 -07:00
Michael Crosby
bd23df8fd1 Remove process dir and entry on error
If we fail to exec a process make sure that it is cleaned up within the
container's information and on disk state.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-14 16:05:45 -07:00
Michael Crosby
ca6ae2e64b Remove container on load if it exited
If the shim gets sigkilled while containerd is down we need to be able
to remove the container correctly so that it does not stay in a stopped
state forever.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-14 14:23:24 -07:00
Michael Crosby
17e4d62ab0 Update runc state dir
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-11 16:06:38 -08:00
Michael Crosby
b68bc651a8 Handle start errors sync with runc
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-11 10:13:34 -08:00
Tonis Tiigi
4700b961ca Fix userns mapping for tty
- Linux part of the spec was ignored
- Exec used empty spec

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2016-03-10 23:09:39 -08:00
Michael Crosby
0dd075a47b Add update rpc for resource updates
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-03-07 15:23:52 -08:00
Michael Crosby
500ca74f38 Add oom support to events
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-29 17:01:40 -08:00
John Howard
d4ca79c978 Getting ctr closer to compiling on Windows
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-29 12:42:30 -08:00
John Howard
b044ff0f29 Refactor process.go for platform specific
Signed-off-by: John Howard <jhoward@microsoft.com>

Move process sorter to new file

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Sort containers by id

This will not be the most accurate sorting but atleast the list will be
consistent inbetween calls.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Allow runtime to be configurable via daemon start

This allows people to pass an alternate name or location to the runtime
binary to start containers.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Fix state output for containers

Return the proper state/status for a container by checking if the pid is
still alive.  Also fix the cleanup handling in the shim to make sure
containers are not left behind.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Properly wait for container start

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-29 10:43:35 -08:00
John Howard
2b8f022950 runtime compiles on Windows
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-26 14:01:06 -08:00
Michael Crosby
ab74e7b2aa Merge pull request #112 from jhowardmsft/processsyscalls
Refactor process.go for platform specific
2016-02-26 11:04:19 -08:00
John Howard
1acf68535a Refactor process.go for platform specific
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-25 13:01:17 -08:00
John Howard
817c2089aa Refactors getRootIDs
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-02-25 12:13:21 -08:00
Michael Crosby
bdeb87a090 Implement stats for containerd
This is a single endpoint that clients will poll

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 14:36:32 -08:00
Michael Crosby
532697f32f Add all pids to state output
Also update libcontainer dep

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 14:07:34 -08:00
Michael Crosby
d6bd304c92 Add labels for containers
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 13:44:25 -08:00
Michael Crosby
76d69b4ed8 Add id to state command to return single container
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 12:20:29 -08:00
Michael Crosby
d317f71ac2 Move exec and checkpoint to process state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 11:30:25 -08:00
Michael Crosby
cf28969328 Fix tty and io permission for userns
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-11 11:23:35 -08:00
Michael Crosby
20a39bce97 Update to use runc 0.0.8
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-10 16:48:04 -08:00
Michael Crosby
01176f2d7f Add pid and stdio to process state
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-04 14:40:35 -08:00
Michael Crosby
36eb83cb99 Move fifo creation to client
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-03 13:56:15 -08:00
Michael Crosby
a42eb9fd63 Add close stdin
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-02 16:00:22 -08:00
Michael Crosby
277cc920a4 Implement checkpoint / restore for shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-02 16:00:22 -08:00
Michael Crosby
835f3b6a97 Update shim for exec
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-02 16:00:22 -08:00
Michael Crosby
fe38efda50 Add shim for reattach of processes
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Remove runtime files from containerd

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Update supervisor for orphaned containers

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Remove ctr/container.go back to rpc calls

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add attach to loaded container

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add monitor based on epoll for process exits

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Convert pids in containerd to string

This is so that we no longer care about linux or system level pids and
processes in containerd have user defined process id(pid) kinda like the
exec process ids that docker has today.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add reaper back to containerd

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Implement list containers with new process model

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Implement restore of processes

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add NONBLOCK to exit fifo open

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Implement tty reattach

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Fix race in exit pipe creation

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Add delete to shim

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>

Update shim to use pid-file and not stdout

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2016-02-02 16:00:22 -08:00
Burcu Dogan
167219101f runtime: remove unnecessary intermediate type, Status
Signed-off-by: Burcu Dogan <jbd@google.com>
2016-01-28 00:31:33 +01:00
Burcu Dogan
6014cf22d8 Fix typo
Signed-off-by: Burcu Dogan <jbd@google.com>
2016-01-23 14:32:56 -08:00
Michael Crosby
76cf593212 Add oom notifications and pid to create response
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2015-12-15 16:22:53 -08:00