Commit Graph

672 Commits

Author SHA1 Message Date
Akihiro Suda
9fcc3beb59
Merge pull request #9230 from mxpv/exit
Exit shim when shutdown manager is done
2023-10-13 14:51:20 +09:00
Derek McGowan
7b2a918213
Generalize the plugin package
Remove containerd specific parts of the plugin package to prepare its
move out of the main repository. Separate the plugin registration
singleton into a separate package.

Separating out the plugin package and registration makes it easier to
implement external plugins without creating a dependency loop.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-12 21:22:32 -07:00
Derek McGowan
a80606bc2d
Move plugin type definitions to containerd plugins package
The plugins packages defines the plugins used by containerd.
Move all the types and properties to this package.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-12 20:52:56 -07:00
Maksym Pavlenko
2486c12987 Exit shim when shutdown manager is done
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-12 19:53:05 -07:00
Chen Yiyang
68dd47ef70 containerd-shim-runc-v2: avoid potential deadlock in create handler
After pr #8617, create handler of containerd-shim-runc-v2 will
call handleStarted() to record the init process and handle its exit.
Init process wouldn't quit so early in normal circumstances. But if
this screnario occurs, handleStarted() will call
handleProcessExit(), which will cause deadlock because create() had
acquired s.mu, and handleProcessExit() will try to lock it again.

So, I added a parameter muLocked to handleStarted to indicate whether
or not s.mu is currently locked, and thus deciding whether or not to
lock it when calling handleProcessExit.

Fix: #9103
Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2023-10-02 17:44:41 +00:00
Chen Yiyang
6604ff6c55 containerd-shim-runc-v2: remove unnecessary s.getContainer()
Previous code has already called `getContainer()`, just pass it into
`s.getContainerPids` to reduce unnecessary lock and map lookup.

Signed-off-by: Chen Yiyang <cyyzero@qq.com>
2023-10-02 17:44:41 +00:00
Derek McGowan
508aa3a1ef
Move to use github.com/containerd/log
Add github.com/containerd/log to go.mod

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-22 07:53:23 -07:00
Jin Dong
fc45365fa1 Remove most logrus
Signed-off-by: Jin Dong <jin.dong@databricks.com>
2023-08-26 14:31:53 -04:00
Jin Dong
cd8c8ae4bc Remove hashicorp/go-multierror
Signed-off-by: Jin Dong <jin.dong@databricks.com>
2023-08-20 17:59:45 -07:00
Wei Fu
601699a184 integration: add ShouldRetryShutdown case based on #7496
Since the moby/moby can't handle duplicate exit event well, it's hard
for containerd to retry shutdown if there is error, like context
canceled.

In order to prevent from regression like #4769, I add skipped
integration case as TODO item and we should rethink about how to handle
the task/shim lifecycle.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-08-11 17:43:51 +08:00
Maksym Pavlenko
8dcc06d14a
Merge pull request #8747 from Iceber/shim_ttrpc_service
shim: change ttrpcService and ttrpcServerOptioner to exported interfaces
2023-07-18 17:12:22 -07:00
Akihiro Suda
98f27e1d9c
Revert "Add support for mounts on Darwin"
This reverts commit 2799b28e61.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-07-19 00:22:20 +09:00
Marat Radchenko
2799b28e61 Add support for mounts on Darwin
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-07-17 23:27:04 +03:00
Phil Estes
34b1653e95
Merge pull request #8780 from slonopotamus/uncopypaste-read-spec
Uncopypaste parsing of OCI Bundle spec file
2023-07-11 09:53:00 -04:00
Marat Radchenko
9e34b8b441 Uncopypaste parsing of OCI Bundle spec file
Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-07-11 14:41:15 +03:00
Phil Estes
466d884518
Merge pull request #8777 from yankay/fix-restart-with-tty
Fix the automatically restart issue when using LogURI and Terminal together
2023-07-06 10:51:11 -04:00
Kay Yan
073de93086 Fix the auto restart fail when using LogURI and TTY together
Signed-off-by: Kay Yan <kay.yan@daocloud.io>
2023-07-06 04:58:56 +00:00
Iceber Gu
00e5ae2118 shim: change ttrpcService and ttrpcServerOptioner to exported interfaces
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-07-06 00:36:43 +08:00
Marat Radchenko
51a1e7f0b2 Fix example shim to actually use its task service
In commit 4b35c3829d, example shim erroneously started to depend on runc, fix that back.

Also, build example shim on all supported platforms to prevent such situations in the future.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-07-03 20:40:20 +03:00
Marat Radchenko
0607e73263 Move GetTopic function out of runc shim
Every shim implementation needs to select a correct publisher topic when posting events, so move it out of Linux-only runc code to the place where other shims can also use it

