Commit Graph

59 Commits

Author SHA1 Message Date
Derek McGowan
63ceaf877d
Add testing log context
Enables showing debug logs in testing output.
For integration tests the client log output will show
in addition to daemon output, with timestamps for better
correlation.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2019-07-16 10:31:43 -07:00
Michael Crosby
7dfc605fc6 Set shim OOM scores to +1 containerd daemon score
This changes the shim's OOM score from a static max killable of -999 to
be +1 of the containerd daemon's score.  This should allow the shim's to
be killed first in an OOM condition but leave the daemon alone for a bit
to help cleanup and manage the containers during this situation.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-06-27 11:14:14 -04:00
Michael Crosby
fe6a2b03ed Add shim cgroup support for v2 runtimes
Closes #3198

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-05-20 16:04:06 +00:00
Li Yuxuan
cf6e008542 Fix fd leak of shim log
Open shim v2 log with the flag `O_RDWR` will cause the `Read()` block
forever even if the pipe has been closed on the shim side. Then the
`io.Copy()` would never return and lead to a fd leak.
Fix typo when closing shim v1 log which causes the `stdouLog` leak.
Update `numPipes` function in test case to get the opened FIFO
correctly.

Signed-off-by: Li Yuxuan <liyuxuan04@baidu.com>
2019-05-09 20:21:57 +08:00
Michael Crosby
84a24711e8 Add runc.v2 multi-shim
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-02-21 11:09:46 -05: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
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
Phil Estes
85e8221f10
Tests should set up snapshot prior to any use of fs
These tests would have failed if any image had a USER declaration in it,
but because the test image never has, these were never caught. Adding
supplemental GIDs on any image revealed the issue.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-09-14 14:36:01 -04: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
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
4b9b3e8fc9 Add WithAmbientCapabilities opt
Closes #2516

This can be used for non-root users binding to low ports.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-27 17:16:44 -04:00
Michael Crosby
99df1a9e11 Set gid 0 when no group is specified
This change is to match Docker's implementaion of setting gid and groups
to 0 when no gid is specified but an explicit uid is set.

Fixes #2527

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-08-06 15:08:59 -04:00
Michael Crosby
da1b5470cd Runtime v2
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-07-17 10:21:29 -04:00
Derek McGowan
6b9be1bfc3
Fix creation of DirectIO overwriting fifo config
Creating a direct IO should not overwrite the fifo
configuration. The fifo configuration can be updated
before creating the direct io if needed.
This fixes an expected change in behavior for clients
who were calling NewDirectIO previously with terminal
configured on the fifo.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2018-06-01 16:04:22 -07:00
Evan Hazlett
cae94b930d linux -> runtime/linux
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-05-30 09:23:10 -04:00
Evan Hazlett
6b4355d242 add NewDirectIOWithTerminal; add test for pty
Signed-off-by: Evan Hazlett <ejhazlett@gmail.com>
2018-04-25 16:17:10 -04:00
Michael Wan
7fd6d5e2be fix words misspell
Signed-off-by: Michael Wan <zirenwan@gmail.com>
2018-04-23 00:09:42 -04:00
Phil Estes
b769cce904
Fix tests using invalid ID
These tests are using their name as ID, but subtests add a forward slash
connected to the parent test, and slash (/) is an invalid character for
container IDs.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2018-04-04 15:32:02 -04:00
Lantao Liu
45b0045593 Add oci.WithUser helper function.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-03-30 20:06:25 +00: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
Darren Stahl
e6280a7c82 Enable integration tests on Windows using snapshotter and differ
Signed-off-by: Darren Stahl <darst@microsoft.com>
2018-01-23 15:25:17 -08:00
Daniel Nephin
1cd32fa68d Cleanup extra returns in tests
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2018-01-23 14:09:22 -05:00
Daniel Nephin
7d4337e738 Reduce the number of IO constructors
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-11 15:07:09 -05:00
Daniel Nephin
3146019918 Refactor cio.DirectIO
New code duplication
Better re-use from consumers of the cio package

