From 6cf228f94eaf0149a215a5da97723a6f47e2bd15 Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 13:51:19 +0200 Subject: [PATCH 1/8] feat(node-agent): create cargo workspace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Cargo.toml file at the root of the project to manage the dependencies of the different crates. Building, formatting and linting will now be easier. Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- .gitignore | 8 +- Cargo.lock | 2181 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 5 + 3 files changed, 2190 insertions(+), 4 deletions(-) create mode 100644 Cargo.lock create mode 100644 Cargo.toml diff --git a/.gitignore b/.gitignore index 6985cf1b..a5b960a0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,12 +3,12 @@ debug/ target/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - # These are backup files generated by rustfmt **/*.rs.bk # MSVC Windows builds of rustc generate these, which store debugging information *.pdb + +# IDE +.vscode/ +.idea/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..c964f498 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2181 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" + +[[package]] +name = "anstyle-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +dependencies = [ + "backtrace", +] + +[[package]] +name = "async-stream" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "async-trait" +version = "0.1.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http", + "http-body", + "hyper", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http", + "http-body", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "bumpalo" +version = "3.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f56b4c72906975ca04becb8a30e102dfecddd0c06181e3e95ddc444be28881f8" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "time 0.1.45", + "wasm-bindgen", + "windows-targets", +] + +[[package]] +name = "clap" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" +dependencies = [ + "clap_builder", + "clap_derive", + "once_cell", +] + +[[package]] +name = "clap-verbosity-flag" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eef05769009513df2eb1c3b4613e7fad873a14c600ff025b08f250f59fee7de" +dependencies = [ + "clap", + "log", +] + +[[package]] +name = "clap_builder" +version = "4.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "clap_lex" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "containerd-client" +version = "0.4.0" +source = "git+https://github.com/containerd/rust-extensions?tag=client-v0.4.0#d08ece3805d8f4784cacb93a9430c525dfa3bb3c" +dependencies = [ + "prost", + "prost-types", + "tokio", + "tonic", + "tonic-build", + "tower", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "deranged" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + +[[package]] +name = "h2" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 1.9.3", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.4.9", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5477fe2230a79769d8dc68e0eabf5437907c0457a5614a9e8dddb67f65eb65d" +dependencies = [ + "equivalent", + "hashbrown 0.14.0", +] + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "js-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" + +[[package]] +name = "linux-raw-sys" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" + +[[package]] +name = "lock_api" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "matchit" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed1202b2a6f884ae56f04cff409ab315c5ce26b5e58d7412e484f01fd52f52ef" + +[[package]] +name = "memchr" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys", +] + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-traits" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "orka-controller" +version = "0.1.0" +dependencies = [ + "anyhow", + "axum", + "log", + "pretty_env_logger", + "prost", + "serde", + "serde_json", + "syn 2.0.29", + "thiserror", + "tokio", + "tokio-stream", + "tonic", + "tonic-build", + "validator", +] + +[[package]] +name = "orka-node-agent" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-stream", + "clap", + "clap-verbosity-flag", + "containerd-client", + "orka-proto", + "prost", + "prost-types", + "serde_json", + "sysinfo", + "thiserror", + "tokio", + "tokio-stream", + "tonic", + "tonic-build", + "tower-http", + "tracing", + "tracing-log", + "tracing-subscriber", + "uuid", +] + +[[package]] +name = "orka-proto" +version = "0.1.0" +dependencies = [ + "prost", + "prost-build", + "tonic", + "tonic-build", +] + +[[package]] +name = "orka-scheduler" +version = "0.1.0" +dependencies = [ + "anyhow", + "chrono", + "clap", + "clap-verbosity-flag", + "log", + "orka-proto", + "prost", + "prost-types", + "rcgen", + "thiserror", + "time 0.3.28", + "tokio", + "tokio-stream", + "tonic", + "tower-http", + "tracing", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "pem" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a" +dependencies = [ + "base64", + "serde", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.0", +] + +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "pretty_env_logger" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "rcgen" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4954fbc00dcd4d8282c987710e50ba513d351400dbdd00e803a05172a90d8976" +dependencies = [ + "pem", + "ring", + "time 0.3.28", + "yasna", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "regex" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustix" +version = "0.38.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed6248e1caa625eb708e266e06159f135e8c26f2bb7ceb72dc4b2766d0340964" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustls" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +dependencies = [ + "ring", + "untrusted", +] + +[[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.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "serde_json" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "693151e1ac27563d6dbcec9dee9fbd5da8539b20fa14ad3752b2e6d363ace360" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4beec8bce849d58d06238cb50db2e1c417cfeafa4c63f692b15c82b7c80f8335" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sysinfo" +version = "0.29.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d0e9cc2273cc8d31377bdd638d72e3ac3e5607b18621062b169d02787f1bab" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi", +] + +[[package]] +name = "tempfile" +version = "3.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys", +] + +[[package]] +name = "termcolor" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + +[[package]] +name = "time" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" +dependencies = [ + "deranged", + "serde", + "time-core", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ed6077ed6cd6c74735e21f37eb16dc3935f96878b1fe961074089cc80893f9" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2 0.5.3", + "tokio-macros", + "windows-sys", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tonic" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64", + "bytes", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "rustls-pemfile", + "tokio", + "tokio-rustls", + "tokio-stream", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tonic-build" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6fdaae4c2c638bb70fe42803a26fbd6fc6ac8c72f5c59f67ecc2a2dcabf4b07" +dependencies = [ + "prettyplease", + "proc-macro2", + "prost-build", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ae70283aba8d2a8b411c695c437fe25b8b5e44e23e780662002fc72fb47a82" +dependencies = [ + "bitflags 2.4.0", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "tracing-core" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30a651bc37f915e81f087d86e62a18eec5f79550c7faff886f7090b4ea757c77" +dependencies = [ + "nu-ansi-term", + "sharded-slab", + "smallvec", + "thread_local", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +dependencies = [ + "getrandom", + "rand", + "uuid-macro-internal", +] + +[[package]] +name = "uuid-macro-internal" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7e1ba1f333bd65ce3c9f27de592fcbc256dafe3af2717f56d7c87761fbaccf4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", +] + +[[package]] +name = "validator" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b92f40481c04ff1f4f61f304d61793c7b56ff76ac1469f1beb199b1445b253bd" +dependencies = [ + "idna", + "lazy_static", + "regex", + "serde", + "serde_derive", + "serde_json", + "url", + "validator_derive", +] + +[[package]] +name = "validator_derive" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc44ca3088bb3ba384d9aecf40c6a23a676ce23e09bdaca2073d99c207f864af" +dependencies = [ + "if_chain", + "lazy_static", + "proc-macro-error", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "validator_types", +] + +[[package]] +name = "validator_types" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111abfe30072511849c5910134e8baf8dc05de4c0e5903d681cbd5c9c4d611e3" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.29", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.29", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.87" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" + +[[package]] +name = "web-sys" +version = "0.3.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time 0.3.28", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..2c5ec1f2 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,5 @@ +[workspace] + +resolver = "2" + +members = ["node-agent", "scheduler", "controller", "proto"] From f94425567f158837b197cac7b952126bcbcea060 Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 13:52:02 +0200 Subject: [PATCH 2/8] fix(node-agent): use proper types for enums MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- proto/src/node-agent/agent.proto | 2 +- proto/src/scheduler/agent.proto | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/proto/src/node-agent/agent.proto b/proto/src/node-agent/agent.proto index 5a25095a..d6910297 100644 --- a/proto/src/node-agent/agent.proto +++ b/proto/src/node-agent/agent.proto @@ -28,7 +28,7 @@ message WorkloadStatus { TERMINATED = 2; } - uint32 code = 1; + StatusCode code = 1; optional string message = 2; } diff --git a/proto/src/scheduler/agent.proto b/proto/src/scheduler/agent.proto index e3f70034..b8defb46 100644 --- a/proto/src/scheduler/agent.proto +++ b/proto/src/scheduler/agent.proto @@ -11,6 +11,7 @@ message Empty {} message ConnectionRequest { string id = 1; + uint32 port = 2; // Expected to be in the uint16 boundaries } message DisconnectionNotice { From 9498c1ba575c8928c062126e3d125df84ed427c0 Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 14:18:52 +0200 Subject: [PATCH 3/8] feat(node-agent): implement container creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a wrapper for containerd-client lib (and ctr cli for creation) to create a container and run a workload. This will however mean more resource usage, overhead, latency, potential socket exhaustion, etc.. This is a tradeoff we are willing to make for now, since these issues are not likely to be a problem in the near future. The ctr cli was used to create the container because the containerd-client we did not manage to create a container with the containerd-client lib. It runs the command ctr run -d . **Note**: It seems Kuruyia has managed to prepare a rootfs and run a container, you can find it [here](https://github.com/Martin-Moreira-de-jesus/orka/blob/tmp/containerd-create-workload/node-agent/src/workload_manager/container/client.rs). Also note that for some reason if you dont build the node-agent binary from the folder node-agent, the containerd socket cannot be found for some reason. Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- Cargo.lock | 102 ----------- node-agent/Cargo.toml | 25 +++ node-agent/src/main.rs | 22 +++ .../src/workload_manager/container/client.rs | 160 ++++++++++++++++++ .../src/workload_manager/container/error.rs | 20 +++ .../src/workload_manager/container/mod.rs | 2 + node-agent/src/workload_manager/mod.rs | 1 + 7 files changed, 230 insertions(+), 102 deletions(-) create mode 100644 node-agent/Cargo.toml create mode 100644 node-agent/src/main.rs create mode 100644 node-agent/src/workload_manager/container/client.rs create mode 100644 node-agent/src/workload_manager/container/error.rs create mode 100644 node-agent/src/workload_manager/container/mod.rs create mode 100644 node-agent/src/workload_manager/mod.rs diff --git a/Cargo.lock b/Cargo.lock index c964f498..6822d151 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -337,49 +337,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset", - "scopeguard", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - [[package]] name = "deranged" version = "0.3.8" @@ -780,15 +737,6 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "mime" version = "0.3.17" @@ -821,15 +769,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "ntapi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" -dependencies = [ - "winapi", -] - [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -899,15 +838,11 @@ name = "orka-node-agent" version = "0.1.0" dependencies = [ "anyhow", - "async-stream", - "clap", - "clap-verbosity-flag", "containerd-client", "orka-proto", "prost", "prost-types", "serde_json", - "sysinfo", "thiserror", "tokio", "tokio-stream", @@ -1193,28 +1128,6 @@ dependencies = [ "getrandom", ] -[[package]] -name = "rayon" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" -dependencies = [ - "crossbeam-channel", - "crossbeam-deque", - "crossbeam-utils", - "num_cpus", -] - [[package]] name = "rcgen" version = "0.11.1" @@ -1504,21 +1417,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" -[[package]] -name = "sysinfo" -version = "0.29.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d0e9cc2273cc8d31377bdd638d72e3ac3e5607b18621062b169d02787f1bab" -dependencies = [ - "cfg-if", - "core-foundation-sys", - "libc", - "ntapi", - "once_cell", - "rayon", - "winapi", -] - [[package]] name = "tempfile" version = "3.8.0" diff --git a/node-agent/Cargo.toml b/node-agent/Cargo.toml new file mode 100644 index 00000000..86a6485b --- /dev/null +++ b/node-agent/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "orka-node-agent" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow = "1.0.72" +containerd-client = { git = "https://github.com/containerd/rust-extensions", tag = "client-v0.4.0" } +prost = "0.11.9" +prost-types = "0.11.9" +thiserror = "1.0.44" +tokio = { version = "1.29.1", features = ["full"] } +tonic = "0.9.2" +orka-proto = { path = "../proto" } +serde_json = "1.0.105" +tokio-stream = "0.1.14" +tracing = "0.1.37" +tracing-subscriber = "0.3.17" +tracing-log = "0.1.3" +uuid = { version = "1.4.1", features = ["v4", "macro-diagnostics", "fast-rng"] } +tower-http = { version = "0.4.3", features = ["trace"] } + +[build-dependencies] +tonic-build = "0.9.2" +tokio = { version = "1.0.0", features = ["full"] } diff --git a/node-agent/src/main.rs b/node-agent/src/main.rs new file mode 100644 index 00000000..28d78820 --- /dev/null +++ b/node-agent/src/main.rs @@ -0,0 +1,22 @@ +mod workload_manager; + +use orka_proto::node_agent::Workload; +use workload_manager::container::client::ContainerClient; + +#[tokio::main] +async fn main() { + let mut workload_manager = ContainerClient::new("/var/run/containerd/containerd.sock").await.unwrap(); + + let workload = Workload { + instance_id: "nginx".to_string(), + image: "docker.io/library/nginx:latest".to_string(), + environment: vec!["FOO=BAR".to_string()], + ..Default::default() + }; + + workload_manager.create(&workload).await.unwrap(); + + let response = workload_manager.info("nginx").await.unwrap(); + + println!("{:?}", response); +} diff --git a/node-agent/src/workload_manager/container/client.rs b/node-agent/src/workload_manager/container/client.rs new file mode 100644 index 00000000..558a12e6 --- /dev/null +++ b/node-agent/src/workload_manager/container/client.rs @@ -0,0 +1,160 @@ +use containerd_client::{ + connect, + services::v1::{ + containers_client::ContainersClient, tasks_client::TasksClient, + GetContainerRequest, GetContainerResponse, + }, + with_namespace, +}; +use tokio::process::Command; +use tonic::{transport::Channel, Code, Response}; +use tonic::{Request, Status}; + +use super::error::ContainerClientError; + +use orka_proto::node_agent::Workload; + +const NAMESPACE: &str = "default"; + +pub struct CreateContainerResponse { + pub container_id: String, +} + +pub struct ContainerClient { + sock_path: String, +} + +impl ContainerClient { + async fn get_channel(&self) -> Result { + let channel = connect(self.sock_path.clone()).await.map_err(|_| { + ContainerClientError::ContainerdSocketNotFound { + sock_path: self.sock_path.clone(), + } + })?; + Ok(channel) + } + + async fn get_task_client(&self) -> Result, ContainerClientError> { + let channel = self.get_channel().await?; + Ok(TasksClient::new(channel)) + } + + async fn get_client(&self) -> Result, ContainerClientError> { + let channel = self.get_channel().await?; + Ok(ContainersClient::new(channel)) + } + + pub async fn new(sock_path: &str) -> Result { + let _ = connect(sock_path.clone()).await.map_err(|_| { + ContainerClientError::ContainerdSocketNotFound { + sock_path: sock_path.to_string(), + } + })?; + + Ok(Self { + sock_path: sock_path.to_string(), + }) + } + + pub async fn info( + &mut self, + container_id: &str, + ) -> Result, ContainerClientError> { + let request = GetContainerRequest { + id: container_id.to_string(), + }; + + let request = with_namespace!(request, NAMESPACE); + + let mut client = self.get_client().await?; + + let response = client + .get(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + Ok(response) + } + + pub async fn pull_image_if_not_present( + &mut self, + image_name: &str, + ) -> Result<(), ContainerClientError> { + // TODO - pull image with standard rust instead of CLI + let command = Command::new("ctr") + .arg("image") + .arg("pull") + .arg(image_name) + .output() + .await + .map_err(|error| ContainerClientError::GRPCError { + status: Status::unknown(format!("ctr image pull {:?}", error)), + })?; + + if !command.status.success() { + return Err(ContainerClientError::GRPCError { + status: Status::unknown(format!( + "failed pulling image {:?}", + String::from_utf8_lossy(&command.stderr) + )), + }); + } + + Ok(()) + } + + pub async fn create( + &mut self, + workload: &Workload, + ) -> Result, ContainerClientError> { + match self.info(&workload.instance_id).await { + Ok(_) => { + return Err(ContainerClientError::GRPCError { + status: Status::already_exists("container already exists".to_string()), + }) + } + Err(ContainerClientError::ContainerdSocketNotFound { sock_path }) => { + return Err(ContainerClientError::ContainerdSocketNotFound { sock_path }) + } + Err(ContainerClientError::GRPCError { status }) => { + if status.code() != Code::NotFound { + return Err(ContainerClientError::GRPCError { status }); + } + } + } + + // TODO - pull image with standard rust instead of CLI + self.pull_image_if_not_present(&workload.image).await?; + + let env = workload + .environment + .iter() + .map(|value| format!("--env={}", value)); + + // TODO - use containerd library to create container instead of ctr + let command = Command::new("ctr") + .arg("run") + .arg("--detach") + .args(env) + .arg(&workload.image) + .arg(&workload.instance_id) + .output() + .await + .map_err(|error| ContainerClientError::GRPCError { + status: Status::unknown(format!("ctr run failed {:?}", error)), + })?; + + if !command.status.success() { + return Err(ContainerClientError::GRPCError { + status: Status::unknown(format!( + "ctr run failed: {}", + String::from_utf8_lossy(&command.stderr) + )), + }); + } + + Ok(Response::new(CreateContainerResponse { + container_id: workload.instance_id.to_string(), + })) + } +} diff --git a/node-agent/src/workload_manager/container/error.rs b/node-agent/src/workload_manager/container/error.rs new file mode 100644 index 00000000..00bf460d --- /dev/null +++ b/node-agent/src/workload_manager/container/error.rs @@ -0,0 +1,20 @@ +use thiserror::Error; +use tonic::Status; + +#[derive(Error, Debug)] +pub enum ContainerClientError { + #[error("Socket {sock_path:?} not found")] + ContainerdSocketNotFound { sock_path: String }, + #[error("gRPC with error code {status:?} occured")] + GRPCError { status: Status }, +} + +pub fn into_tonic_status(error: ContainerClientError) -> tonic::Status { + match error { + ContainerClientError::GRPCError { status } => status, + _ => tonic::Status::new( + tonic::Code::Internal, + format!("Failed to delete container: {:?}", error), + ), + } +} diff --git a/node-agent/src/workload_manager/container/mod.rs b/node-agent/src/workload_manager/container/mod.rs new file mode 100644 index 00000000..f27e7610 --- /dev/null +++ b/node-agent/src/workload_manager/container/mod.rs @@ -0,0 +1,2 @@ +pub mod client; +pub mod error; diff --git a/node-agent/src/workload_manager/mod.rs b/node-agent/src/workload_manager/mod.rs new file mode 100644 index 00000000..18581c4b --- /dev/null +++ b/node-agent/src/workload_manager/mod.rs @@ -0,0 +1 @@ +pub mod container; From 33b521949ab2de7aa58b0c10c7d23c211bd08836 Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 14:29:41 +0200 Subject: [PATCH 4/8] feat(node-agent): add status, cleanup and kill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `containerd-client` is used to kill the container. We did however have an issue concerning an ambiguous type definition. Indeed, the Workload Signal enum is ambiguous. It is not clear what signal STOP represents. For now we made the assumption that stop is SIGINT (2). Both Stop (SIGINT) and Kill (SIGKILL) signals are sent to the workload, then the workload is cleaned up. Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- node-agent/src/main.rs | 22 ++++- .../src/workload_manager/container/client.rs | 93 ++++++++++++++++++- 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/node-agent/src/main.rs b/node-agent/src/main.rs index 28d78820..bb5ea5a3 100644 --- a/node-agent/src/main.rs +++ b/node-agent/src/main.rs @@ -3,12 +3,14 @@ mod workload_manager; use orka_proto::node_agent::Workload; use workload_manager::container::client::ContainerClient; +const CID: &str = "nginx"; + #[tokio::main] async fn main() { let mut workload_manager = ContainerClient::new("/var/run/containerd/containerd.sock").await.unwrap(); let workload = Workload { - instance_id: "nginx".to_string(), + instance_id: CID.to_string(), image: "docker.io/library/nginx:latest".to_string(), environment: vec!["FOO=BAR".to_string()], ..Default::default() @@ -16,7 +18,23 @@ async fn main() { workload_manager.create(&workload).await.unwrap(); - let response = workload_manager.info("nginx").await.unwrap(); + let response = workload_manager.info(CID).await.unwrap(); println!("{:?}", response); + + let response = workload_manager.status(CID).await.unwrap(); + + println!("{:?}", response); + + let signal = 9; + workload_manager.kill(CID, signal).await.unwrap(); + + workload_manager.wait(CID).await.unwrap(); + + workload_manager.cleanup(CID).await.unwrap(); + + match workload_manager.status(CID).await { + Ok(_) => panic!("Workload should not exist"), + Err(_) => println!("Workload does not exist"), + }; } diff --git a/node-agent/src/workload_manager/container/client.rs b/node-agent/src/workload_manager/container/client.rs index 558a12e6..62e9ed84 100644 --- a/node-agent/src/workload_manager/container/client.rs +++ b/node-agent/src/workload_manager/container/client.rs @@ -2,7 +2,7 @@ use containerd_client::{ connect, services::v1::{ containers_client::ContainersClient, tasks_client::TasksClient, - GetContainerRequest, GetContainerResponse, + GetContainerRequest, GetContainerResponse, KillRequest, WaitRequest, WaitResponse, DeleteTaskRequest, DeleteContainerRequest, GetResponse, GetRequest, }, with_namespace, }; @@ -56,6 +56,27 @@ impl ContainerClient { }) } + pub async fn status( + &mut self, + container_id: &str, + ) -> Result, ContainerClientError> { + let request = GetRequest { + container_id: container_id.to_string(), + ..Default::default() + }; + + let request = with_namespace!(request, NAMESPACE); + + let mut client = self.get_task_client().await?; + + let response = client + .get(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + Ok(response) + } + pub async fn info( &mut self, container_id: &str, @@ -157,4 +178,74 @@ impl ContainerClient { container_id: workload.instance_id.to_string(), })) } + + pub async fn cleanup(&mut self, id: &str) -> Result, ContainerClientError> { + let request = DeleteTaskRequest { + container_id: id.to_string(), + }; + + let request = with_namespace!(request, NAMESPACE); + + let mut task_client = self.get_task_client().await?; + + let _ = task_client + .delete(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + let request = DeleteContainerRequest { id: id.to_string() }; + + let request = with_namespace!(request, NAMESPACE); + + let mut container_client = self.get_client().await?; + + let _ = container_client + .delete(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + Ok(Response::new(())) + } + + pub async fn kill( + &mut self, + id: &str, + signal: u32, + ) -> Result, ContainerClientError> { + let request = KillRequest { + container_id: id.to_string(), + signal, + all: true, + ..Default::default() + }; + + let request = with_namespace!(request, NAMESPACE); + + let mut task_client = self.get_task_client().await?; + + let response = task_client + .kill(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + Ok(response) + } + + pub async fn wait(&mut self, id: &str) -> Result, ContainerClientError> { + let request = WaitRequest { + container_id: id.to_string(), + ..Default::default() + }; + + let request = with_namespace!(request, NAMESPACE); + + let mut client = self.get_task_client().await?; + + let response = client + .wait(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + Ok(response) + } } From ce3d051a422c2e4ba54d26185561337c517b841d Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 14:39:58 +0200 Subject: [PATCH 5/8] feat(node-agent): add metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- node-agent/build.rs | 7 ++ node-agent/src/main.rs | 14 +++ .../src/workload_manager/container/client.rs | 22 +++- .../container/metrics/metrics.proto | 105 ++++++++++++++++++ .../container/metrics/metrics.rs | 23 ++++ .../workload_manager/container/metrics/mod.rs | 1 + .../src/workload_manager/container/mod.rs | 1 + 7 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 node-agent/build.rs create mode 100644 node-agent/src/workload_manager/container/metrics/metrics.proto create mode 100644 node-agent/src/workload_manager/container/metrics/metrics.rs create mode 100644 node-agent/src/workload_manager/container/metrics/mod.rs diff --git a/node-agent/build.rs b/node-agent/build.rs new file mode 100644 index 00000000..9db49a45 --- /dev/null +++ b/node-agent/build.rs @@ -0,0 +1,7 @@ +fn main() -> Result<(), Box> { + tonic_build::configure().compile( + &["src/workload_manager/container/metrics/metrics.proto"], + &["src/workload_manager/container/metrics"], + )?; + Ok(()) +} diff --git a/node-agent/src/main.rs b/node-agent/src/main.rs index bb5ea5a3..1a41fe65 100644 --- a/node-agent/src/main.rs +++ b/node-agent/src/main.rs @@ -3,6 +3,8 @@ mod workload_manager; use orka_proto::node_agent::Workload; use workload_manager::container::client::ContainerClient; +use crate::workload_manager::container::metrics::metrics::any_to_resource; + const CID: &str = "nginx"; #[tokio::main] @@ -26,6 +28,18 @@ async fn main() { println!("{:?}", response); + for _ in 0..10 { + let response = workload_manager.metrics(CID).await.unwrap(); + + for metric in response.into_inner().metrics { + let data = metric.data.unwrap(); + + println!("{:?}", any_to_resource(&data)); + } + + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + } + let signal = 9; workload_manager.kill(CID, signal).await.unwrap(); diff --git a/node-agent/src/workload_manager/container/client.rs b/node-agent/src/workload_manager/container/client.rs index 62e9ed84..40e75ed2 100644 --- a/node-agent/src/workload_manager/container/client.rs +++ b/node-agent/src/workload_manager/container/client.rs @@ -2,7 +2,7 @@ use containerd_client::{ connect, services::v1::{ containers_client::ContainersClient, tasks_client::TasksClient, - GetContainerRequest, GetContainerResponse, KillRequest, WaitRequest, WaitResponse, DeleteTaskRequest, DeleteContainerRequest, GetResponse, GetRequest, + GetContainerRequest, GetContainerResponse, KillRequest, WaitRequest, WaitResponse, DeleteTaskRequest, DeleteContainerRequest, GetResponse, GetRequest, MetricsRequest, MetricsResponse, }, with_namespace, }; @@ -97,6 +97,26 @@ impl ContainerClient { Ok(response) } + pub async fn metrics( + &mut self, + container_id: &str, + ) -> Result, ContainerClientError> { + let request = MetricsRequest { + filters: vec![format!("id=={}", container_id)], + }; + + let request = with_namespace!(request, NAMESPACE); + + let mut client = self.get_task_client().await?; + + let response = client + .metrics(request) + .await + .map_err(|status| ContainerClientError::GRPCError { status })?; + + Ok(response) + } + pub async fn pull_image_if_not_present( &mut self, image_name: &str, diff --git a/node-agent/src/workload_manager/container/metrics/metrics.proto b/node-agent/src/workload_manager/container/metrics/metrics.proto new file mode 100644 index 00000000..7cef7fd0 --- /dev/null +++ b/node-agent/src/workload_manager/container/metrics/metrics.proto @@ -0,0 +1,105 @@ +syntax = "proto3"; + +package metrics; + +option go_package = "github.com/containerd/cgroups/cgroup2/stats"; + +message Metrics { + PidsStat pids = 1; + CPUStat cpu = 2; + MemoryStat memory = 4; + RdmaStat rdma = 5; + IOStat io = 6; + repeated HugeTlbStat hugetlb = 7; + MemoryEvents memory_events = 8; +} + +message PidsStat { + uint64 current = 1; + uint64 limit = 2; +} + +message CPUStat { + uint64 usage_usec = 1; + uint64 user_usec = 2; + uint64 system_usec = 3; + uint64 nr_periods = 4; + uint64 nr_throttled = 5; + uint64 throttled_usec = 6; +} + +message MemoryStat { + uint64 anon = 1; + uint64 file = 2; + uint64 kernel_stack = 3; + uint64 slab = 4; + uint64 sock = 5; + uint64 shmem = 6; + uint64 file_mapped = 7; + uint64 file_dirty = 8; + uint64 file_writeback = 9; + uint64 anon_thp = 10; + uint64 inactive_anon = 11; + uint64 active_anon = 12; + uint64 inactive_file = 13; + uint64 active_file = 14; + uint64 unevictable = 15; + uint64 slab_reclaimable = 16; + uint64 slab_unreclaimable = 17; + uint64 pgfault = 18; + uint64 pgmajfault = 19; + uint64 workingset_refault = 20; + uint64 workingset_activate = 21; + uint64 workingset_nodereclaim = 22; + uint64 pgrefill = 23; + uint64 pgscan = 24; + uint64 pgsteal = 25; + uint64 pgactivate = 26; + uint64 pgdeactivate = 27; + uint64 pglazyfree = 28; + uint64 pglazyfreed = 29; + uint64 thp_fault_alloc = 30; + uint64 thp_collapse_alloc = 31; + uint64 usage = 32; + uint64 usage_limit = 33; + uint64 swap_usage = 34; + uint64 swap_limit = 35; +} + +message MemoryEvents { + uint64 low = 1; + uint64 high = 2; + uint64 max = 3; + uint64 oom = 4; + uint64 oom_kill = 5; +} + +message RdmaStat { + repeated RdmaEntry current = 1; + repeated RdmaEntry limit = 2; +} + +message RdmaEntry { + string device = 1; + uint32 hca_handles = 2; + uint32 hca_objects = 3; +} + +message IOStat { + repeated IOEntry usage = 1; +} + +message IOEntry { + uint64 major = 1; + uint64 minor = 2; + uint64 rbytes = 3; + uint64 wbytes = 4; + uint64 rios = 5; + uint64 wios = 6; +} + +message HugeTlbStat { + uint64 current = 1; + uint64 max = 2; + string pagesize = 3; +} \ No newline at end of file diff --git a/node-agent/src/workload_manager/container/metrics/metrics.rs b/node-agent/src/workload_manager/container/metrics/metrics.rs new file mode 100644 index 00000000..ca8bf17f --- /dev/null +++ b/node-agent/src/workload_manager/container/metrics/metrics.rs @@ -0,0 +1,23 @@ +use crate::workload_manager::container::metrics::metrics::metrics::Metrics; +use orka_proto::node_agent::workload_status::Resources; +use prost::{DecodeError, Message}; +use prost_types::Any; + +mod metrics { + tonic::include_proto!("metrics"); +} + +fn any_to_metrics(any: &Any) -> Result { + Metrics::decode(any.value.as_slice()) +} + +pub fn any_to_resource(any: &Any) -> Result { + match any_to_metrics(any) { + Ok(m) => Ok(Resources { + cpu: m.cpu.unwrap().usage_usec as i32, + memory: m.memory.unwrap().usage as i32, + disk: 0, // TODO!: implement for real + }), + Err(e) => Err(e), + } +} diff --git a/node-agent/src/workload_manager/container/metrics/mod.rs b/node-agent/src/workload_manager/container/metrics/mod.rs new file mode 100644 index 00000000..e1448832 --- /dev/null +++ b/node-agent/src/workload_manager/container/metrics/mod.rs @@ -0,0 +1 @@ +pub mod metrics; diff --git a/node-agent/src/workload_manager/container/mod.rs b/node-agent/src/workload_manager/container/mod.rs index f27e7610..daf6b91c 100644 --- a/node-agent/src/workload_manager/container/mod.rs +++ b/node-agent/src/workload_manager/container/mod.rs @@ -1,2 +1,3 @@ pub mod client; pub mod error; +pub mod metrics; From 70a664b7e959f0ff4897dab4c5e1d13fdbb6ce2b Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 14:52:10 +0200 Subject: [PATCH 6/8] feat(node-agent): implement node lifecycle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add method to connect to cluster and stream node status. Retries in case of the connection closing. Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- Cargo.lock | 115 ++++++++++++++++-- node-agent/Cargo.toml | 4 + node-agent/src/args.rs | 27 ++++ node-agent/src/main.rs | 110 ++++++++++++++++- node-agent/src/workload_manager/mod.rs | 1 + .../src/workload_manager/node/metrics.rs | 59 +++++++++ node-agent/src/workload_manager/node/mod.rs | 1 + 7 files changed, 308 insertions(+), 9 deletions(-) create mode 100644 node-agent/src/args.rs create mode 100644 node-agent/src/workload_manager/node/metrics.rs create mode 100644 node-agent/src/workload_manager/node/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 6822d151..14b220fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -263,13 +263,12 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c8d502cbaec4595d2e7d5f61e318f05417bd2b66fdc3809498f0d3fdf0bea27" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] @@ -284,9 +283,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.1" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5891c7bc0edb3e1c2204fc5e94009affabeb1821c9e5fdc3959536c5c0bb984d" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", @@ -296,9 +295,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.0" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9fd1a5729c4548118d7d70ff234a44868d00489a4b6597b0b020918a0e91a1a" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", @@ -337,6 +336,49 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "crossbeam-channel" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + [[package]] name = "deranged" version = "0.3.8" @@ -737,6 +779,15 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76fc44e2588d5b436dbc3c6cf62aef290f90dab6235744a93dfe1cc18f451e2c" +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "mime" version = "0.3.17" @@ -769,6 +820,15 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -838,11 +898,15 @@ name = "orka-node-agent" version = "0.1.0" dependencies = [ "anyhow", + "async-stream", + "clap", + "clap-verbosity-flag", "containerd-client", "orka-proto", "prost", "prost-types", "serde_json", + "sysinfo", "thiserror", "tokio", "tokio-stream", @@ -1128,6 +1192,28 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + [[package]] name = "rcgen" version = "0.11.1" @@ -1417,6 +1503,21 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sysinfo" +version = "0.29.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d0e9cc2273cc8d31377bdd638d72e3ac3e5607b18621062b169d02787f1bab" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi", + "once_cell", + "rayon", + "winapi", +] + [[package]] name = "tempfile" version = "3.8.0" diff --git a/node-agent/Cargo.toml b/node-agent/Cargo.toml index 86a6485b..bca819ba 100644 --- a/node-agent/Cargo.toml +++ b/node-agent/Cargo.toml @@ -19,6 +19,10 @@ tracing-subscriber = "0.3.17" tracing-log = "0.1.3" uuid = { version = "1.4.1", features = ["v4", "macro-diagnostics", "fast-rng"] } tower-http = { version = "0.4.3", features = ["trace"] } +clap = { version = "4.4.2", features = ["env", "derive"] } +clap-verbosity-flag = "2.0.1" +async-stream = "0.3.5" +sysinfo = "0.29.9" [build-dependencies] tonic-build = "0.9.2" diff --git a/node-agent/src/args.rs b/node-agent/src/args.rs new file mode 100644 index 00000000..084787c6 --- /dev/null +++ b/node-agent/src/args.rs @@ -0,0 +1,27 @@ +//! Command-line arguments. +use clap::Parser; +use clap_verbosity_flag::{InfoLevel, Verbosity}; + +/// Scheduler service for the Orka container orchestration system. +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +pub struct CliArguments { + #[arg(long, default_value_t = 3, env)] + pub lifecycle_retries: i32, + + /// The port to start the node agent on. + #[arg(long, default_value_t = 50052, env)] + pub node_agent_port: u16, + + /// The address of the scheduler to connect the node agent to. + #[arg(long, default_value = "[::]", env)] + pub scheduler_address: String, + + /// The port of the scheduler to connect the node agent to. + #[arg(long, default_value_t = 50051, env)] + pub scheduler_port: u16, + + /// Verbosity level. + #[command(flatten)] + pub verbose: Verbosity, +} diff --git a/node-agent/src/main.rs b/node-agent/src/main.rs index 1a41fe65..0d118723 100644 --- a/node-agent/src/main.rs +++ b/node-agent/src/main.rs @@ -1,9 +1,77 @@ +mod args; mod workload_manager; -use orka_proto::node_agent::Workload; +use clap::Parser; +use orka_proto::{node_agent::Workload, scheduler_agent::{lifecycle_service_client::LifecycleServiceClient, ConnectionRequest, status_update_service_client::StatusUpdateServiceClient}}; +use tracing::{info, error}; +use uuid::Uuid; use workload_manager::container::client::ContainerClient; +use anyhow::Result; +use tracing_log::AsTrace; + +use crate::{workload_manager::container::metrics::metrics::any_to_resource, args::CliArguments}; +use crate::workload_manager::node::metrics::stream_node_status; + +async fn execute_node_lifecycle( + node_id: Uuid, + node_agent_port: u16, + scheduler_connection_string: String, +) -> Result<()> { + info!( + "Connecting to scheduler on {}", + scheduler_connection_string + ); + + loop { + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; -use crate::workload_manager::container::metrics::metrics::any_to_resource; + let mut lifecycle_client = + match LifecycleServiceClient::connect(scheduler_connection_string.clone()).await { + Ok(client) => Ok(client), + Err(e) => { + error!("Failed to connect to scheduler: {:?}", e); + Err(e) + } + }?; + + match lifecycle_client + .join_cluster(ConnectionRequest { + id: node_id.to_string(), + port: node_agent_port as u32, + }) + .await + { + Ok(_) => Ok(()), + Err(e) => { + error!("Failed to join cluster: {:?}", e); + Err(e) + } + }?; + + info!("Joined cluster"); + + let mut client = + match StatusUpdateServiceClient::connect(scheduler_connection_string.clone()).await { + Ok(client) => Ok(client), + Err(e) => { + error!("Failed to connect to scheduler: {:?}", e); + Err(e) + } + }?; + + match stream_node_status(node_id, &mut client, 15).await { + Ok(_) => { + info!("Node status stream ended, retrying"); + } + Err(error) => { + error!( + "Node status stream failed: {:?}, reconnecting to scheduler", + error + ); + } + }; + } +} const CID: &str = "nginx"; @@ -51,4 +119,42 @@ async fn main() { Ok(_) => panic!("Workload should not exist"), Err(_) => println!("Workload does not exist"), }; + + let args = CliArguments::parse(); + + tracing_subscriber::fmt() + .with_max_level(args.verbose.log_level_filter().as_trace()) + .init(); + + info!( + app_name = env!("CARGO_PKG_NAME"), + app_version = env!("CARGO_PKG_VERSION"), + "Starting", + ); + + info!("Arguments: {:?}", args); + + let scheduler_connection_string = + format!("http://{}:{}", args.scheduler_address, args.scheduler_port); + + let node_id = Uuid::new_v4(); + + let retries = args.lifecycle_retries; + + for _ in 0..retries { + match execute_node_lifecycle( + node_id, + args.node_agent_port, + scheduler_connection_string.clone(), + ) + .await + { + Ok(_) => { + // will never be reached + } + Err(e) => { + error!("Failed to execute node lifecycle: {:?}", e); + } + } + } } diff --git a/node-agent/src/workload_manager/mod.rs b/node-agent/src/workload_manager/mod.rs index 18581c4b..41485bec 100644 --- a/node-agent/src/workload_manager/mod.rs +++ b/node-agent/src/workload_manager/mod.rs @@ -1 +1,2 @@ pub mod container; +pub mod node; diff --git a/node-agent/src/workload_manager/node/metrics.rs b/node-agent/src/workload_manager/node/metrics.rs new file mode 100644 index 00000000..2bfd1c7b --- /dev/null +++ b/node-agent/src/workload_manager/node/metrics.rs @@ -0,0 +1,59 @@ +use orka_proto::scheduler_agent::status_update_service_client::StatusUpdateServiceClient; +use sysinfo::{CpuExt, System, SystemExt}; + +use orka_proto::scheduler_agent::node_status::{CpuLoad, Memory}; +use orka_proto::scheduler_agent::NodeStatus; + +use anyhow::Result; +use tonic::Request; +use uuid::Uuid; + +fn get_node_status(node_id: &Uuid, system: &mut System) -> NodeStatus { + system.refresh_all(); + + let total_memory = system.total_memory(); + + let free_memory = system.free_memory(); + + let cpus = system.cpus(); + + let average_load = + cpus.iter().map(|cpu| cpu.cpu_usage() as f64).sum::() / cpus.len() as f64; + + let cpu_load = if average_load == f64::INFINITY { + None + } else { + Some(CpuLoad { load: average_load }) + }; + + NodeStatus { + id: node_id.to_string(), + memory: Some(Memory { + total: total_memory, + free: free_memory, + }), + cpu_load, + } +} + +pub async fn stream_node_status( + node_id: Uuid, + client: &mut StatusUpdateServiceClient, + interval_sec: u64, +) -> Result<()> { + let mut system = System::new(); + + let outbound = async_stream::stream! { + let mut interval = tokio::time::interval(std::time::Duration::from_secs(interval_sec)); + + loop { + let node_status = get_node_status(&node_id, &mut system); + yield node_status; + interval.tick().await; + } + }; + + let _ = client.update_node_status(Request::new(outbound)).await?; + + Ok(()) +} diff --git a/node-agent/src/workload_manager/node/mod.rs b/node-agent/src/workload_manager/node/mod.rs new file mode 100644 index 00000000..e1448832 --- /dev/null +++ b/node-agent/src/workload_manager/node/mod.rs @@ -0,0 +1 @@ +pub mod metrics; From 88c6e0dac595807d337d00bf302e72a3080f6b53 Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 15:40:32 +0200 Subject: [PATCH 7/8] feat(node-agent): implement gRPC server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- node-agent/src/args.rs | 11 +- node-agent/src/main.rs | 155 ++++++++++------- node-agent/src/workload_manager/grpc/mod.rs | 2 + .../grpc/scheduler_workload_service.rs | 164 ++++++++++++++++++ .../src/workload_manager/grpc/server.rs | 60 +++++++ node-agent/src/workload_manager/mod.rs | 1 + 6 files changed, 329 insertions(+), 64 deletions(-) create mode 100644 node-agent/src/workload_manager/grpc/mod.rs create mode 100644 node-agent/src/workload_manager/grpc/scheduler_workload_service.rs create mode 100644 node-agent/src/workload_manager/grpc/server.rs diff --git a/node-agent/src/args.rs b/node-agent/src/args.rs index 084787c6..174a68d2 100644 --- a/node-agent/src/args.rs +++ b/node-agent/src/args.rs @@ -9,9 +9,6 @@ pub struct CliArguments { #[arg(long, default_value_t = 3, env)] pub lifecycle_retries: i32, - /// The port to start the node agent on. - #[arg(long, default_value_t = 50052, env)] - pub node_agent_port: u16, /// The address of the scheduler to connect the node agent to. #[arg(long, default_value = "[::]", env)] @@ -21,6 +18,14 @@ pub struct CliArguments { #[arg(long, default_value_t = 50051, env)] pub scheduler_port: u16, + /// The address of the node agent for the scheduler to connect to. + #[arg(long, default_value = "[::]", env)] + pub node_agent_address: String, + + /// The port of the node agent for the scheduler to connect to. + #[arg(long, default_value_t = 50052, env)] + pub node_agent_port: u16, + /// Verbosity level. #[command(flatten)] pub verbose: Verbosity, diff --git a/node-agent/src/main.rs b/node-agent/src/main.rs index 0d118723..5e63e6ed 100644 --- a/node-agent/src/main.rs +++ b/node-agent/src/main.rs @@ -1,15 +1,18 @@ mod args; mod workload_manager; +use std::process::exit; + use clap::Parser; -use orka_proto::{node_agent::Workload, scheduler_agent::{lifecycle_service_client::LifecycleServiceClient, ConnectionRequest, status_update_service_client::StatusUpdateServiceClient}}; -use tracing::{info, error}; +use orka_proto::scheduler_agent::{lifecycle_service_client::LifecycleServiceClient, ConnectionRequest, status_update_service_client::StatusUpdateServiceClient, DisconnectionNotice}; +use tokio::sync::mpsc::{Sender, Receiver, self}; +use tracing::{info, error, warn}; use uuid::Uuid; -use workload_manager::container::client::ContainerClient; use anyhow::Result; use tracing_log::AsTrace; -use crate::{workload_manager::container::metrics::metrics::any_to_resource, args::CliArguments}; +use crate::workload_manager::grpc::server::GrpcServer; +use crate::args::CliArguments; use crate::workload_manager::node::metrics::stream_node_status; async fn execute_node_lifecycle( @@ -73,53 +76,8 @@ async fn execute_node_lifecycle( } } -const CID: &str = "nginx"; - #[tokio::main] async fn main() { - let mut workload_manager = ContainerClient::new("/var/run/containerd/containerd.sock").await.unwrap(); - - let workload = Workload { - instance_id: CID.to_string(), - image: "docker.io/library/nginx:latest".to_string(), - environment: vec!["FOO=BAR".to_string()], - ..Default::default() - }; - - workload_manager.create(&workload).await.unwrap(); - - let response = workload_manager.info(CID).await.unwrap(); - - println!("{:?}", response); - - let response = workload_manager.status(CID).await.unwrap(); - - println!("{:?}", response); - - for _ in 0..10 { - let response = workload_manager.metrics(CID).await.unwrap(); - - for metric in response.into_inner().metrics { - let data = metric.data.unwrap(); - - println!("{:?}", any_to_resource(&data)); - } - - tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; - } - - let signal = 9; - workload_manager.kill(CID, signal).await.unwrap(); - - workload_manager.wait(CID).await.unwrap(); - - workload_manager.cleanup(CID).await.unwrap(); - - match workload_manager.status(CID).await { - Ok(_) => panic!("Workload should not exist"), - Err(_) => println!("Workload does not exist"), - }; - let args = CliArguments::parse(); tracing_subscriber::fmt() @@ -139,22 +97,97 @@ async fn main() { let node_id = Uuid::new_v4(); - let retries = args.lifecycle_retries; + info!("Node ID: {}", node_id); - for _ in 0..retries { - match execute_node_lifecycle( - node_id, - args.node_agent_port, - scheduler_connection_string.clone(), - ) - .await - { - Ok(_) => { - // will never be reached + let (tx, mut rx): (Sender, Receiver) = mpsc::channel(1); + + let lifecycle_tx = tx.clone(); + let lifecycle_connection_string = scheduler_connection_string.clone(); + + // join scheduler and stream node status to scheduler, retrying on failure + tokio::spawn(async move { + let retries = args.lifecycle_retries; + + for _ in 0..retries { + match execute_node_lifecycle( + node_id, + args.node_agent_port, + lifecycle_connection_string.clone(), + ) + .await + { + Ok(_) => { + // will never be reached + } + Err(e) => { + error!("Failed to execute node lifecycle: {:?}", e); + } } + } + + error!(" + Node lifecycle failed, initiating graceful shutdown" + ); + + let _ = lifecycle_tx.send(1).await; + }); + + // start grpc server + tokio::spawn(async move { + error!("Starting gRPC server on {}:{}", + args.node_agent_address, + args.node_agent_port + ); + + let grpc = GrpcServer::new(args.node_agent_address, args.node_agent_port); + + let server = match grpc.map_err(|e| { + error!("Failed to create gRPC server: {:?}", e); + }) { + Ok(server) => server, Err(e) => { - error!("Failed to execute node lifecycle: {:?}", e); + error!("Failed to create gRPC server: {:?}", e); + let _ = tx.send(1).await; + exit(1); } + }; + + match server.start_server().await { + Ok(_) => {} + Err(e) => { + error!("Failed to start gRPC server: {:?}", e); + let _ = tx.send(1).await; + exit(1); + } + }; + }); + + let _ = rx.recv().await; + + info!("Exiting"); + + info!("Trying to quit cluster"); + + match LifecycleServiceClient::connect(scheduler_connection_string).await { + Err(error) => { + warn!("Failed connecting to scheduler when exiting {:?}", error) + } + Ok(mut client) => { + match client + .leave_cluster(DisconnectionNotice { + id: node_id.to_string(), + }) + .await + { + Ok(_) => { + info!("Successfully left cluster") + } + Err(error) => { + warn!("Failed existing cluster {:?}", error) + } + }; } } + + exit(1); } diff --git a/node-agent/src/workload_manager/grpc/mod.rs b/node-agent/src/workload_manager/grpc/mod.rs new file mode 100644 index 00000000..733483fc --- /dev/null +++ b/node-agent/src/workload_manager/grpc/mod.rs @@ -0,0 +1,2 @@ +pub mod scheduler_workload_service; +pub mod server; diff --git a/node-agent/src/workload_manager/grpc/scheduler_workload_service.rs b/node-agent/src/workload_manager/grpc/scheduler_workload_service.rs new file mode 100644 index 00000000..351ad63e --- /dev/null +++ b/node-agent/src/workload_manager/grpc/scheduler_workload_service.rs @@ -0,0 +1,164 @@ +use crate::workload_manager::container::client::ContainerClient; +use crate::workload_manager::container::error::into_tonic_status; +use crate::workload_manager::container::metrics::metrics::any_to_resource; +use orka_proto::node_agent::workload_service_server::WorkloadService; +use orka_proto::node_agent::workload_signal::Signal; +use orka_proto::node_agent::{workload_status, Empty, Workload, WorkloadSignal, WorkloadStatus}; +use tokio_stream::wrappers::ReceiverStream; +use tonic::{Request, Response, Result, Status}; +use tracing::debug; + +pub struct WorkloadSvc {} + +impl WorkloadSvc { + /// Create a new `WorkloadService` gRPC service manager. + pub fn new() -> Self { + Self {} + } +} + +#[tonic::async_trait] +impl WorkloadService for WorkloadSvc { + type CreateStream = ReceiverStream>; + + async fn create( + &self, + request: Request, + ) -> Result, Status> { + let workload = request.into_inner(); + let mut client = match ContainerClient::new("/var/run/containerd/containerd.sock").await { + Ok(x) => x, + Err(e) => { + return Err(Status::new( + tonic::Code::Internal, + format!("Failed to create container client{:?}", e), + )) + } + }; + + let container = match client.create(&workload).await { + Ok(x) => x, + Err(e) => { + return Err(Status::new( + tonic::Code::Internal, + format!("Failed to create container: {:?}", e), + )) + } + } + .into_inner(); + + let (tx, rx) = tokio::sync::mpsc::channel(4); + tokio::spawn(async move { + loop { + let metrics = match client.metrics(&container.container_id).await { + Ok(x) => x, + Err(e) => { + return Status::new( + tonic::Code::Internal, + format!("Failed to get container info: {:?}", e), + ) + } + } + .into_inner() + .metrics; + + let status = match client.status(&container.container_id).await { + Ok(x) => x, + Err(e) => { + return Status::new( + tonic::Code::Internal, + format!("Failed to get container info: {:?}", e), + ) + } + } + .into_inner() + .process; + + for metric in metrics { + let data = metric.data.unwrap(); + let resource = any_to_resource(&data); + let status_code = containerd_client::types::v1::Status::from_i32( + status.clone().unwrap().status, + ) + .unwrap(); + let workload_status = WorkloadStatus { + instance_id: workload.instance_id.clone(), + status: Some(workload_status::Status { + code: match status_code { + containerd_client::types::v1::Status::Running => { + workload_status::status::StatusCode::Running as i32 + } + containerd_client::types::v1::Status::Stopped => { + workload_status::status::StatusCode::Terminated as i32 + } + _ => workload_status::status::StatusCode::Waiting as i32, + }, + ..Default::default() + }), + resource_usage: resource.ok(), + }; + match tx.send(Ok(workload_status)).await { + Ok(x) => x, + Err(e) => { + return Status::new( + tonic::Code::Internal, + format!("Failed to send workload status: {:?}", e), + ) + } + }; + } + tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + } + }); + + Ok(Response::new(ReceiverStream::new(rx))) + } + + async fn signal(&self, request: Request) -> Result, Status> { + let workload_signal = request.into_inner(); + + let mut client = ContainerClient::new("/var/run/containerd/containerd.sock") + .await + .map_err(|error| { + Status::new( + tonic::Code::Internal, + format!("Failed to create container client{:?}", error), + ) + })?; + + let signal = if workload_signal.signal == Signal::Stop as i32 { + sysinfo::Signal::Quit + } else { + sysinfo::Signal::Kill + }; + + // kill task + client + .kill(&workload_signal.instance_id, signal as u32) + .await + .map_err(|error| { + debug!("Failed to kill container {:?}", error); + into_tonic_status(error) + })?; + + // wait for container to stop + client + .wait(&workload_signal.instance_id) + .await + .map_err(|error| { + debug!("Failed to wait for container {:?}", error); + into_tonic_status(error) + })?; + + // cleanup container + client + .cleanup(&workload_signal.instance_id) + .await + .map_err(|error| { + debug!("Failed to cleanup container {:?}", error); + into_tonic_status(error) + })?; + + Ok(Response::new(Empty {})) + } +} diff --git a/node-agent/src/workload_manager/grpc/server.rs b/node-agent/src/workload_manager/grpc/server.rs new file mode 100644 index 00000000..565e8a21 --- /dev/null +++ b/node-agent/src/workload_manager/grpc/server.rs @@ -0,0 +1,60 @@ +//! The gRPC server for interacting with the Orka scheduler. + +use std::net::SocketAddr; + +use anyhow::{Context, Result}; +use orka_proto::node_agent::workload_service_server::WorkloadServiceServer; +use tonic::transport::Server; +use tower_http::trace::TraceLayer; +use tracing::{event, Level}; + +use super::scheduler_workload_service::WorkloadSvc; + +/// The gRPC server manager for the scheduler. +pub struct GrpcServer { + /// The address to bind the gRPC server to. + bind_socket_address: SocketAddr, +} + +impl GrpcServer { + /// Create a gRPC server manager. + /// + /// # Arguments + /// + /// * `bind_address` - The address to bind the gRPC server to. + /// * `bind_port` - The port to bind the gRPC server to. + pub fn new(bind_address: String, bind_port: u16) -> Result { + let bind_socket_address = format!("{}:{}", bind_address, bind_port) + .parse() + .with_context(|| { + format!( + "Unable to parse the gRPC bind address: bind_address={:?}, bind_port={:?}", + bind_address, bind_port + ) + })?; + + Ok(Self { + bind_socket_address, + }) + } + + /// Start the gRPC server. + pub async fn start_server(&self) -> Result<()> { + // Configure the server + event!(Level::INFO, bind_address = %self.bind_socket_address, "Starting gRPC server"); + + let mut server_builder = Server::builder().layer(TraceLayer::new_for_grpc()); + + // Configure the router + let router = server_builder.add_service(WorkloadServiceServer::new(WorkloadSvc::new())); + + event!(Level::DEBUG, "The gRPC server was configured successfully"); + + router + .serve(self.bind_socket_address) + .await + .with_context(|| "An error occurred while serving gRPC requests")?; + + Ok(()) + } +} diff --git a/node-agent/src/workload_manager/mod.rs b/node-agent/src/workload_manager/mod.rs index 41485bec..200aca89 100644 --- a/node-agent/src/workload_manager/mod.rs +++ b/node-agent/src/workload_manager/mod.rs @@ -1,2 +1,3 @@ pub mod container; +pub mod grpc; pub mod node; From cd288606ebe2245ba2e151d8f85fd58db896f16a Mon Sep 17 00:00:00 2001 From: Martin Moreira de Jesus Date: Fri, 1 Sep 2023 15:40:47 +0200 Subject: [PATCH 8/8] feat(node-agent): add cni MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add cni and format code Signed-off-by: Martin Moreira de Jesus Signed-off-by: Noé Tarbouriech Co-Authored-By: Noé Tarbouriech --- node-agent/src/args.rs | 3 ++ node-agent/src/main.rs | 32 ++++++++++--------- .../src/workload_manager/container/client.rs | 14 ++++++-- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/node-agent/src/args.rs b/node-agent/src/args.rs index 174a68d2..aa56a2db 100644 --- a/node-agent/src/args.rs +++ b/node-agent/src/args.rs @@ -9,6 +9,9 @@ pub struct CliArguments { #[arg(long, default_value_t = 3, env)] pub lifecycle_retries: i32, + /// Enable the orka CNI in containerd. + #[arg(long, default_value_t = false, env)] + pub cni: bool, /// The address of the scheduler to connect the node agent to. #[arg(long, default_value = "[::]", env)] diff --git a/node-agent/src/main.rs b/node-agent/src/main.rs index 5e63e6ed..1acd3c8c 100644 --- a/node-agent/src/main.rs +++ b/node-agent/src/main.rs @@ -3,16 +3,20 @@ mod workload_manager; use std::process::exit; -use clap::Parser; -use orka_proto::scheduler_agent::{lifecycle_service_client::LifecycleServiceClient, ConnectionRequest, status_update_service_client::StatusUpdateServiceClient, DisconnectionNotice}; -use tokio::sync::mpsc::{Sender, Receiver, self}; -use tracing::{info, error, warn}; -use uuid::Uuid; use anyhow::Result; +use clap::Parser; +use orka_proto::scheduler_agent::{ + lifecycle_service_client::LifecycleServiceClient, + status_update_service_client::StatusUpdateServiceClient, ConnectionRequest, + DisconnectionNotice, +}; +use tokio::sync::mpsc::{self, Receiver, Sender}; +use tracing::{error, info, warn}; use tracing_log::AsTrace; +use uuid::Uuid; -use crate::workload_manager::grpc::server::GrpcServer; use crate::args::CliArguments; +use crate::workload_manager::grpc::server::GrpcServer; use crate::workload_manager::node::metrics::stream_node_status; async fn execute_node_lifecycle( @@ -20,10 +24,7 @@ async fn execute_node_lifecycle( node_agent_port: u16, scheduler_connection_string: String, ) -> Result<()> { - info!( - "Connecting to scheduler on {}", - scheduler_connection_string - ); + info!("Connecting to scheduler on {}", scheduler_connection_string); loop { tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; @@ -100,7 +101,7 @@ async fn main() { info!("Node ID: {}", node_id); let (tx, mut rx): (Sender, Receiver) = mpsc::channel(1); - + let lifecycle_tx = tx.clone(); let lifecycle_connection_string = scheduler_connection_string.clone(); @@ -125,7 +126,8 @@ async fn main() { } } - error!(" + error!( + " Node lifecycle failed, initiating graceful shutdown" ); @@ -134,9 +136,9 @@ async fn main() { // start grpc server tokio::spawn(async move { - error!("Starting gRPC server on {}:{}", - args.node_agent_address, - args.node_agent_port + error!( + "Starting gRPC server on {}:{}", + args.node_agent_address, args.node_agent_port ); let grpc = GrpcServer::new(args.node_agent_address, args.node_agent_port); diff --git a/node-agent/src/workload_manager/container/client.rs b/node-agent/src/workload_manager/container/client.rs index 40e75ed2..849abd0f 100644 --- a/node-agent/src/workload_manager/container/client.rs +++ b/node-agent/src/workload_manager/container/client.rs @@ -1,8 +1,10 @@ +use clap::Parser; use containerd_client::{ connect, services::v1::{ - containers_client::ContainersClient, tasks_client::TasksClient, - GetContainerRequest, GetContainerResponse, KillRequest, WaitRequest, WaitResponse, DeleteTaskRequest, DeleteContainerRequest, GetResponse, GetRequest, MetricsRequest, MetricsResponse, + containers_client::ContainersClient, tasks_client::TasksClient, DeleteContainerRequest, + DeleteTaskRequest, GetContainerRequest, GetContainerResponse, GetRequest, GetResponse, + KillRequest, MetricsRequest, MetricsResponse, WaitRequest, WaitResponse, }, with_namespace, }; @@ -12,6 +14,7 @@ use tonic::{Request, Status}; use super::error::ContainerClientError; +use crate::args::CliArguments; use orka_proto::node_agent::Workload; const NAMESPACE: &str = "default"; @@ -172,9 +175,16 @@ impl ContainerClient { .iter() .map(|value| format!("--env={}", value)); + let cni = if CliArguments::parse().cni { + vec!["--cni"] + } else { + vec![] + }; + // TODO - use containerd library to create container instead of ctr let command = Command::new("ctr") .arg("run") + .args(cni.as_slice()) .arg("--detach") .args(env) .arg(&workload.image)