From e5e0ebbe364e0d4d766b7d3d048c44a235481258 Mon Sep 17 00:00:00 2001 From: bin liu Date: Mon, 13 Dec 2021 18:14:51 +0800 Subject: [PATCH 1/3] shim: pass the correct ID of containers to shim The ID passed from shim::run:: is the shim name, the container ID can get from command-line flags. Signed-off-by: bin liu --- crates/shim/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/shim/src/lib.rs b/crates/shim/src/lib.rs index 37df6f9..598b3b3 100644 --- a/crates/shim/src/lib.rs +++ b/crates/shim/src/lib.rs @@ -183,7 +183,7 @@ where match flags.action.as_str() { "start" => { let args = StartOpts { - id: id.into(), + id: flags.id, publish_binary: flags.publish_binary, address: flags.address, ttrpc_address, From bcf427ab94580ad74ede0686fe41995df1e938b9 Mon Sep 17 00:00:00 2001 From: bin liu Date: Mon, 13 Dec 2021 18:15:17 +0800 Subject: [PATCH 2/3] shim: add log to .gitignore add log to .gitignore to avoid committing log file to repo. Signed-off-by: bin liu --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 088ba6b..9045886 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +log From c12ac9ee68bdce74c15ef40a9f5086f0dfc57281 Mon Sep 17 00:00:00 2001 From: bin liu Date: Mon, 13 Dec 2021 19:33:38 +0800 Subject: [PATCH 3/3] 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 --- crates/shim/README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/shim/README.md b/crates/shim/README.md index ee21028..568921a 100644 --- a/crates/shim/README.md +++ b/crates/shim/README.md @@ -73,19 +73,21 @@ fn main() { ## How to use with containerd +**Note**: All operations are in the root directory of `rust-extensions`. + With shim v2 runtime: ```bash -$ cargo build --example empty-shim -$ sudo cp ./target/debug/examples/empty-shim /usr/local/bin/containerd-shim-empty-v2 -$ sudo ctr run --rm --runtime io.containerd.empty.v2 -t docker.io/library/hello-world:latest hello +$ cargo build --example empty_shim +$ sudo cp ./target/debug/examples/empty_shim /usr/local/bin/containerd-shim-empty-v1 +$ sudo ctr run --rm --runtime io.containerd.empty.v1 -t docker.io/library/hello-world:latest hello ``` Or if on 1.6+ ```bash -$ cargo build --example empty-shim -ctr run --rm --runtime ./target/debug/examples/empty_shim docker.io/library/hello-world:latest hello +$ cargo build --example empty_shim +$ sudo ctr run --rm --runtime ./target/debug/examples/empty_shim docker.io/library/hello-world:latest hello ``` Or manually: @@ -103,8 +105,8 @@ $ sudo TTRPC_ADDRESS="/var/run/containerd/containerd.sock.ttrpc" \ start unix:///var/run/containerd/eb8e7d1c48c2a1ec.sock -$ cargo build --example connect -$ sudo ./target/debug/examples/connect unix:///var/run/containerd/eb8e7d1c48c2a1ec.sock +$ cargo build --example shim-proto-connect +$ sudo ./target/debug/examples/shim-proto-connect unix:///var/run/containerd/eb8e7d1c48c2a1ec.sock Connecting to unix:///var/run/containerd/eb8e7d1c48c2a1ec.sock... Sending `Connect` request... Connect response: version: "example"