Commit Graph

69 Commits

Author SHA1 Message Date
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
James Sturtevant fca511e235 Create v0.6.0 release of containerd-shim and shim-protos
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-10-30 18:05:57 +00:00
Maksym Pavlenko e8ad07d5fd
Update nix crate
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-10-05 11:37:27 -07:00
Bryant Biggs 5e1b7760a1 chore: Standardize Cargo.toml files, enable more workspace dependencies 2023-09-21 13:04:22 -04:00
James Sturtevant fd1b235913 Bump the version for shim protos and containerd-shim
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-08-24 16:40:16 +00:00
jiaxiao zhou deea90ff83
feat(runc-shim): add a version flag
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
2023-08-21 21:45:01 +00:00
Maksym Pavlenko f1d2500c1f Fix docs link
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-08-08 10:07:45 -07:00
Maksym Pavlenko 77a2b87c18 [runc-shim] Move async code to package root
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-08-08 10:07:45 -07:00
Maksym Pavlenko 53cc80da4d Remove sync runc shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-08-08 10:07:45 -07:00
Maksym Pavlenko 27a503a474 [shim] Bump version to 0.4
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-08-02 12:37:35 -07:00
Tianyang Zhang 7817d7ef7b runc-shim: open read side of stdout/stderr fifo to avoid EPIPE
The "read" side of container stdout/stderr fifo has been opened
by containerd and on the other hand "write" side is opened by
container process, which is a little different with golang shim.
If containerd shutdown and closed the read fd, container process
will receive EPIPE when writing to stdout/stderr and then be
killed by SIGPIPE signal. In this commit, the "read" side is
opened again by shim so that at least there is one opened "read"
side all the time.

