Commit Graph

392 Commits

Author SHA1 Message Date
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 ddf49a9a52 Fix dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-07-11 10:47:24 -07:00
Jorge Prendes 4da0055413
Add missing condition to stop reaping child procs
Signed-off-by: Jorge Prendes <jorge.prendes@gmail.com>
2023-07-05 16:54:42 +01:00
James Sturtevant bdd17eb2a5
Update to use latest ttrpc library
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-22 12:14:29 -07:00
James Sturtevant 38545a7d56
Use inline platform branches
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-22 10:06:40 -07:00
James Sturtevant b97955944c
Clean up signal processing
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-22 10:06:39 -07:00
James Sturtevant fa4a0045e6
Make one function that works for both platforms
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-22 10:06:39 -07:00
James Sturtevant bceaf4aca3
Windows support for the synchronous shim
Signed-off-by: James Sturtevant <jsturtevant@gmail.com>
Signed-off-by: James Sturtevant <jstur@microsoft.com>
2023-06-22 10:06:39 -07:00
Maksym Pavlenko 35a97f17d5
Merge pull request #145 from wllenyj/sandbox
shim: add Sandbox API support
2023-05-16 13:25:35 -07:00
wanglei01 79d5d5afcf shim: add sandbox module
Added sandbox feature to enable sandbox support.

Signed-off-by: wanglei01 <wllenyj@linux.alibaba.com>
2023-05-17 01:41:23 +08:00
wanglei01 e8d11318e1 shim: add Sandbox API support
Added sandbox proto file.

Signed-off-by: wanglei01 <wllenyj@linux.alibaba.com>
2023-05-17 01:41:17 +08:00
Maksym Pavlenko 4f66aaffe7 Update tonic dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-05-15 10:19:35 -07:00
Maksym Pavlenko f23659c392 [client] Bump version to 0.3.0 2023-05-05 10:44:55 -07:00
Chris Rice 660d4f886b add submodule for sandbox 2023-05-05 11:05:49 -06:00
Chris Rice c9fe55ef51 add containerd.services.sandbox.v1 2023-05-05 08:40:48 -06:00
Maksym Pavlenko c54a467f16
Merge pull request #137 from simon-mo/list-request-impl
Implement the input parameters for snapshotter::list
2023-04-23 19:28:03 +02: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
Simon Mo 9bf2db776b Implement `list` for snapshotter request
This PR follows up on @wedsonaf's #126 and pass the filters through the list input.
Note that this is not backward compatible but this is a step closer to the protocol
conformance.
2023-04-21 18:39:32 +00:00
Maksym Pavlenko 16e9695e80 Bump snapshots crate
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2023-04-14 12:26:18 -07:00
Tim Zhang dc856c67bf containerd-shim: bump containerd-shim-protos to v0.3.0
Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-14 16:02:48 +08:00
Tim Zhang 18609f2762 release containerd-shim-protos: v0.3.0
Bump containerd-shim-protos from 0.2.0 to 0.3.0 to
include changes made in #95.

Because the update in #95 is not compatible we need a major
version update.

Signed-off-by: Tim Zhang <tim@hyper.sh>
2023-04-14 15:43:13 +08: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 115029bb63
Merge pull request #127 from mxpv/refactor
Make shim / runc-shim APIs more consistent
2023-03-16 11:01:47 -07:00
Maksym Pavlenko b284957f88
Merge pull request #130 from wedsonaf/kind-eq
Derive `PartialEq` for `Kind`
2023-03-16 04:39:15 +00:00
Wedson Almeida Filho 68c227a774 Derive `PartialEq` for `Kind`
This allows us to use the `==` and `!=` operators to compare instances
of `Kind`, which is useful when we require that a snapshot be of some
specific kind (e.g., committed) before performing an operation on it.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-03-16 01:16:09 -03:00
Wedson Almeida Filho 7380fe8528
Use `futures` version from workspace
Co-authored-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@users.noreply.github.com>
2023-03-16 00:59:56 -03: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
Wedson Almeida Filho f071faafc8 Implement `list` function
This is needed by remote snapshotters: once they report "already
exists", containerd tries to find the snapshot via `list`. If
it's not implemented, the "already exists" trick to prevent
layer download doesn't work.