Otherwise, shims have to copy-paste this code. For example, see runj: 8158e558a3/containerd/shim.go (L144-L172)

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2023-06-30 10:29:21 +03:00
Jin Dong
0a92661e69 Add a platform.ParseAll helper
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-06-26 20:34:37 +00:00
Kazuyoshi Kato
ded713010c
Merge pull request #8617 from corhere/reduce-exec-lock-contention
runtime/v2/runc: handle early exits w/o big locks
2023-06-14 15:55:07 -07:00
Derek McGowan
0ae64ebd4e
Merge pull request #8680 from dcantah/sb-metrics
Sandbox: Add SandboxMetrics rpc
2023-06-14 18:11:18 +00:00
Jin Dong
9e09bfb590 Use RWMutex in NSMap and reduce lock area
Signed-off-by: Jin Dong <djdongjin95@gmail.com>
2023-06-14 17:50:54 +00:00
Danny Canter
d56722ef2a Sandbox: Add SandboxMetrics rpc
To gather metrics/stats about a specific sandbox instance, it'd be nice to
have a dedicated rpc for this. Due to the same "what kind of stats are going
to be returned" dilemma exists for sandboxes as well, I've re-used the metrics
type we have as the data field is just an `any`, leaving the metrics returned
entirely up to the shim author. For CRI usecases this will just be cgroup and
windows stats as that's all that's supported right now.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-06-12 03:30:48 -07:00
Derek McGowan
98b7dfb870
Merge pull request #8673 from thaJeztah/no_any
avoid "any" as variable name
2023-06-10 20:44:30 -07:00
Sebastiaan van Stijn
4bb709c018
avoid "any" as variable name
Avoid shadowing / confusion with Go's "any" built-in type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-10 13:49:06 +02:00
Sebastiaan van Stijn
577696f608
replace some basic uses of fmt.Sprintf()
Really tiny gains here, and doesn't significantly impact readability:

    BenchmarkSprintf
    BenchmarkSprintf-10    11528700     91.59 ns/op   32 B/op  1 allocs/op
    BenchmarkConcat
    BenchmarkConcat-10    100000000     11.76 ns/op    0 B/op  0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-10 13:24:43 +02:00
Cory Snider
5cd6210ad0 runtime/v2/runc: handle early exits w/o big locks
eventSendMu is causing severe lock contention when multiple processes
start and exit concurrently. Replace it with a different scheme for
maintaining causality w.r.t. start and exit events for a process which
does not rely on big locks for synchronization.

Keep track of all processes for which a Task(Exec)Start event has been
published and have not yet exited in a map, keyed by their PID.
Processing exits then is as simple as looking up which process
corresponds to the PID. If there are no started processes known with
that PID, the PID must either belong to a process which was started by
s.Start() and before the s.Start() call has added the process to the map
of running processes, or a reparented process which we don't care about.
Handle the former case by having each s.Start() call subscribe to exit
events before starting the process. It checks if the PID has exited in
the time between it starting the process and publishing the TaskStart
event, handling the exit if it has. Exit events for reparented processes
received when no s.Start() calls are in flight are immediately
discarded, and events received during an s.Start() call are discarded
when the s.Start() call returns.

Co-authored-by: Laura Brehm <laurabrehm@hey.com>
Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-06-09 16:53:43 -04:00
Samuel Karp
c409c631ca
shim: WritePidFile & WriteAddress use atomicfile
Signed-off-by: Samuel Karp <samuelkarp@google.com>
2023-06-02 16:56:34 -07:00
Akihiro Suda
2eeb4b6238
Merge pull request #8373 from Iceber/shim_run
runtime/shim: rename RunManager to Run and remove `runc/v2/services` package
2023-05-12 00:46:46 +09:00
Danny Canter
df65e321ee Simplify closing bundle dir fd
Follow-up to #8489. We don't need to call Close in the err and success
cases, we can just do it after Readdirnames returns.

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-05-09 17:22:04 -07:00
Danny Canter
f5211ee3fc Change to Readdirnames for some cases
There was a couple uses of Readdir/ReadDir here where the only thing the return
value was used for was the Name of the entry. This is exactly what Readdirnames
returns, so we can avoid the overhead of making/returning a bunch of interfaces
and calling lstat everytime in the case of Readdir(-1).

https://cs.opensource.google/go/go/+/refs/tags/go1.20.4:src/os/dir_unix.go;l=114-137

Signed-off-by: Danny Canter <danny@dcantah.dev>
2023-05-08 00:41:13 -07:00
Maksym Pavlenko
6f34da5f80 Cleanup logrus imports
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-05 11:54:14 -07:00
Derek McGowan
7d7aac7dae
Merge pull request #8393 from Iceber/fix_checkpoint_options
runtime/shim: fix the nil checkpoint options
2023-04-24 21:22:39 -07:00
Maksym Pavlenko
370be0c18f Move logrus setup code to log package
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-04-24 10:14:13 -07:00
Iceber Gu
18d7e84f9b runtime/shim: fix the nil checkpoint options
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-04-14 22:32:50 +08:00
Iceber Gu
4b35c3829d update shim example
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-04-14 11:42:21 +08:00
Iceber Gu
71ababe30a runtime/shim: remove runc/v2/services
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-04-14 11:42:21 +08:00
Iceber Gu
b71f4b7518 runtime/shim: rename RunManager to Run
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-04-14 11:42:21 +08:00
Iceber Gu
f7b8b11812 update the version of the runc shim in the readme and examples
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-04-11 16:02:06 +08:00
Iceber Gu
23d288a809 Remove the CriuPath field from runc's options
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-03-16 17:12:51 +08:00
Fu Wei
e735405c15
Merge pull request #7951 from Iceber/fix_restart_monitor 2023-03-16 08:58:20 +08:00
Maksym Pavlenko
07c2ae12e1 Remove v1 runctypes
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-15 09:18:16 -07:00
Maksym Pavlenko
ef516a1507 Remove runtime v1
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-15 09:18:14 -07:00
Akihiro Suda
35a103d321
Remove "containerd.io/restart.logpath" label (deprecated since v1.5)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-03-15 09:00:11 +09:00
Iceber Gu
e0d9b96631 Fix restarting the paused containers
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
2023-03-14 17:42:36 +08:00
Hsing-Yu (David) Chen
d602c9aec7 docs: fix typo of shim.RunManager's function comment
Signed-off-by: Hsing-Yu (David) Chen <davidhsingyuchen@gmail.com>
2023-03-06 16:29:15 -08:00
Derek McGowan
57fb2d30f0
Add max shim version environment variable
Adds environment variable to shim start command

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-03-01 11:20:49 -08:00
Derek McGowan
dba6f9db18
Add version to shim protocol
Document environment variables and test shim start response parsing.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-02-27 22:58:47 -08:00