diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 2af5418..4b6d4e9 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -4,6 +4,7 @@ :262: https://github.com/stackabletech/agent/pull/262[#262] :267: https://github.com/stackabletech/agent/pull/267[#267] +:270: https://github.com/stackabletech/agent/pull/270[#270] === Changed * Lazy validation of repository URLs changed to eager validation @@ -11,6 +12,7 @@ * `certificates.k8s.io/v1` used instead of `certificates.k8s.io/v1beta1` so that the Stackable Agent is now compatible with Kubernetes v1.22 but not any longer with versions prior to v1.19 ({267}). +* Prints self-diagnostic information on startup ({270}) == 0.5.0 - 2021-07-26 diff --git a/Cargo.lock b/Cargo.lock index cc84ca6..8f68f7a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -281,6 +281,17 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1522ac6ee801a11bf9ef3f80403f4ede6eb41291fac3dde3de09989679305f25" +[[package]] +name = "built" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f346b6890a0dfa7266974910e7df2d5088120dd54721b9b0e5aae1ae5e05715" +dependencies = [ + "cargo-lock", + "chrono", + "git2", +] + [[package]] name = "bumpalo" version = "3.7.0" @@ -327,11 +338,26 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" +[[package]] +name = "cargo-lock" +version = "7.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb04b88bd5b2036e30704f95c6ee16f3b5ca3b4ca307da2889d9006648e5c88" +dependencies = [ + "semver 1.0.4", + "serde", + "toml", + "url 2.2.2", +] + [[package]] name = "cc" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -916,6 +942,19 @@ dependencies = [ "wasi 0.10.0+wasi-snapshot-preview1", ] +[[package]] +name = "git2" +version = "0.13.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "659cd14835e75b64d9dba5b660463506763cf0aa6cb640aeeb0e98d841093490" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "url 2.2.2", +] + [[package]] name = "h2" version = "0.3.3" @@ -1239,6 +1278,15 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "jobserver" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.51" @@ -1484,6 +1532,18 @@ version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f823d141fe0a24df1e23b4af4e3c7ba9e5966ec514ea068c93024aa7deb765" +[[package]] +name = "libgit2-sys" +version = "0.12.22+1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89c53ac117c44f7042ad8d8f5681378dfbc6010e49ec2c0d1f11dfedc7a4a1c3" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + [[package]] name = "libsystemd-sys" version = "0.9.0" @@ -1495,6 +1555,18 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "libz-sys" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linked-hash-map" version = "0.5.4" @@ -2526,6 +2598,9 @@ name = "semver" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" +dependencies = [ + "serde", +] [[package]] name = "semver-parser" @@ -2750,6 +2825,7 @@ dependencies = [ "Inflector", "anyhow", "async-trait", + "built", "byteorder", "dirs", "env_logger 0.9.0", diff --git a/Cargo.toml b/Cargo.toml index aa9b180..fb5788c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ edition = "2018" license = "Apache-2.0" name = "stackable-agent" version = "0.6.0-nightly" +build = "build.rs" [dependencies] # We are currently referencing the Krustlet directly from a Stackable fork of the official repository. @@ -52,6 +53,9 @@ indoc = "1.0" rstest = "0.11" serde_yaml = "0.8" +[build-dependencies] +built = { version = "0.5", features = ["chrono", "git2"] } + [profile.release] opt-level = "s" lto = true diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..d8f91cb --- /dev/null +++ b/build.rs @@ -0,0 +1,3 @@ +fn main() { + built::write_built_file().expect("Failed to acquire build-time information"); +} diff --git a/src/bin/stackable-agent.rs b/src/bin/stackable-agent.rs index 29d066b..560aed0 100644 --- a/src/bin/stackable-agent.rs +++ b/src/bin/stackable-agent.rs @@ -9,6 +9,29 @@ use stackable_config::ConfigBuilder; use stackable_agent::config::AgentConfig; use stackable_agent::provider::StackableProvider; +mod built_info { + // The file has been placed there by the build script. + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + +pub fn print_startup_string( + pkg_version: &str, + git_version: Option<&str>, + target: &str, + built_time: &str, + rustc_version: &str, +) { + let git_information = match git_version { + None => "".to_string(), + Some(git) => format!(" (Git information: {})", git), + }; + info!("Starting the Stackable Agent"); + info!( + "This is version {}{}, built for {} by {} at {}", + pkg_version, git_information, target, rustc_version, built_time + ) +} + #[tokio::main] async fn main() -> anyhow::Result<()> { // Initialize the logger @@ -18,6 +41,15 @@ async fn main() -> anyhow::Result<()> { ConfigBuilder::build(env::args_os().collect::>(), "CONFIG_FILE") .expect("Error initializing Configuration!"); + // Make sure to only print diagnostic information once we are actually trying to start + print_startup_string( + built_info::PKG_VERSION, + built_info::GIT_VERSION, + built_info::TARGET, + built_info::BUILT_TIME_UTC, + built_info::RUSTC_VERSION, + ); + // Currently the only way to _properly_ configure the Krustlet is via these environment exports, // as their config object only offers methods that parse from command line flags (or combinations // of those flags with other things).