Commit Graph

30 Commits

Author SHA1 Message Date
jokemanfire a345bac309 OpenOptions in blocking mod is a time-consuming operation.
1.Prevent it from blocking a tokio thread. Change sync to async.
2.Add pipe unit test which I found error in Pipe new.

Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
2025-01-09 02:57:43 +00:00
jiaxiao zhou 7efe8d8390 runc: split Pipe, Io, and PipedIo to async and sync modules
Signed-off-by: jiaxiao zhou <duibao55328@gmail.com>
2024-12-03 17:58:52 +00:00
zhang yu 10307750 3a7b9ce173 feat: set THP_DISABLE=true in shim, and restore it before starting runc
If /sys/kernel/mm/transparent_hugepage/enabled=always, the shim process
will use huge pages, which will consume a lot of memory.

Just like this:
ps -efo pid,rss,comm | grep shim
    PID   RSS COMMAND
   2614  7464 containerd-shim

I don't think shim needs to use huge pages, and if we turn off the huge
pages option, we can save a lot of memory resources.

After we set THP_DISABLE=true:
ps -efo pid,comm,rss
    PID COMMAND           RSS
1629841 containerd-shim  5648

containerd
    |
    |--shim1   --start
        |
        |--shim2    (this shim will on host)
            |
            |--runc create (when containerd send create request by ttrpc)
                |
                |--runc init (this is the pid 1 in container)

    we should set thp_disabled=1 in shim1 --start, because if we set this
    in shim 2, the huge page has been setted while func main() running,
    we set thp_disabled cannot change the setted huge pages.
    So We need to set thp_disabled=1 in shim1 so that shim2 inherits the
    settings of the parent process shim1, and shim2 has closed the
    hugepage when it starts.

    For runc processes, we need to set thp_disabled='before' in shim2 after
    fork() and before execve(). So we use cmd.pre_exec to do this.
2024-02-20 02:43:24 +00:00
Andrew Baxter 9ac1f26516 `Runc::state()` returns wrong type with async feature
It's a very small change so I figured it's simpler to open a PR than an issue first.

The sync `state` method returns `Container` but for async returns `Vec<usize>`, and I couldn't locate an explanation for why these might be different so I assume it's a mistake.  From a user perspective too I want Container rather than a usize vec.

Signed-off-by: Andrew Baxter <i@isandrew.com>
2023-12-25 17:56:09 +00:00
Maksym Pavlenko e9910f30b8 Simplify doc management
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-03 20:41:38 -07:00
jiaxiao zhou 5c55e352de
cargo clippy
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
2023-08-02 02:43:05 +00:00
Maksym Pavlenko 5ddd3e37bb Run fmt
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-29 11:55:31 -07:00
Feng Shaobao 1e1a6a8d97 change Executor to Spawner and make it trait object 2022-03-08 15:39:43 +08:00
Feng Shaobao 777fe2ad23 support async feature for runc shim
Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-07 16:38:19 +08:00
Zhang Tianyang a06ec3df2d runc-shim: implement pids task
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-01 19:04:12 +08:00
Zhang Tianyang dd90a9180f runc: Set piped stdio as default
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-28 21:36:03 +08:00
Zhang Tianyang cdb93f2358 runc-shim: implement update task
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-27 18:12:33 +08:00
Liu Jiang 33e940b9c8 runc: refine the way to setup Io
Refine the way to setup Io drivers for runC.

The capability to capture output/error messages from runc depends on
the Io driver used. Some add two more Io drivers: InheritedStdIo and
PipedStdIo. Also document whether the Io driver supports capturing
output/error messages.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-24 18:47:08 +08:00
Liu Jiang 41c2083eac runc: simple syntax improvments
Simple syntax only improvements.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-24 18:46:38 +08:00
Liu Jiang fc50adf2dc runc: implement sync version of ps() and stats()
Implement sync version of ps() and stats().

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-24 18:46:37 +08:00
Liu Jiang 95cda30597 runc: fix two bugs in preparing command line arguments
1) it should use "runc resume" instead of "runc pause" for resume()
2) the order of arguments to run() is wrong, other options may appear
   between "--bundle" and "bundle_id".

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-24 18:46:36 +08:00
Liu Jiang 6c6fa1ac09 runc: make async version of Runc::create() to return Response
Make async version of Runc::create() to return `Response` instead of
`()`, to keep symmetry with sync version.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-24 18:46:35 +08:00
Liu Jiang f5f18ec52b runc: avoid unwrap() in runc::launch()
In runc::launch(), it does
        let stdout = String::from_utf8(result.stdout).unwrap();
        let stderr = String::from_utf8(result.stderr).unwrap();

This is risk of DoS attack because the content result.stdout/sterr may
contain contents generated by the container, so it may contain malicious
non-UTF8 characters.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-24 18:46:33 +08:00
Zhang Tianyang b08e4090ea runc: fix bug that exec command leaks files
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-23 21:16:16 +08:00
Zhang Tianyang 117263d9be Move Io and Console
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-17 23:06:35 +08:00
Zhang Tianyang 0a33f3e867 Runc shim implementation
Implement shim cli commands and some basic task APIs to run a runc container

Co-authored-by: Feng Shaobao fshb1988@gmail.com
Co-authored-by: Zhang Tianyang burning9699@gmail.com
Co-authored-by: Yu Qitao yuqitao1024@qq.com

Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-17 23:02:14 +08:00
Liu Jiang 8c2a61a807 runc: introduce helper function execute()
Introduce helper function monitor.rs::execute() to avoid duplicated
code, and also correctly setup stdout/stderr for ProcessMonitor.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 11:15:33 +08:00
Liu Jiang 4b3efbc875 runc: move runc commandline constants into options.rs
Move runc commandline related constants into options.rs, so options.rs
hosts all commandline parsing related code. And util.rs only hosts
utilities.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-14 16:57:04 +08:00
Liu Jiang cfdbb4dbcd runc: rename ConfigBuilder as GlobalOpts and moves it into options.rs
Rename ConfigBuilder as GlobalOpts and moves it into options.rs,
to follow the runc man pages.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-14 16:48:08 +08:00
Maksym Pavlenko ab45a92d6d Add async feature
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-13 14:23:16 -08:00
Maksym Pavlenko 64306e3e4d Remove target checks
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-11 11:41:12 -08:00
Maksym Pavlenko 14dceb116f Remove duplicated config builder
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-11 11:18:16 -08:00
Akihiro Suda 522e26fab8
crates/runc/src/lib.rs: fix compilation on non-Linux
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-02-06 18:32:35 +09:00
Yuna Tomida eddd107601
remove unnecessary 'forget'
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-04 02:27:54 +00:00
Yuna Tomida 8f3e556a1b
renamed crate and applied recommended changes
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-04 00:39:39 +00:00