From 25d151bd1b99d7170f059118e5b90f726ef89d6a Mon Sep 17 00:00:00 2001 From: Manabu Sugimoto Date: Wed, 9 Aug 2023 11:35:55 +0900 Subject: [PATCH] runk: Modify kill command's error message for containerd tests The error message when the kill command is executed with the container's state == Stopped should be "container not running" because the containerd tests expect that OCI runtimes return the error message and compare it. If the error message is different from the expected one, the tests fail. Fixes: #7650 Signed-off-by: Manabu Sugimoto --- src/tools/runk/Cargo.lock | 60 ++++++++++++++++++++ src/tools/runk/libcontainer/src/container.rs | 6 +- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/tools/runk/Cargo.lock b/src/tools/runk/Cargo.lock index ed239100af..f653ba9ccb 100644 --- a/src/tools/runk/Cargo.lock +++ b/src/tools/runk/Cargo.lock @@ -438,6 +438,16 @@ dependencies = [ "dirs-sys", ] +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if 1.0.0", + "dirs-sys-next", +] + [[package]] name = "dirs-sys" version = "0.3.7" @@ -449,6 +459,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "either" version = "1.6.1" @@ -774,6 +795,7 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" name = "kata-sys-util" version = "0.1.0" dependencies = [ + "anyhow", "byteorder", "cgroups-rs", "chrono", @@ -911,6 +933,7 @@ dependencies = [ "slog-async", "slog-json", "slog-scope", + "slog-term", ] [[package]] @@ -1512,6 +1535,12 @@ dependencies = [ "zbus", ] +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + [[package]] name = "ryu" version = "1.0.9" @@ -1659,6 +1688,19 @@ dependencies = [ "slog", ] +[[package]] +name = "slog-term" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87d29185c55b7b258b4f120eab00f48557d4d9bc814f41713f449d35b0f8977c" +dependencies = [ + "atty", + "slog", + "term", + "thread_local", + "time 0.3.9", +] + [[package]] name = "smallvec" version = "1.8.0" @@ -1748,6 +1790,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + [[package]] name = "termcolor" version = "1.1.3" @@ -1819,8 +1872,15 @@ dependencies = [ "itoa", "libc", "num_threads", + "time-macros", ] +[[package]] +name = "time-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" + [[package]] name = "tokio" version = "1.28.1" diff --git a/src/tools/runk/libcontainer/src/container.rs b/src/tools/runk/libcontainer/src/container.rs index 49f57a019b..f8ddcdfe5f 100644 --- a/src/tools/runk/libcontainer/src/container.rs +++ b/src/tools/runk/libcontainer/src/container.rs @@ -103,7 +103,11 @@ impl Container { "container {} can't be killed because it is {:?}", self.status.id, self.state - )); + ) + // This error message mustn't be chagned because the containerd integration tests + // expect that OCI container runtimes return the message. + // Ref. https://github.com/containerd/containerd/blob/release/1.7/pkg/process/utils.go#L135 + .context("container not running")); } let pid = Pid::from_raw(self.status.pid);