Signed-off-by: Tianyang Zhang <burning9699@gmail.com>
2023-07-21 17:12:16 +08:00
James Sturtevant 60558b7848 Pass all commandline arguments through
Because the second invocation of the shim doesn't have the containerd pipe passed to it, a shim that wants to communicate over the pipe needs to parse the arguments its own.  This makes it so the library pass all the arguments, which has already parsed the arguments allowing shims to use the containerd address.

Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-07-20 21:43:23 +00:00
Maksym Pavlenko e3c2364587
Merge pull request #138 from Burning1020/ttyfd-close
runc-shim: fix tty fd multi close error
2023-04-23 19:25:59 +02:00
Zhang Tianyang ad90c998ef runc-shim: fix tty fd multi close error
use File::from_raw_fd() to create the tty io file, when the io copy
thread ends, it will drop the file object which will close the fd, but
as we made three file objects from the same fd, it will be closed
three times, if other opened files occupied this fd number, the
second or third drop of the file object may close the fds of other files.

Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2023-04-11 20:16:39 +08:00
Maksym Pavlenko dad95076c4 Move Stdio to runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-16 11:35:03 -07:00
Maksym Pavlenko 2fcf8af423 Move processes to runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-16 11:24:31 -07:00
Maksym Pavlenko 33d37c0c0d Move console to runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-16 11:16:24 -07:00
Maksym Pavlenko 45c0c0d4e0 Move async container and task modules to runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-15 14:26:15 -07:00
Maksym Pavlenko 98754fd771 Update tokio
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-03-13 09:43:52 -07:00
dependabot[bot] 2cf2fd4a92
build(deps): update oci-spec requirement from 0.5.8 to 0.6.0
Updates the requirements on [oci-spec](https://github.com/containers/oci-spec-rs) to permit the latest version.
- [Release notes](https://github.com/containers/oci-spec-rs/releases)
- [Changelog](https://github.com/containers/oci-spec-rs/blob/main/release.md)
- [Commits](https://github.com/containers/oci-spec-rs/compare/v0.5.8...v0.6.0)

---
updated-dependencies:
- dependency-name: oci-spec
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-03-13 01:44:43 +00:00
Zhang Tianyang 65921d09dc Remove unused declaration
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2023-01-16 23:37:45 +08:00
Zhang Tianyang ffa56dbf3b runc-shim: fix leaking thread and fd
The stdin fifo fd should be closed when containerd
calls close io, otherwise, runc-shim would hold
this fd and the copy console thread forever.

Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2023-01-16 23:37:44 +08:00
Zhang Tianyang 62798a0745 runc-shim: fix leaking files for exec process
A pid file under bundle path will be created after
the exec process created, so it should also be deleted
before process deleted.

Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2023-01-08 10:57:31 +08:00
Maksym Pavlenko 80c6d9edf0
Merge pull request #107 from containerd/dependabot/cargo/nix-0.26
build(deps): update nix requirement from 0.25 to 0.26
2023-01-07 11:49:13 -08:00
Maksym Pavlenko 07a98518d4
Merge pull request #109 from utam0k/rust-1.66
Update Rust to 1.66 and fix some lints
2023-01-07 11:48:17 -08:00
Zhang Tianyang 3822d608e9 runc-shim: retrieve OCI runtime error if OCI command failed
If an error is encountered when running the OCI command, shim process
should walk the OCI command logfile and retrieve the last error.

Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2023-01-06 21:21:13 +08:00
utam0k fe1b3b0f73
Fix the warns from clippy lints
Signed-off-by: utam0k <k0ma@utam0k.jp>
2022-12-29 21:21:55 +09:00
dependabot[bot] 7558fe4c49
build(deps): update nix requirement from 0.25 to 0.26
Updates the requirements on [nix](https://github.com/nix-rust/nix) to permit the latest version.
- [Release notes](https://github.com/nix-rust/nix/releases)
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.25.0...v0.26.1)

---
updated-dependencies:
- dependency-name: nix
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-11-29 21:09:10 +00:00
Maksym Pavlenko 80e7945674 Use workspace inheritance to describe crates
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-11-04 14:34:49 -07:00
Maksym Pavlenko 55aa661b4d Update Rust to 1.65
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-11-04 14:34:49 -07:00
Zhang Tianyang 6203977cbf runc-shim: Update README with performance test
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-10-16 16:41:01 +08:00
Maksym Pavlenko 5ddd3e37bb Run fmt
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-29 11:55:31 -07:00
Maksym Pavlenko 26ae44e5c3 Update ttrpc dependencies and switch to Protobuf 3
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-23 08:54:45 -07:00
Maksym Pavlenko 51a27ee268 Update nix dependency (fix #93)
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-21 11:32:39 -07:00
Maksym Pavlenko d5b72ce007
Merge pull request #80 from yuqitao/support-more-overlayfs-layers
synchronous: supprt more overlayfs layers
2022-05-30 13:09:13 -07:00
yuqitao fdd5d7c7d1 synchronous: supprt more overlayfs layers
Signed-off-by: yuqitao <yuqitao1024@qq.com>
2022-05-27 15:27:08 +08:00
Zhang Tianyang be8d9d479e runc-shim: Update console copy
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-05-17 22:57:58 +08:00
Maksym Pavlenko cfe09e2227 Update nix dependency
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-05-05 14:55:34 -07:00
Maksym Pavlenko 83dec597de Remove docs.rs badge from runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-05-03 13:59:15 -07:00
Feng Shaobao df87a63c8e add exit-signal for container
to exit io copy tasks when deleting container

Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-22 14:47:41 +08:00
Feng Shaobao 93cc73cf9b upgrade rust toolchain version to 1.59
the dependent path-dedot crate updated to rust edition 2021, we have to
upgrade out toolchain version to compile

Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-18 17:26:24 +08:00
Feng Shaobao 63a4e5c891 fix tokio not exit and signal handle exit issue
make all integartion tests passed

Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-18 12:39:36 +08:00
Feng Shaobao b48cc3d993 add update/stats/pids for async
Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-16 10:07:31 +08:00
Maksym Pavlenko b3ac82d9cc Fix badges
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-03-10 16:18:47 -08:00
Maksym Pavlenko 21e298aef3 Bump versions
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-03-10 15:58:28 -08:00
Maksym Pavlenko 70c7f85b45 Update runc shim README
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-03-10 15:49:59 -08:00
Maksym Pavlenko 80e6588c53 Fix runtime name for integration tests
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-03-10 15:24:10 -08:00
Maksym Pavlenko d7ceb45072 [runc-shim] Implement Connect
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-03-10 09:42:10 -08:00
Zhang Tianyang 2fd561e290 runc-shim: support remote publisher and extra some common methods
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-10 17:23:50 +08:00
Zhang Tianyang 3ff1fc0a6d bugfix: return a tmp dir when 'XDG_RUNTIME_DIR' was not set
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-09 23:46:47 +08:00