This is still missing a filtering function, but allows remote
snapshotters to work.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-03-14 23:59:29 -03:00
Wedson Almeida Filho af7ec66df5 Implement `Serialize` and `Deserialize` for `Kind` and `Info`
This allows us to use `serde` to serialize and deserialize the
information about a particular snapshot so that we can write it
to and read it from storage.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-03-14 15:16:58 -03: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
Christophe de Dinechin 2d0d5c5602 docs: Update link for containerd shimv2 proto file
The `shim.proto` file is now under `api/runtime` instead of just `runtime`.

Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
2023-03-08 15:15:19 +01:00
Maksym Pavlenko 27a92fc606
Merge pull request #117 from wedsonaf/status
Add `Into<tonic::Status>` bound to `Snapshotter::Error`
2023-01-19 13:36:28 -08:00
Wedson Almeida Filho cdb52e74e5 Use `?` instead of `match` expression
This is just a simplification of the code to use `map_err` and
the question mark operator to improve readability.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-01-19 16:22:50 -03:00
Wedson Almeida Filho 3aeeea0f55 Add `Into<tonic::Status>` bound to `Snapshotter::Error`
This allows implementers to express which grpc status should be
returned to clients on errors.

Prior to this patch, all errors got converted to "internal"
errors (`tonic::Status::internal`), which doesn't work when
specific status are needed. For example, remote snapshotters
need to return "already exists" to indicate that a layer
doesn't need to be downloaded.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
2023-01-19 16:18:05 -03: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 faf24cbd42
Merge pull request #106 from containerd/dependabot/cargo/page_size-0.5.0
build(deps): update page_size requirement from 0.4.2 to 0.5.0
2023-01-07 11:49:28 -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] 8a20e3b2c3
build(deps): update page_size requirement from 0.4.2 to 0.5.0
Updates the requirements on [page_size](https://github.com/Elzair/page_size_rs) to permit the latest version.
- [Release notes](https://github.com/Elzair/page_size_rs/releases)
- [Commits](https://github.com/Elzair/page_size_rs/compare/0.4.2...0.5.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-12-17 23:28:10 +00:00
utam0k 909b41b4fe
Update oci-spec 2022-12-17 14:10:18 +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
dependabot[bot] 00b836f8de
build(deps): update simple_logger requirement from 3.0 to 4.0
Updates the requirements on [simple_logger](https://github.com/borntyping/rust-simple_logger) to permit the latest version.
- [Release notes](https://github.com/borntyping/rust-simple_logger/releases)
- [Commits](https://github.com/borntyping/rust-simple_logger/compare/v3.0.0...v4.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-27 21:49:35 +00:00
dependabot[bot] 0409907ac4
build(deps): update simple_logger requirement from 2.0 to 3.0
Updates the requirements on [simple_logger](https://github.com/borntyping/rust-simple_logger) to permit the latest version.
- [Release notes](https://github.com/borntyping/rust-simple_logger/releases)
- [Commits](https://github.com/borntyping/rust-simple_logger/compare/v2.0.0...v3.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-10-20 21:52:22 +00: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 d3d97df549 Remove generated code from shim-protos
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-27 08:57:33 -07:00
Maksym Pavlenko 97d00b4947
Merge pull request #95 from mxpv/ttrpc 2022-09-23 19:08:42 -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 78cd9dda69 Fix docs
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-22 18:50:31 -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
Zhang Tianyang 132b3fb221 shim: fix bug in mount rootfs flag
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-09-20 22:16:03 +08:00
Maksym Pavlenko 9d2ad01aa7 Remove vulnerable dependency found by cargo deny
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-19 15:12:58 -07:00
Maksym Pavlenko de34dc8760 Update snapshots dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-19 15:12:52 -07:00
Maksym Pavlenko 774ef5df56 Update client dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-09-19 15:12:40 -07:00
Manu Gupta a83ff8e8d2
Update README.md
ctr pull needs to be replaced by ctr i pull for the command to work.

Signed-off-by: Manu Gupta <manugupt1@gmail.com>
2022-09-05 21:54: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
Yuna Tomida f9ae07236d
removed unsafe codes on runc client and shim
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-05-04 15:39:41 +09: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
dependabot[bot] 9193b476c2
build(deps): update uuid requirement from 0.8.2 to 1.0.0
Updates the requirements on [uuid](https://github.com/uuid-rs/uuid) to permit the latest version.
- [Release notes](https://github.com/uuid-rs/uuid/releases)
- [Commits](https://github.com/uuid-rs/uuid/compare/0.8.2...1.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-20 21:37:17 +00:00
Maksym Pavlenko 497f88ca86 Update proto dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-04-06 09:19:21 -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
Zhang Tianyang 74ac192726 runc-shim: implement ShimExecutor in synchronous version
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-09 21:17:26 +08:00
Maksym Pavlenko 6bc49c007c
Merge pull request #50 from abel-von/add-async-runc
[runc-shim] support of async runc shim
2022-03-08 12:58:18 -08:00
Feng Shaobao 1e1a6a8d97 change Executor to Spawner and make it trait object 2022-03-08 15:39:43 +08:00
Maksym Pavlenko c0baac598f [Client] Bump to 0.2.0
Close: #54

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-03-07 11:09:02 -08:00
Feng Shaobao cdc78f7760 split async and sync codes for runc-shim and shim
Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-07 22:34:51 +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
Feng Shaobao 01f4916f95 shim: Support async traits and helper functions
Signed-off-by: Feng Shaobao <fshb1988@gmail.com>
2022-03-07 15:33:49 +08:00
Maksym Pavlenko 3aa4a4da77
Merge pull request #48 from Burning1020/shim-cgroup
runc-shim: support shim cgroup and oom score
2022-03-05 14:50:42 -08:00
Zhang Tianyang 4e1c3a2a69 runc-shim: support shim cgroup and oom score
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-04 15:47:29 +08:00
Zhang Tianyang fda23cd59f shim: refine set subreaper
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-03 20:46:01 +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 3ffe778e4b runc-shim: implement close io task
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-03-01 19:02:31 +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
Zhang Tianyang 9b93f39ee1 runc-shim: implement stats task
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-27 18:12:33 +08:00
Maksym Pavlenko c630c56e57
Merge pull request #41 from mxpv/exit
Rework exit signals and task creation
2022-02-25 12:30:37 -08:00
Maksym Pavlenko fa0d72f516 Fix clippy warnings
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-24 11:46:22 -08:00
Maksym Pavlenko 996c8e6aa8 Rework exit signal and task creation
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-24 11:32:34 -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
Maksym Pavlenko fa766d4e75
Merge pull request #38 from Burning1020/fix-files-leak 2022-02-23 15:47:37 -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
Liu Jiang 43f4702b7a shim-proto: group common proto types into types
Group generated soruce files for common protobuf source files into
src/types, also simplify the build.rs.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-02-23 16:39:09 +08:00
Maksym Pavlenko 78521c80bf Remove runc dependency from shim crate
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-21 10:26:19 -08:00
Maksym Pavlenko a1b2a25987 Update Cargo.toml for runc-shim
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-21 09:59:16 -08:00
Maksym Pavlenko 03496c936b
Merge pull request #34 from quanweiZhou/develop
support async for containerd-shim-protos
2022-02-21 09:52:01 -08:00
Quanwei Zhou c4471c4cbf shim-proto: add async example
Fixes: #33
Signed-off-by:Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-02-21 18:10:12 +08:00
Quanwei Zhou 6e50c8741c shim-proto: support async
Fixes: #33
Signed-off-by: Quanwei Zhou <quanweiZhou@linux.alibaba.com>
2022-02-21 16:52:45 +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 db4e648261 Simpify Config transmission mode
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-17 23:02:26 +08:00
Zhang Tianyang 620ce26d59 Remove extern use and refactor naming
Signed-off-by: Zhang Tianyang <burning9699@gmail.com>
2022-02-17 23:02:26 +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
Maksym Pavlenko 464af70dfa Remove IO impl for Arc
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-15 10:44:18 -08:00
Liu Jiang d453f1e38a runc: implement Io for Arc<T: Io>
Add an implementation of `impl<T: Io> Io for Arc<T>`.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 14:08:13 +08:00
Liu Jiang 0dc9705d7e runc: add unit test cases for io.rs
Add unit test cases for io.rs to avoid mistake.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 14:08:12 +08:00
Liu Jiang a52bcd0c7e runc: add helper PipedIo::create_pipe()
Add helper PipedIo::create_pipe() to reduce duplicated code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 14:08:11 +08:00
Liu Jiang be8046e832 runc: simplify code a bit and refine doc
Simplify code in io.rs a bit, also refine doc and simplify code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 14:08:10 +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 cd965aa06a runc: avoid panic when the child process get signalled
On Unix, tokio::process::ExitStatus::code() will return None if the
process was terminated by a signal. So handle to avoid panicking
caused by unwrap().

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 11:15:31 +08:00
Liu Jiang 8f20cfb58c runc: add test cases for process monitor 2022-02-15 11:15:27 +08:00
Liu Jiang 37975426b9 runc: enhance documentation for ProcessMonitor
Enhance documentation for ProcessMonitor, to explicitly state the
requirement of ProcessMonitor::start().

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-15 11:15:26 +08:00
Maksym Pavlenko 7a55e0f11b
Merge pull request #30 from jiangliu/globalotps
RFC: Refactor ConfigBuilder as GlobalOpts
2022-02-14 10:39:19 -08:00
Liu Jiang 8e86897ee9 shim-proto: avoid duplicated definition of Mount
There are two copies of mount.rs generated from the same protobuf file,
so unify them into one copy.

Fixed: #23

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-14 17:41:37 +08:00
Liu Jiang d170d62326 runc: add a unit test case for GlobalOpts
Add a unit test case for GlobalOpts.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-14 16:57:05 +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
Liu Jiang 2cba19f230 runc: avoid using unwrap() in util.rs
Introduce helper path_to_string() to avoid using unwrap().

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 0c6ca068ed
Merge pull request #26 from jiangliu/doc 2022-02-12 08:44:33 -08:00
Liu Jiang f1b90cc9b2 shim: add inline doc for set_subreaper() and SOCKET_FD
As follow-on work, add inline documentation for set_reapder(#19)
and SOCKET_FD (#20).

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2022-02-12 16:25:10 +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
Maksym Pavlenko 3b2b00f206 Update README
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-02-11 10:10:42 -08:00
Akihiro Suda 6e17be8d75
crates/shim-protos: regenerate with rust-protobuf 2.27.1
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2022-02-06 18:33:18 +09: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
Yuna Tomida 8bbd4e7baf
fixed clippy warnings in shim::args and example in client
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-03 13:35:24 +00:00
Yuna Tomida 43cf334648
applied fmt
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-03 08:35:04 +00:00
Yuna Tomida 2663849a52
confirmed tests
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-03 07:04:26 +00:00
Yuna Tomida 7c2b93f187
removed chrono from dependencies and applied fmt
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-03 05:09:17 +00:00
Yuna Tomida d34fa454ad
runc client
Signed-off-by: Yuna Tomida <ytomida.mmm@gmail.com>
2022-02-03 02:19:22 +00:00
Maksym Pavlenko f035941680
Merge pull request #20 from Burning1020/fix-socket-address
[shim] Fix socket binding address
2022-02-02 10:14:26 -08:00
Burning 88882cb2e2 [shim] Fix socket binding address
As there is no need in "-socket" flag, we'd better use SOCKET_FD as the binding address of task server only.

Signed-off-by: Burning <burning9699@gmail.com>
2022-01-22 20:28:12 +08:00
Burning 7c9a6a5a25 [shim] Set the "child subreaper" attribute
The shim process can have "child subreaper" attribute when arg2 is nonzero.

Signed-off-by: Burning <burning9699@gmail.com>
2022-01-22 19:50:19 +08:00
Maksym Pavlenko 9030cffa98
Merge pull request #17 from mxpv/ttrpc
Update ttrpc-rust to 0.6
2022-01-20 10:30:30 -08:00
dependabot[bot] 62755062d3
Update simple_logger requirement from 1.16 to 2.0
Updates the requirements on [simple_logger](https://github.com/borntyping/rust-simple_logger) to permit the latest version.
- [Release notes](https://github.com/borntyping/rust-simple_logger/releases)
- [Commits](https://github.com/borntyping/rust-simple_logger/compare/v1.16.0...v2.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-19 21:37:30 +00:00
Maksym Pavlenko 17ea78a0e0 Update ttrpc-rust to 0.6
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2022-01-19 08:47:43 -08:00
Samuel Ortiz f2ad153965 [shim] README: Update the example to the latest API
Use the skeleton.rs code.

Signed-off-by: Samuel Ortiz <s.ortiz@apple.com>
2022-01-19 08:31:34 -08:00
Maksym Pavlenko 4e84e9b800 [logger] Update documentation
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-31 12:29:13 +02:00
Maksym Pavlenko 0befc3d4f7 [shim] Rename empty shim example
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-30 10:16:56 +02:00
Maksym Pavlenko 55cd05887d [shim] Add runtime section to README
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-30 10:06:14 +02:00
Maksym Pavlenko f43b11df48 Bump shim to 0.2.0
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-30 09:23:57 +02:00
Maksym Pavlenko 559bf7bc8d Bump shim-protos to 0.1.2
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-30 09:14:03 +02:00
Maksym Pavlenko 4ad21f61b3 [shim-protos] Update README
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-30 09:12:54 +02:00
Maksym Pavlenko 39065ec9ed Rename shim-client to shim-protos
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-30 08:43:32 +02:00
Maksym Pavlenko d901356551 Update dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-28 10:54:59 +02:00
bin liu cfca48d75c containerd-client: add example to create container and task
Add an example to show how to create/delete containers and tasks.

Signed-off-by: bin liu <bin@hyper.sh>
2021-12-19 20:09:17 -08:00
bin liu 2010a32a47 containerd-client: add task service and with_namespace macro
There is no task service included yet, add the task
service protocol file to build.rs.

Add a with_namespace maro to let user inject namespace

Signed-off-by: bin liu <bin@hyper.sh>
2021-12-19 20:09:17 -08:00
Maksym Pavlenko fcb5cc5966 Update crate description
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-18 10:39:28 -08:00
Maksym Pavlenko a6b32c32bd Add README
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-18 10:39:28 -08:00
Maksym Pavlenko e5d003c8bb Add snapshots example
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-18 10:39:28 -08:00
Maksym Pavlenko 70f7cacdc1 Implement GRPC wrapper for snapshots
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-18 10:39:28 -08:00
Maksym Pavlenko e3b7f97813 Generate GRPC bindings for snapshots
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-18 10:39:28 -08:00
Maksym Pavlenko b342a674b1 Add snapshots crate
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-18 10:39:28 -08:00
Maksym Pavlenko b7e673d7a7 Add cargo deny
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-15 20:58:32 -08:00
Liu Jiang 95e8049398 shim: distinguish between runtime id and container id
There's a misuse of runtime id and container id in Shim::new(). Both
runtime id and container id are needed by shim implentions, so add
parameter `container id` to Shim::new().

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-14 13:44:45 +08:00
bin liu c12ac9ee68 shim: update README.md to run shim examples
The content of README.md is out of date, update it
with the correct steps to run the examples.

Signed-off-by: bin liu <bin@hyper.sh>
2021-12-14 11:37:00 +08:00
bin liu e5e0ebbe36 shim: pass the correct ID of containers to shim
The ID passed from shim::run::<Service> is the shim name,
the container ID can get from command-line flags.

Signed-off-by: bin liu <bin@hyper.sh>
2021-12-13 18:14:51 +08:00
Liu Jiang 72aebb1b39 shim: trivial documentation enhancements
Trivial documentation enhancements:
1) comments for unsafe code
2) list supported platforms

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:13:05 +08:00
Liu Jiang a2bfeed2ca shim: introduce Shim::wait()
Introduce Shim::wait() to wait for a shim instance to exit, so the
`Shim` implementor could customize the way to manage exit event.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:20 +08:00
Liu Jiang fdd50661f3 shim: add interface Shim::get_task_service()
Currently Containerd shimv2 runtime only provides task service, but it
may provide more service in future. So add interface
Shim::get_task_service() to get the task service object instead of
"Shim: Task".

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:19 +08:00
Liu Jiang 7a8fa4413e shim: implement ExitSignal with Condvar
Implement ExitSignal with Condvar instead of busy looping.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:15 +08:00
Liu Jiang 04af4df73a shim: pass environment variables to spawned process
Enhanace spawn() to pass envrionment variables to child process.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:15 +08:00
Liu Jiang 1b106ee38d shim: add unit test for start_listener()
Add unit test for start_listener().

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:14 +08:00
Liu Jiang 0c83d7c04c shim: be more careful when removing stale socket files
The function start_listener() tries to remove stale socket files when
syscall::bind() retune EADDRINUSE, let's be more careful to only remove
existing sockets instead of other types of files.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:13 +08:00
Liu Jiang 63f62b9c9c shim: avoid raw fd leak in spawn()
The RawFd for the listener socket will get leaked in error handling
path in start_listener(). Use UnixListener to replace RawFd for clear
ownership and also simplify the code a bit.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:12 +08:00
Liu Jiang 64d57879ce shim: add unit tests for remote publisher
Add unit tests for remote publisher.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:11 +08:00
Liu Jiang 01e45800dc shim: release fd when error happens in RemotePublisher::connect()
A RawFd won't be automatically released when going out of scope,
so we need to close the just created RawFd when error happens
in RemotePublisher::connect().

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:11 +08:00
Liu Jiang 0eff017c40 shim: add unit test case for logger
Add unit test case for logger.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:10 +08:00
Liu Jiang 5197e72f4a shim: do not panic if failed to log to FIFO
According to Linux FIFO doc, writing to a FIFO without reader may
return errors:
If all file descriptors referring to the read end of a pipe have been
closed, then a write(2) will cause a SIGPIPE signal to be generated
for the calling process. If the calling process is ignoring this
signal, then write(2) fails with the error EPIPE.

When restarting logger servers, there are small race windows that
FifoLogger::log/flush() may encounter IO error and panic. It's not
a good situation to panic due to errors in logging subsystem.

So just ignore those IO errors.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-13 10:08:09 +08:00
Liu Jiang 4f78733008 shim-client: refine data structures exported by submodule api
Reexport auto-generated public data structures under submodule api.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-12 22:39:33 +08:00
Liu Jiang 6d46508d3b shim-client: add unit test cases and more examples
Add unit test cases and more examples.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-12 22:39:32 +08:00
Liu Jiang 62fd081d88 shim-client: add support for cgroup metrics
Generate rust bindings for cgroups metrics from protobuf file:
https://github.com/containerd/cgroups/blob/main/stats/v1/metrics.proto

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-12 22:39:31 +08:00
Liu Jiang 8655b0ff41 shim-client: make dependency on ttrpc-codegen as optional
Now we have feature "generate_bindings" for shim-client, and crate
ttrpc-codegen is used only when feature "generate_bindings" is enabled.
So mark ttrpc-codegen as optional.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-12 22:39:30 +08:00
Liu Jiang 9d66917ce1 shim-client: docuement the way to upgrade the auto-generated code
Enhance README.md to document the way to upgrade the auto-generated
rust source code.

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-11 15:20:53 +08:00
Maksym Pavlenko b8252e525b Bump containerd client to 0.1.2
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-10 16:01:05 -08:00
Maksym Pavlenko 8cf673677a Update containerd client dependencies
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-10 15:58:05 -08:00
Maksym Pavlenko 34ab8a1b6f Bump version to 0.1.1
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-10 15:33:15 -08:00
Maksym Pavlenko 064387518e Update authors and homepage
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-10 15:32:26 -08:00
Maksym Pavlenko 3baf235798 Include generated code for shim-client
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
2021-12-10 15:25:47 -08:00