Commit Graph

479 Commits

Author SHA1 Message Date
Michael Crosby
218db0f9af
Merge pull request #5835 from dmcgowan/plugin-events-cleanup
Move plugin context events into separate plugin
2021-08-07 21:47:11 -04:00
Derek McGowan
0a0621bb47
Move plugin context events into separate plugin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-08-05 22:59:20 -07:00
Derek McGowan
6f027e38a8
Remove redundant build tags
Remove build tags which are already implied by the name of the file.
Ensures build tags are used consistently

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-08-05 22:27:46 -07:00
Maksym Pavlenko
fcd9c41991
Merge pull request #5746 from lifupan/main
runtime: fix the issue of create new socket with abstract address
2021-07-29 15:40:28 -07:00
fupan.lfp
4ab3e7a53a runtime: fix the issue of create new socket with abstract address
For the abstract socket adress there's no need to chmod
the address's file, cause the file didn't exist actually.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2021-07-27 23:24:26 +08:00
jerryzhuang
7a10fd4fcc respect context timeout in shim binary call
Signed-off-by: jerryzhuang <zhuangqhc@gmail.com>
2021-07-27 22:28:05 +08:00
Maksym Pavlenko
559f9a5b90
Merge pull request #5744 from mxpv/metrics
Add runtime label to metrics
2021-07-23 12:24:32 -07:00
Maksym Pavlenko
efa8ab7158 Add runtime label to metrics
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-07-23 10:04:46 -07:00
yylt
0d45ac14e9 interface about shim build check
Signed-off-by: Yang Yang <yang8518296@163.com>
2021-07-22 09:03:12 +08:00
Sebastiaan van Stijn
dbef1d56d7
runtime: runc v2: remove redundant validation
cgroupsv2.LoadManager() already performs VerifyGroupPath(), and returns
an error if the path is invalid, so this check is redundant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-07-14 23:24:31 +02:00
Brian Goff
0a8802df67 Allow WithServices to use custom implementations
Before this change, for several of the services that `WithServices`
handles, only the grpc client is supported.
Now, for instance, one can use an `images.Store` directly instead of
only an `imagesapi.StoreSlient`.

Some of the methods have been renamed to satisfy the difference between
using a grpc `<Foo>Client` vs the main interface.

I did not see a good candidate for TaskService so have left that mostly
unchanged.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-07-09 23:30:40 +00:00
Maksym Pavlenko
f0a32c66da
Merge pull request #5617 from fidencio/wip/shimv2-debug
runtime,v2: Enable debug when containerd is on debug+ log level
2021-06-17 10:08:51 -07:00
Fabiano Fidêncio
87a2e0b2a2 runtime,v2: Enable debug when containerd is on debug+ log level
Currently the shimv2 debug is only enabled when containerd is,
specifically, on debug mode.  However, it should be enabled whenever the
CRI runtime is on debug *or any other lower* mode, as in trace mode.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-06-17 12:43:02 +02:00
Shiming Zhang
7966a6652a Cleanup code
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-04-19 16:59:45 +08:00
Maksym Pavlenko
69a30ad581
Merge pull request #5378 from Iceber/check-flag
runtime/shim: check the namespace flag first
2021-04-18 09:10:46 -07:00
Phil Estes
1e5cb4edcb
Merge pull request #5368 from mxpv/runtime_cleanup
Runtime cleanup
2021-04-16 14:50:15 -04:00
Iceber Gu
34780d67ad runtime/shim: check the namespace flag first
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-04-16 17:32:21 +08:00
Samuel Karp
b431fe4fc0
freebsd: don't run shim delete in deleted dir
fork/exec can fail and log a warning like this in containerd's log:
failed to clean up after shim disconnected error=": fork/exec /usr/local/bin/containerd-shim-[my-shim]: no such file or directory" id=test namespace=default

Passing the bundle path on the command line allows the shim delete
command to run successfully.