TODO: io_windows.go

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-12-08 14:26:10 -05:00
Daniel Nephin
cdf62f69a1 Fix usage of oci in other packages.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-27 16:16:17 -05:00
Daniel Nephin
f74862a0dd Add structcheck, unused, and varcheck linters.
Warn on unused and dead code

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-21 11:14:37 -05:00
Daniel Nephin
298dabc6c2 Move io.go into cio package
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2017-11-17 17:04:45 -05:00
Jess Valarezo
0961807715 rename runcopts to runctypes
Signed-off-by: Jess Valarezo <valarezo.jessica@gmail.com>
2017-11-10 11:43:51 -08:00
Michael Crosby
b937d230ba Add additional container test for missing methods
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-20 16:25:11 -04:00
Derek McGowan
efcec3674a
Skip user namespace tests in kernels which have it disabled
Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-10-18 11:20:17 -07:00
Kenfe-Mickael Laventure
c807ba8379
Allow setting the uid & gid of the io pipes
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-10-10 13:24:12 -07:00
Michael Crosby
fa9e9bdf46 Fetch current container info before operations
This makes sure the client is always in sync with the server before
performing any type of operations on the container metadata.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-04 15:29:57 -04:00
Michael Crosby
9e85035f15 Add container update method
This adds an update method to the container interface for the client
package.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-03 16:59:52 -04:00
Stephen Day
fe9d6a46d1 Merge pull request #1525 from crosbymichael/shim-hang
Add wait API endpoint for waiting on process exit
2017-09-21 18:21:29 -07:00
Phil Estes
cadee0374b
Revert "Merge pull request #1502 from crosbymichael/test-image"
This reverts commit 558b46f26e, reversing
changes made to 0e616f4d7a.

Signed-off-by: Phil Estes <estesp@linux.vnet.ibm.com>
2017-09-21 15:25:34 -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
ca3f16c510 [tmp] Use amd64 test image
This is a workaround because official images were pushed with multi-arch
support recently and the current Pull code is not accounting for this.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-09-13 13:31:52 -04:00
Kenfe-Mickael Laventure
92772bd471
linux: Ensure all init children are dead when it exits
This ensure that when using the host pid, we don't let process alive,
preventing Wait() to return until they all die.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-09-01 14:50:56 -07:00
Kenfe-Mickael Laventure
ab0cb4e756
linux: Honor RuncOptions if set on container
This also fix the type used for RuncOptions.SystemCgroup, hence introducing
an API break.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-08-31 14:35:05 -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
Michael Crosby
ed6b8fb0aa Add KillOpts for killing all processes
Fixes #1431

This adds KillOpts so that a client can specify when they want to kill a
single process or all the processes inside a container.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-28 13:29:47 -04:00
Lantao Liu
bb9e2bfa43 Add WithUserID which gets uid and gid from image's /etc/passwd.
Signed-off-by: Lantao Liu <lantaol@google.com>
2017-08-25 19:52:48 +00:00
Michael Crosby
b3303b55c1 Add LoadProcess api to Task
Fixes #1374

This adds a `LoadProcess` api to load existing exec'd processes from a
task.  It allows reattaching of IO and waiting on the process.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 16:30:34 -04:00
Michael Crosby
f436f4c828 Add WithUsername spec opt
This option will mount and inspect the /etc/passwd file of an image to
get the uid/gid of a user.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 10:32:16 -04:00
Michael Crosby
c601606f84 Move spec generation to Container Create
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 10:32:16 -04:00
Michael Crosby
fa14f2ef3a Add context and client to SpecOpts
In order to do more advanced spec generation with images, snapshots,
etc, we need to inject the context and client into the spec generation
code.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-24 10:32:16 -04:00
Derek McGowan
4028add553 Merge pull request #1405 from crosbymichael/fifos
Add FifoIO to expose fifos directly to client
2017-08-22 15:52:44 -07:00
Michael Crosby
a8b21da538 Add FifoIO to expose fifos directly to client
This allows clients an easier way to interact with the fifos for a
container without having to use the built in copyIO functions when
opening fifos.

It's nothing that clients could not have already coded but since we use
this type of functionality in the tests it makes sense to add an
implementation here.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-22 14:34:14 -04:00
Michael Crosby
1b470c180e Remove Stdio usage in tests
This causes shims and containers to hang when they use the testing
process's IO.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-08-22 14:02:45 -04:00
Brian Goff
6ab99edb71 Convert ExitStatus to use fn to get details
Instead of requiring callers to read the struct fields to check for an
error, provide the exit results via a function instead which is more
natural.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-08-22 10:48:44 -04:00