Signed-off-by: Samuel Karp <me@samuelkarp.com>
2021-04-15 18:09:29 -07:00
Maksym Pavlenko
b83d04f910 Add variable names to runtime's interface definitions
To ease code readability

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-04-15 12:03:13 -07:00
Maksym Pavlenko
993b863993 Add shim start opts
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-04-15 11:55:24 -07:00
Shiming Zhang
fcf3b275fc Add lock for ListPids
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-04-15 13:55:03 +08:00
Maksym Pavlenko
0ad8c0a169 Decouple shim start from task creation
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-04-11 18:51:27 -07:00
Sebastiaan van Stijn
7bb73da6b9
runtime/v2/shim: remove unused SetScore() and remove sys.OOMScoreMaxKillable
The shim.SetScore() utility was no longer used since 7dfc605fc6.

Checking for uses outside of this repository, I found only one external use of
this in gVisor; a9441aea27/pkg/shim/service.go (L262-L264)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-04-07 19:16:58 +02:00
Sebastiaan van Stijn
91e7d21ee8
sys: add AdjustOOMScore() utility
Handle the limits in this function so that consumers don't have to
perform the boundary checks.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-04-07 19:16:56 +02:00
Sebastiaan van Stijn
708299ca40
Move RunningInUserNS() to its own package
This allows using the utility without bringing whole of "sys" with it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-03-23 11:29:53 +01:00
Maksym Pavlenko
56f17a0856
Merge pull request #5148 from wzshiming/fix/defer-cleanup
runtime/v2: Fix defer cleanup for TaskManager.Create
2021-03-20 13:24:42 -07:00
Shiming Zhang
30e1e66e5c runtime/v2: Fix defer cleanup
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-03-20 18:40:36 +08:00
Michael Crosby
e0c94bb269
Merge pull request #4708 from kzys/enable-criu
Re-enable CRIU tests by not using overlayfs snapshotter
2021-03-19 14:23:05 -04:00
Shiming Zhang
fe787efa2b Fix error log when kill shim
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-03-19 19:03:47 +08:00
Wei Fu
9fdc96c095 runtime/v2: add comment for checkCopyShimLogError
After #4906, containerd opens fifo in read/write mode in linux platform
The original comment doesn't correct and is removed by #5174.

```
// original comment

// When using a multi-container shim, the fifo of the 2nd to Nth
// container will not be opened when the ctx is done. This will
// cause an ErrReadClosed that can be ignored.
```

However, we should add comment for checkCopyShimLogError to mention why
we call checkCopyShimLogError. The checkCopyShimLogError, it is to prevent
the flood of expected error messages after task die and the expected
errors depend on platform.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2021-03-18 13:02:28 +08:00
Phil Estes
a0cc9b432d
Merge pull request #5195 from fuweid/fix-5173
runtime/v2/runc: fix leaking socket path
2021-03-17 09:33:41 -04:00
Kazuyoshi Kato
b520428b5a Fix CRIU
- process.Init#io could be nil
- Make sure CreateTaskRequest#Options is not empty before unmarshaling

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
2021-03-16 16:46:45 -07:00
Iceber Gu
5e484c9613
runtime/v2/runc: fix the defer cleanup of the NewContainer
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2021-03-16 11:41:17 +08:00
Phil Estes
a1138182d5
Merge pull request #5180 from dmcgowan/lint-enforce-comments
Fix exported comments enforcer in CI
2021-03-15 10:50:06 -04:00
Wei Fu
d895118c7c runtime/v2/runc: fix leaking socket path
When runC shimv2 starts, the StartShim interface will re-exec itself as
long-running process, which will read the `address` during initializing.

```happycase
Process

containerd-shim-runc-v1/v2 start             containerd-shim-runc-v1/v2

	initializing socket

	reexec containerd-shim-runc-v1/v2

	write address into file

						initializing

							read address

	write back to containerd daemon

						serving

						...

						remove address in Shutdown call
```

However, there is no synchronization after reexec. Then the data race is
like:

```leaking-case
Process

containerd-shim-runc-v1/v2 start             containerd-shim-runc-v1/v2

	initializing socket

	reexec containerd-shim-runc-v1/v2

						initializing

							read address

	write address into file

	write back to containerd daemon

						serving

						...

						fail to remove address
						because of empty address
```

The `address` should be writen into file first before reexec.

And if shutdown the whole service before cleanup temporary
resource (like socket file), the Shutdown caller will receive `ttrpc: closed`
sometime, which depends on go runtime scheduler. Then it also causes leaking
socket files.

Since the shimV2-Delete binary API must be called to cleanup shim temporary
resource and shimV2-runC-v1 doesn't support grouping multi containers in one,
it is safe to remove the socket file in the binary call for shimV2-runC-v1.
But for the shimV2-runC-v2 shim, we still cleanup socket in Shutdown.
Hopefully we can find a way to cleanup socket in shimV2-Delete binary
call.

Fix: #5173

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2021-03-15 18:32:00 +08:00
Wei Fu
eabd9b98b6 runtime: ignore file-already-closed error if dead shim
fix: #5130

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2021-03-15 12:18:26 +08:00
Derek McGowan
35eeb24a17
Fix exported comments enforcer in CI
Add comments where missing and fix incorrect comments

Signed-off-by: Derek McGowan <derek@mcg.dev>
2021-03-12 08:47:05 -08:00
Kevin Parsons
c9afc4250a Fix error checking when resolving shim binary path
Previously a typo was introduced that caused the wrong error to be
checked against when calling exec.LookPath. This had the effect that
containerd would never locate the shim binary if it was in the same
directory as containerd's binary, but not in PATH.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
2021-03-08 16:24:19 -08:00
Maksym Pavlenko
134f7a7370
Merge pull request #5007 from fidencio/wip/allow-shimv2-to-also-be-loaded-from-an-arbitrary-path
v2, util: Take the full binary path when starting the shimv2 process
2021-03-01 14:52:27 -08:00
Derek McGowan
10bbd1a462
Merge pull request #5051 from wzshiming/fix/missing-close
Fix missing close
2021-02-26 14:59:43 -08:00
Derek McGowan
9884730e5c
Merge pull request #5069 from AkihiroSuda/restart-fast
restart: skip Sleep() for the first iteration of the reconcilation
2021-02-25 16:37:53 -08:00
Akihiro Suda
6ab6eaa790
restart: skip Sleep() for the first iteration of the reconcilation
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-25 13:30:38 +09:00
Akihiro Suda
b23dc1131e
restart: parallelize reconcile()
The only shared variable `m.client` is thread-safe, so we can safely
parallelize the loops.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2021-02-25 13:30:00 +09:00
Shiming Zhang
05ef2fe2fb Fix missing close
Signed-off-by: Shiming Zhang <wzshiming@foxmail.com>
2021-02-18 13:21:42 +08:00
Fabiano Fidêncio
d80dbdae68 v2, util: Take the full binary path when starting the shimv2 process
The current code simply ignores the full binary path when starting the
shimv2 process, and instead fallbacks to a binary in the path, and this
is problematic (and confusing) for those using CRI-O, which has this
bits vendored.

The reason it's problematic with CRI-O is because the user can simply
set the full binary path and, instead of having that executed, CRI-O
will simply fail to create the container unless that binary is part of
the path, which may not be case in a few different scenarios (testing
being the most common one).

Fixes: #5006

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
2021-02-05 13:35:22 +01:00
IceberGu
b458583b76
runtime: fix shutdown runc v2 service
Signed-off-by: IceberGu <wei.cai-nat@daocloud.io>
2021-02-02 15:36:49 +08:00
Phil Estes
49c5c14879
Merge pull request #4906 from payall4u/bugfix/fix-open-shim-fifo
bugfix: change the flag of open log fifo to avoid containerd hang on syscall open
2021-02-01 09:01:38 -05:00
payall4u
957fa3379d change flag from RDONLY to RDWR and close the fifo correct
Signed-off-by: Zhiyu Li <payall4u@qq.com>
2021-01-31 19:00:42 +08:00
Aditi Sharma
1423e9199d Update gogo/protobuf to v1.3.2
bump version 1.3.2 for gogo/protobuf due to CVE-2021-3121 discovered
in gogo/protobuf version 1.3.1, CVE has been fixed in 1.3.2

Signed-off-by: Aditi Sharma <adi.sky17@gmail.com>
2021-01-28 12:57:50 +00:00
Maksim An
ddb5e1651a Enhance logging driver and ctr tasks to support windows
Signed-off-by: Maksim An <maksiman@microsoft.com>
2021-01-21 12:17:32 -08:00