From cc6bd5691e762d4d8fcf07d280beb243fdc97ba4 Mon Sep 17 00:00:00 2001 From: xeniape Date: Thu, 15 May 2025 11:18:59 +0200 Subject: [PATCH 01/18] add progress reporting to stackablectl --- Cargo.lock | 89 +++++++++++++++++-- Cargo.toml | 2 + rust/stackable-cockpit/Cargo.toml | 2 + .../src/engine/docker/mod.rs | 5 +- rust/stackable-cockpit/src/engine/kind/mod.rs | 16 +++- .../src/engine/minikube/mod.rs | 7 +- rust/stackable-cockpit/src/helm.rs | 14 ++- rust/stackable-cockpit/src/oci.rs | 15 +++- .../src/platform/demo/spec.rs | 8 +- .../src/platform/manifests.rs | 5 +- .../src/platform/operator/mod.rs | 32 +++++-- .../src/platform/release/spec.rs | 44 +++++++-- .../src/platform/stack/spec.rs | 9 +- .../src/platform/stacklet/mod.rs | 13 +-- rust/stackable-cockpit/src/utils/check.rs | 6 +- .../stackable-cockpit/src/utils/k8s/client.rs | 17 ++-- rust/stackable-cockpit/src/utils/params.rs | 55 +++++++----- rust/stackable-cockpitd/src/handlers/ui.rs | 13 +-- rust/stackablectl/Cargo.toml | 4 +- rust/stackablectl/src/cli/mod.rs | 8 +- rust/stackablectl/src/cmds/cache.rs | 10 ++- rust/stackablectl/src/cmds/demo.rs | 21 +++-- rust/stackablectl/src/cmds/operator.rs | 18 +++- rust/stackablectl/src/cmds/release.rs | 17 +++- rust/stackablectl/src/cmds/stack.rs | 20 +++-- rust/stackablectl/src/cmds/stacklet.rs | 10 ++- rust/stackablectl/src/main.rs | 38 +++++--- rust/xtask/src/openapi.rs | 9 +- 28 files changed, 387 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba811d48..ae421883 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,7 +82,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "220044e6a1bb31ddee4e3db724d29767f352de47445a6cd75e1a173142136c83" dependencies = [ "nom", - "vte", + "vte 0.10.1", ] [[package]] @@ -155,6 +155,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "async-broadcast" version = "0.7.1" @@ -665,7 +671,7 @@ dependencies = [ "crossterm", "strum 0.26.3", "strum_macros 0.26.4", - "unicode-width", + "unicode-width 0.1.13", ] [[package]] @@ -686,7 +692,7 @@ dependencies = [ "encode_unicode", "lazy_static", "libc", - "unicode-width", + "unicode-width 0.1.13", "windows-sys 0.52.0", ] @@ -1641,6 +1647,20 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width 0.2.0", + "vt100", + "web-time", +] + [[package]] name = "inout" version = "0.1.3" @@ -1896,7 +1916,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -2083,6 +2103,12 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "numtoa" version = "0.1.0" @@ -2394,6 +2420,12 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "portable-atomic" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" + [[package]] name = "powerfmt" version = "0.2.0" @@ -3267,6 +3299,7 @@ dependencies = [ "futures", "helm-sys", "indexmap 2.5.0", + "indicatif", "k8s-openapi", "kube", "rand 0.8.5", @@ -3282,6 +3315,7 @@ dependencies = [ "tera", "tokio", "tracing", + "tracing-indicatif", "url", "urlencoding", "utoipa", @@ -3438,6 +3472,7 @@ dependencies = [ "dotenvy", "futures", "indexmap 2.5.0", + "indicatif", "lazy_static", "libc", "rand 0.8.5", @@ -3453,6 +3488,7 @@ dependencies = [ "termion", "tokio", "tracing", + "tracing-indicatif", "tracing-subscriber", "urlencoding", ] @@ -3930,6 +3966,18 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-indicatif" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8201ca430e0cd893ef978226fd3516c06d9c494181c8bf4e5b32e30ed4b40aa1" +dependencies = [ + "indicatif", + "tracing", + "tracing-core", + "tracing-subscriber", +] + [[package]] name = "tracing-log" version = "0.2.0" @@ -4117,6 +4165,12 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.5" @@ -4228,13 +4282,36 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "vt100" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84cd863bf0db7e392ba3bd04994be3473491b31e66340672af5d11943c6274de" +dependencies = [ + "itoa", + "log", + "unicode-width 0.1.13", + "vte 0.11.1", +] + [[package]] name = "vte" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6cbce692ab4ca2f1f3047fcf732430249c0e971bfdd2b234cf2c47ad93af5983" dependencies = [ - "arrayvec", + "arrayvec 0.5.2", + "utf8parse", + "vte_generate_state_changes", +] + +[[package]] +name = "vte" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5022b5fbf9407086c180e9557be968742d839e68346af7792b8592489732197" +dependencies = [ + "arrayvec 0.7.6", "utf8parse", "vte_generate_state_changes", ] @@ -4413,7 +4490,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 7c48e18d..800e4df1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ directories = "5.0" dotenvy = "0.15" futures = "0.3" indexmap = { version = "2.2", features = ["serde"] } +indicatif = "0.17.11" k8s-openapi = { version = "0.24", default-features = false, features = ["v1_32"] } kube = { version = "0.99", default-features = false, features = ["client", "rustls-tls", "ws", "socks5", "http-proxy"] } lazy_static = "1.5" @@ -54,6 +55,7 @@ termion = "4.0" tokio = { version = "1.38", features = ["rt-multi-thread", "macros", "fs", "process", "io-std"] } tower-http = { version = "0.5", features = ["validate-request"] } tracing = "0.1" +tracing-indicatif = "0.3.9" tracing-subscriber = "0.3" url = "2.5" urlencoding = "2.1.3" diff --git a/rust/stackable-cockpit/Cargo.toml b/rust/stackable-cockpit/Cargo.toml index 87380fb8..1decc06f 100644 --- a/rust/stackable-cockpit/Cargo.toml +++ b/rust/stackable-cockpit/Cargo.toml @@ -31,11 +31,13 @@ stackable-operator.workspace = true tera.workspace = true tokio.workspace = true tracing.workspace = true +tracing-indicatif.workspace = true url.workspace = true urlencoding.workspace = true utoipa = { workspace = true, optional = true } which.workspace = true futures.workspace = true +indicatif.workspace = true [dev-dependencies] rstest.workspace = true diff --git a/rust/stackable-cockpit/src/engine/docker/mod.rs b/rust/stackable-cockpit/src/engine/docker/mod.rs index 697b0797..be248000 100644 --- a/rust/stackable-cockpit/src/engine/docker/mod.rs +++ b/rust/stackable-cockpit/src/engine/docker/mod.rs @@ -1,8 +1,10 @@ use std::process::Stdio; +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use tokio::process::Command; -use tracing::{debug, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; type Result = std::result::Result; @@ -22,6 +24,7 @@ pub enum Error { #[instrument(skip_all)] pub async fn check_if_docker_is_running() -> Result<()> { debug!("Checking if Docker is running"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if Command::new("docker") .arg("info") diff --git a/rust/stackable-cockpit/src/engine/kind/mod.rs b/rust/stackable-cockpit/src/engine/kind/mod.rs index eabe318e..4dc7457d 100644 --- a/rust/stackable-cockpit/src/engine/kind/mod.rs +++ b/rust/stackable-cockpit/src/engine/kind/mod.rs @@ -1,8 +1,10 @@ use std::process::Stdio; +use indicatif::ProgressStyle; use snafu::{OptionExt, ResultExt, Snafu, ensure}; use tokio::{io::AsyncWriteExt, process::Command}; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ engine::{ @@ -67,6 +69,7 @@ impl Cluster { #[instrument(skip_all)] pub async fn create(&self) -> Result<()> { info!("Creating local cluster using kind"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Check if required binaries are present if let Some(binary) = binaries_present_with_name(&["docker", "kind"]) { @@ -112,6 +115,7 @@ impl Cluster { #[instrument(skip_all)] pub async fn create_if_not_exists(&self) -> Result<()> { info!("Creating cluster if it doesn't exist using kind"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if Self::check_if_cluster_exists(&self.name).await? { return Ok(()); @@ -134,6 +138,7 @@ impl Cluster { #[instrument(skip_all)] async fn check_if_cluster_exists(cluster_name: &str) -> Result { debug!("Checking if kind cluster exists"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let output = Command::new("kind") .args(["get", "clusters"]) @@ -141,9 +146,12 @@ impl Cluster { .await .context(CommandFailedToRunSnafu)?; - ensure!(output.status.success(), CommandErroredOutSnafu { - error: String::from_utf8_lossy(&output.stderr) - }); + ensure!( + output.status.success(), + CommandErroredOutSnafu { + error: String::from_utf8_lossy(&output.stderr) + } + ); let output = String::from_utf8_lossy(&output.stdout); Ok(output.lines().any(|name| name == cluster_name)) diff --git a/rust/stackable-cockpit/src/engine/minikube/mod.rs b/rust/stackable-cockpit/src/engine/minikube/mod.rs index dab6e959..668268f8 100644 --- a/rust/stackable-cockpit/src/engine/minikube/mod.rs +++ b/rust/stackable-cockpit/src/engine/minikube/mod.rs @@ -1,6 +1,8 @@ +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use tokio::process::Command; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ engine::docker::{self, check_if_docker_is_running}, @@ -44,6 +46,7 @@ impl Cluster { #[instrument(skip_all)] pub async fn create(&self) -> Result<(), Error> { info!("Creating local cluster using Minikube"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Check if required binaries are present if let Some(binary) = binaries_present_with_name(&["docker", "minikube"]) { @@ -73,6 +76,7 @@ impl Cluster { #[instrument(skip_all)] pub async fn create_if_not_exists(&self) -> Result<(), Error> { info!("Creating cluster if it doesn't exist using Minikube"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if Self::check_if_cluster_exists(&self.name).await? { return Ok(()); @@ -95,6 +99,7 @@ impl Cluster { #[instrument(skip_all)] async fn check_if_cluster_exists(cluster_name: &str) -> Result { debug!("Checking if Minikube cluster exists"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let output = Command::new("minikube") .arg("status") diff --git a/rust/stackable-cockpit/src/helm.rs b/rust/stackable-cockpit/src/helm.rs index cd219166..ede6741f 100644 --- a/rust/stackable-cockpit/src/helm.rs +++ b/rust/stackable-cockpit/src/helm.rs @@ -1,9 +1,11 @@ use std::fmt::Display; +use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::block_in_place; -use tracing::{debug, error, info, instrument}; +use tracing::{Span, debug, error, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use url::Url; use crate::{ @@ -195,6 +197,8 @@ pub fn install_release_from_repo_or_registry( namespace: &str, suppress_output: bool, ) -> Result { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + // Ideally, each Helm invocation would spawn_blocking instead in/around helm_sys, // but that requires a larger refactoring block_in_place(|| { @@ -270,6 +274,8 @@ fn install_release( namespace: &str, suppress_output: bool, ) -> Result<(), Error> { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + let result = helm_sys::install_helm_release( release_name, chart_name, @@ -304,6 +310,7 @@ pub fn uninstall_release( suppress_output: bool, ) -> Result { debug!("Uninstall Helm release"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if check_release_exists(release_name, namespace)? { let result = helm_sys::uninstall_helm_release(release_name, namespace, suppress_output); @@ -336,6 +343,7 @@ pub fn uninstall_release( #[instrument] pub fn check_release_exists(release_name: &str, namespace: &str) -> Result { debug!("Check if Helm release exists"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // TODO (Techassi): Handle error Ok(helm_sys::check_helm_release_exists(release_name, namespace)) @@ -345,6 +353,7 @@ pub fn check_release_exists(release_name: &str, namespace: &str) -> Result Result, Error> { debug!("List Helm releases"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let result = helm_sys::list_helm_releases(namespace); @@ -364,6 +373,7 @@ pub fn list_releases(namespace: &str) -> Result, Error> { #[instrument] pub fn get_release(release_name: &str, namespace: &str) -> Result, Error> { debug!("Get Helm release"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); Ok(list_releases(namespace)? .into_iter() @@ -374,6 +384,7 @@ pub fn get_release(release_name: &str, namespace: &str) -> Result Result<(), Error> { debug!("Add Helm repo"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let result = helm_sys::add_helm_repository(repository_name, repository_url); @@ -396,6 +407,7 @@ where T: AsRef + std::fmt::Display + std::fmt::Debug, { debug!("Get Helm repo index file"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let url = Url::parse(repo_url.as_ref()).context(UrlParseSnafu)?; let url = url.join(HELM_REPO_INDEX_FILE).context(UrlParseSnafu)?; diff --git a/rust/stackable-cockpit/src/oci.rs b/rust/stackable-cockpit/src/oci.rs index 5e350bd3..38a50775 100644 --- a/rust/stackable-cockpit/src/oci.rs +++ b/rust/stackable-cockpit/src/oci.rs @@ -1,8 +1,10 @@ use std::collections::HashMap; +use indicatif::ProgressStyle; use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; -use tracing::{debug, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use url::Url; use urlencoding::encode; @@ -120,6 +122,8 @@ impl OciUrlExt for Url { // TODO (@NickLarsenNZ): Look into why a HashMap is used here when the key is inside each entry in the value #[instrument] pub async fn get_oci_index<'a>() -> Result, Error> { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + let mut source_index_files: HashMap<&str, ChartSourceMetadata> = HashMap::new(); // initialize map @@ -128,9 +132,12 @@ pub async fn get_oci_index<'a>() -> Result HELM_REPO_NAME_TEST, HELM_REPO_NAME_DEV, ] { - source_index_files.insert(repo_name, ChartSourceMetadata { - entries: HashMap::new(), - }); + source_index_files.insert( + repo_name, + ChartSourceMetadata { + entries: HashMap::new(), + }, + ); } let base_url = format!("https://{HELM_OCI_BASE}/api/v2.0"); diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 75efd265..b058e0a1 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -1,6 +1,8 @@ +use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; -use tracing::{debug, info, instrument, warn}; +use tracing::{Span, debug, info, instrument, warn}; +use tracing_indicatif::span_ext::IndicatifSpanExt; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -98,6 +100,7 @@ impl DemoSpec { #[instrument(skip_all)] pub async fn check_prerequisites(&self, client: &Client, namespace: &str) -> Result<(), Error> { debug!("Checking prerequisites before installing demo"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Returns an error if the demo doesn't support to be installed in the // requested namespace @@ -142,6 +145,8 @@ impl DemoSpec { client: &Client, transfer_client: &xfer::Client, ) -> Result<(), Error> { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + // Get the stack spec based on the name defined in the demo spec let stack = stack_list.get(&self.stack).context(NoSuchStackSnafu { name: self.stack.clone(), @@ -189,6 +194,7 @@ impl DemoSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let params = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 7a5df63a..423c2fa1 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -1,8 +1,10 @@ use std::collections::HashMap; +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_operator::kvp::Labels; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ common::manifest::ManifestSpec, @@ -73,6 +75,7 @@ pub trait InstallManifestsExt { transfer_client: &xfer::Client, ) -> Result<(), Error> { debug!("Installing manifests"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut parameters = parameters.clone(); // We add the NAMESPACE parameter, so that stacks/demos can use that to render e.g. the diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index 965afe37..44010684 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -1,9 +1,11 @@ use std::{fmt::Display, str::FromStr}; +use indicatif::ProgressStyle; use semver::Version; use serde::Serialize; use snafu::{ResultExt, Snafu, ensure}; -use tracing::{info, instrument}; +use tracing::{Span, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ constants::{ @@ -61,10 +63,15 @@ pub struct OperatorSpec { impl Display for OperatorSpec { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}{}", self.name, match &self.version { - Some(v) => format!("={v}"), - None => "".into(), - }) + write!( + f, + "{}{}", + self.name, + match &self.version { + Some(v) => format!("={v}"), + None => "".into(), + } + ) } } @@ -86,9 +93,10 @@ impl FromStr for OperatorSpec { ensure!(len <= 2, InvalidEqualSignCountSnafu); // Check if the provided operator name is in the list of valid operators - ensure!(VALID_OPERATORS.contains(&parts[0]), InvalidNameSnafu { - name: parts[0] - }); + ensure!( + VALID_OPERATORS.contains(&parts[0]), + InvalidNameSnafu { name: parts[0] } + ); // If there is only one part, the input didn't include // the optional version identifier @@ -185,7 +193,8 @@ impl OperatorSpec { namespace: &str, chart_source: &ChartSourceType, ) -> Result<(), helm::Error> { - info!(operator = %self, "Installing operator"); + Span::current().pb_set_message(format!("Installing {}-operator", self.name).as_str()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").unwrap()); let version = self.version.as_ref().map(|v| v.to_string()); let helm_name = self.helm_name(); @@ -210,6 +219,9 @@ impl OperatorSpec { true, )?; + Span::current().pb_set_message(format!("{}-operator installed", self.name).as_str()); + Span::current().pb_set_style(&ProgressStyle::with_template("{msg}").unwrap()); + Ok(()) } @@ -219,6 +231,8 @@ impl OperatorSpec { where T: AsRef + std::fmt::Display + std::fmt::Debug, { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + match helm::uninstall_release(&self.helm_name(), namespace.as_ref(), true) { Ok(status) => { println!("{status}"); diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index 1bb8be6b..cadd6f78 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -1,9 +1,11 @@ use futures::{StreamExt as _, TryStreamExt}; use indexmap::IndexMap; +use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::JoinError; -use tracing::{Instrument, Span, info, instrument}; +use tracing::{Instrument, Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -61,8 +63,6 @@ impl ReleaseSpec { namespace: &str, chart_source: &ChartSourceType, ) -> Result<()> { - info!("Installing release"); - include_products.iter().for_each(|product| { Span::current().record("product.included", product); }); @@ -70,8 +70,15 @@ impl ReleaseSpec { Span::current().record("product.excluded", product); }); + let operators = self.filter_products(include_products, exclude_products); + + Span::current().pb_set_style( + &ProgressStyle::with_template("Installing Release {wide_bar} {pos}/{len}").unwrap(), + ); + Span::current().pb_set_length(operators.len() as u64); + let namespace = namespace.to_string(); - futures::stream::iter(self.filter_products(include_products, exclude_products)) + futures::stream::iter(operators) .map(|(product_name, product)| { let task_span = tracing::debug_span!("install_operator", product_name = tracing::field::Empty); @@ -83,7 +90,12 @@ impl ReleaseSpec { tokio::spawn( async move { Span::current().record("product_name", &product_name); - info!("Installing {product_name}-operator"); + Span::current().pb_set_message( + format!("Installing {}-operator", product_name).as_str(), + ); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} {msg}").unwrap(), + ); // Create operator spec let operator = @@ -95,7 +107,11 @@ impl ReleaseSpec { .install(&namespace, &chart_source) .context(HelmInstallSnafu)?; - info!("Installed {product_name}-operator"); + Span::current().pb_set_message( + format!("{}-operator installed", product_name).as_str(), + ); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{msg}").unwrap()); Ok(()) } @@ -103,17 +119,25 @@ impl ReleaseSpec { ) }) .buffer_unordered(10) - .map(|res| res.context(BackgroundTaskSnafu)?) + .map(|res| { + Span::current().pb_inc(1); + res.context(BackgroundTaskSnafu)? + }) .try_collect::<()>() .await } #[instrument(skip_all)] pub fn uninstall(&self, namespace: &str) -> Result<()> { - info!("Uninstalling release"); + debug!("Uninstalling release"); + + Span::current().pb_set_style( + &ProgressStyle::with_template("Uninstalling Release {wide_bar} {pos}/{len}").unwrap(), + ); + Span::current().pb_set_length(self.products.len() as u64); for (product_name, product_spec) in &self.products { - info!("Uninstalling {product_name}-operator"); + debug!("Uninstalling {product_name}-operator"); // Create operator spec let operator = OperatorSpec::new(product_name, Some(product_spec.version.clone())) @@ -122,6 +146,8 @@ impl ReleaseSpec { // Uninstall operator helm::uninstall_release(&operator.helm_name(), namespace, true) .context(HelmUninstallSnafu)?; + + Span::current().pb_inc(1); } Ok(()) diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index 5e638935..fb7b650c 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -1,6 +1,8 @@ +use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; -use tracing::{debug, info, instrument, log::warn}; +use tracing::{Span, debug, info, instrument, log::warn}; +use tracing_indicatif::span_ext::IndicatifSpanExt; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -112,6 +114,7 @@ impl StackSpec { #[instrument(skip_all)] pub async fn check_prerequisites(&self, client: &Client, namespace: &str) -> Result<(), Error> { debug!("Checking prerequisites before installing stack"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Returns an error if the stack doesn't support to be installed in the // requested product namespace. When installing a demo, this check is @@ -160,6 +163,8 @@ impl StackSpec { client: &Client, transfer_client: &xfer::Client, ) -> Result<(), Error> { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + // First, we check if the prerequisites are met self.check_prerequisites(client, &install_parameters.stack_namespace) .await?; @@ -203,6 +208,7 @@ impl StackSpec { chart_source: &ChartSourceType, ) -> Result<(), Error> { info!(self.release, "Trying to install release"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Get the release by name let release = release_list @@ -226,6 +232,7 @@ impl StackSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let parameters = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/stacklet/mod.rs b/rust/stackable-cockpit/src/platform/stacklet/mod.rs index 7c6e6d20..6f7a3e0d 100644 --- a/rust/stackable-cockpit/src/platform/stacklet/mod.rs +++ b/rust/stackable-cockpit/src/platform/stacklet/mod.rs @@ -170,11 +170,14 @@ fn build_products_gvk_list<'a>(product_names: &[&'a str]) -> IndexMap<&'a str, G for product_name in product_names { // Why? Just why? Can we please make this consistent? if *product_name == "spark-history-server" { - map.insert(*product_name, GroupVersionKind { - group: "spark.stackable.tech".into(), - version: "v1alpha1".into(), - kind: "SparkHistoryServer".into(), - }); + map.insert( + *product_name, + GroupVersionKind { + group: "spark.stackable.tech".into(), + version: "v1alpha1".into(), + kind: "SparkHistoryServer".into(), + }, + ); continue; } diff --git a/rust/stackable-cockpit/src/utils/check.rs b/rust/stackable-cockpit/src/utils/check.rs index 401b01b6..9447f24d 100644 --- a/rust/stackable-cockpit/src/utils/check.rs +++ b/rust/stackable-cockpit/src/utils/check.rs @@ -1,6 +1,8 @@ use std::ffi::OsStr; -use tracing::{debug, instrument}; +use indicatif::ProgressStyle; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use which::which; /// Returns if the binary with `name` is present in the $PATH. @@ -12,6 +14,7 @@ pub fn binary_present>(name: T) -> bool { #[instrument(skip_all)] pub fn binaries_present(names: &[&str]) -> bool { debug!("Checking if required binaries are present on the system"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); for name in names { if !binary_present(name) { @@ -27,6 +30,7 @@ pub fn binaries_present(names: &[&str]) -> bool { #[instrument(skip_all)] pub fn binaries_present_with_name(names: &[&str]) -> Option { debug!("Checking if required binaries are present on the system"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); for name in names { if !binary_present(name) { diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index c87b7118..a3ed2e8f 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -14,7 +14,7 @@ use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{commons::listener::Listener, kvp::Labels}; use tokio::sync::RwLock; -use tracing::info; +use tracing::{debug, info}; #[cfg(doc)] use crate::utils::k8s::ListParamsExt; @@ -354,13 +354,16 @@ impl Client { pub async fn create_namespace(&self, name: String) -> Result<()> { let namespace_api: Api = Api::all(self.client.clone()); namespace_api - .create(&PostParams::default(), &Namespace { - metadata: ObjectMeta { - name: Some(name), + .create( + &PostParams::default(), + &Namespace { + metadata: ObjectMeta { + name: Some(name), + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }) + ) .await .context(KubeClientPatchSnafu)?; @@ -420,7 +423,7 @@ impl Client { /// Creates a new [`Discovery`] object and immediatly runs a discovery. #[tracing::instrument(skip_all)] async fn run_discovery(client: kube::client::Client) -> Result { - info!("running discovery"); + debug!("running discovery"); Discovery::new(client) .run() .await diff --git a/rust/stackable-cockpit/src/utils/params.rs b/rust/stackable-cockpit/src/utils/params.rs index 623aeac4..65299350 100644 --- a/rust/stackable-cockpit/src/utils/params.rs +++ b/rust/stackable-cockpit/src/utils/params.rs @@ -281,17 +281,23 @@ mod test { let p = iter.next(); assert!(p.is_some()); - assert_eq!(p.unwrap(), &RawParameter { - name: "param1".into(), - value: "value1".into() - }); + assert_eq!( + p.unwrap(), + &RawParameter { + name: "param1".into(), + value: "value1".into() + } + ); let p = iter.next(); assert!(p.is_some()); - assert_eq!(p.unwrap(), &RawParameter { - name: "param2".into(), - value: "value2".into() - }); + assert_eq!( + p.unwrap(), + &RawParameter { + name: "param2".into(), + value: "value2".into() + } + ); let p = iter.next(); assert!(p.is_none()); @@ -309,17 +315,23 @@ mod test { let p = iter.next(); assert!(p.is_some()); - assert_eq!(p.unwrap(), &RawParameter { - name: "param1".into(), - value: "value1".into() - }); + assert_eq!( + p.unwrap(), + &RawParameter { + name: "param1".into(), + value: "value1".into() + } + ); let p = iter.next(); assert!(p.is_some()); - assert_eq!(p.unwrap(), &RawParameter { - name: "param2".into(), - value: "value2".into() - }); + assert_eq!( + p.unwrap(), + &RawParameter { + name: "param2".into(), + value: "value2".into() + } + ); let p = iter.next(); assert!(p.is_none()); @@ -367,10 +379,13 @@ mod test { match input.into_params(valid_parameters) { Ok(validated) => panic!("SHOULD FAIL: {validated:?}"), - Err(err) => assert_eq!(err, IntoParametersError::InvalidParameter { - parameter: "param2".into(), - expected: "param1".into() - }), + Err(err) => assert_eq!( + err, + IntoParametersError::InvalidParameter { + parameter: "param2".into(), + expected: "param1".into() + } + ), } } } diff --git a/rust/stackable-cockpitd/src/handlers/ui.rs b/rust/stackable-cockpitd/src/handlers/ui.rs index 9abdb02b..e250e0bb 100644 --- a/rust/stackable-cockpitd/src/handlers/ui.rs +++ b/rust/stackable-cockpitd/src/handlers/ui.rs @@ -18,11 +18,14 @@ async fn ui() -> Html<&'static str> { } async fn asset(Path(name): Path) -> impl IntoResponse { ( - [(CONTENT_TYPE, match name.rsplit_once('.') { - Some((_, "js")) => HeaderValue::from_static("text/javascript"), - Some((_, "css")) => HeaderValue::from_static("text/css"), - _ => HeaderValue::from_static("application/octet-stream"), - })], + [( + CONTENT_TYPE, + match name.rsplit_once('.') { + Some((_, "js")) => HeaderValue::from_static("text/javascript"), + Some((_, "css")) => HeaderValue::from_static("text/css"), + _ => HeaderValue::from_static("application/octet-stream"), + }, + )], stackable_cockpit_web::ASSETS[&name], ) } diff --git a/rust/stackablectl/Cargo.toml b/rust/stackablectl/Cargo.toml index 6fa40591..19e570f9 100644 --- a/rust/stackablectl/Cargo.toml +++ b/rust/stackablectl/Cargo.toml @@ -32,7 +32,9 @@ tera.workspace = true tokio.workspace = true tracing-subscriber.workspace = true tracing.workspace = true +tracing-indicatif.workspace = true futures.workspace = true +indicatif.workspace = true termion.workspace = true urlencoding.workspace = true -libc.workspace = true +libc.workspace = true \ No newline at end of file diff --git a/rust/stackablectl/src/cli/mod.rs b/rust/stackablectl/src/cli/mod.rs index 641c8cd4..3574f0c4 100644 --- a/rust/stackablectl/src/cli/mod.rs +++ b/rust/stackablectl/src/cli/mod.rs @@ -2,6 +2,7 @@ use std::env; use clap::{Parser, Subcommand, ValueEnum}; use directories::ProjectDirs; +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::{ constants::{HELM_REPO_NAME_DEV, HELM_REPO_NAME_STABLE, HELM_REPO_NAME_TEST}, @@ -12,7 +13,8 @@ use stackable_cockpit::{ }, xfer::cache::Settings, }; -use tracing::{Level, instrument}; +use tracing::{Level, Span, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ args::{CommonFileArgs, CommonRepoArgs}, @@ -135,7 +137,7 @@ impl Cli { /// Adds the default (or custom) Helm repository URLs. Internally this calls the Helm SDK written in Go through the /// `go-helm-wrapper`. pub fn add_helm_repos(&self) -> Result<(), helm::Error> { - tracing::info!("Add Helm repos"); + tracing::debug!("Add Helm repos"); // Stable repository helm::add_repo(HELM_REPO_NAME_STABLE, &self.repos.helm_repo_stable)?; @@ -172,6 +174,8 @@ impl Cli { #[instrument(skip_all)] pub async fn run(&self) -> Result { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + // FIXME (Techassi): There might be a better way to handle this with // the match later in this function. diff --git a/rust/stackablectl/src/cmds/cache.rs b/rust/stackablectl/src/cmds/cache.rs index 37dc77ee..ec96f9c6 100644 --- a/rust/stackablectl/src/cmds/cache.rs +++ b/rust/stackablectl/src/cmds/cache.rs @@ -2,9 +2,11 @@ use std::time::Duration; use clap::{Args, Subcommand}; use comfy_table::{ColumnConstraint, Table, Width, presets::UTF8_FULL}; +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::xfer::cache::{self, Cache, DeleteFilter}; -use tracing::{info, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::cli::Cli; @@ -52,7 +54,8 @@ impl CacheArgs { #[instrument(skip_all)] async fn list_cmd(cache: Cache, cli: &Cli) -> Result { - info!("Listing cached files"); + debug!("Listing cached files"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let files = cache.list().await.context(ListCachedFilesSnafu)?; @@ -88,7 +91,8 @@ async fn list_cmd(cache: Cache, cli: &Cli) -> Result { #[instrument(skip_all)] async fn clean_cmd(args: &CacheCleanArgs, cache: Cache) -> Result { - info!("Cleaning cached files"); + debug!("Cleaning cached files"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let delete_filter = if args.only_remove_old_files { DeleteFilter::OnlyExpired diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 3a4f4c80..0a4a9b38 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -3,6 +3,7 @@ use comfy_table::{ ContentArrangement, Row, Table, presets::{NOTHING, UTF8_FULL}, }; +use indicatif::ProgressStyle; use snafu::{OptionExt as _, ResultExt, Snafu, ensure}; use stackable_cockpit::{ common::list, @@ -19,7 +20,8 @@ use stackable_cockpit::{ xfer::{self, cache::Cache}, }; use stackable_operator::kvp::{LabelError, Labels}; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError, CommonNamespaceArgs}, @@ -162,6 +164,7 @@ impl DemoArgs { #[instrument(skip_all, fields(with_cache = !cli.no_cache))] pub async fn run(&self, cli: &Cli, cache: Cache) -> Result { debug!("Handle demo args"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let transfer_client = xfer::Client::new_with(cache); @@ -172,9 +175,10 @@ impl DemoArgs { let release_branch = match &self.release { Some(release) => { - ensure!(release_list.contains_key(release), NoSuchReleaseSnafu { - release - }); + ensure!( + release_list.contains_key(release), + NoSuchReleaseSnafu { release } + ); if release == "dev" { "main".to_string() @@ -211,7 +215,8 @@ impl DemoArgs { /// Print out a list of demos, either as a table (plain), JSON or YAML #[instrument(skip_all)] async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result { - info!("Listing demos"); + debug!("Listing demos"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -263,7 +268,8 @@ async fn describe_cmd( cli: &Cli, list: demo::List, ) -> Result { - info!(demo_name = %args.demo_name, "Describing demo"); + debug!(demo_name = %args.demo_name, "Describing demo"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { name: args.demo_name.clone(), @@ -325,7 +331,8 @@ async fn install_cmd( transfer_client: &xfer::Client, release_branch: &str, ) -> Result { - info!(demo_name = %args.demo_name, "Installing demo"); + debug!(demo_name = %args.demo_name, "Installing demo"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Init result output and progress output let mut output = cli.result(); diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 207b7df4..4d370f7c 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -6,6 +6,7 @@ use comfy_table::{ presets::{NOTHING, UTF8_FULL}, }; use indexmap::IndexMap; +use indicatif::ProgressStyle; use semver::Version; use serde::Serialize; use snafu::{ResultExt, Snafu}; @@ -25,7 +26,8 @@ use stackable_cockpit::{ k8s::{self, Client}, }, }; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, info_span, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError}, @@ -189,6 +191,7 @@ impl OperatorArgs { #[instrument(skip_all)] async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result { debug!("Listing operators"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Build map which maps artifacts to a chart source let source_index_files = @@ -246,6 +249,7 @@ async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result Result { debug!(operator_name = %args.operator_name, "Describing operator"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Build map which maps artifacts to a chart source let source_index_files = @@ -304,7 +308,7 @@ async fn describe_cmd(args: &OperatorDescribeArgs, cli: &Cli) -> Result Result { - info!("Installing operator(s)"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); args.local_cluster .install_if_needed() @@ -354,7 +358,8 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result Result { - info!("Uninstalling operator(s)"); + info_span!("Uninstalling operator(s)"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); for operator in &args.operators { operator @@ -384,7 +389,8 @@ fn uninstall_cmd(args: &OperatorUninstallArgs, cli: &Cli) -> Result Result { - info!("Listing installed operators"); + debug!("Listing installed operators"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); type ReleaseList = IndexMap; @@ -459,6 +465,7 @@ async fn build_source_index_file_list<'a>( chart_source: &ChartSourceType, ) -> Result, CmdError> { debug!("Building source index file list"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut source_index_files: HashMap<&str, ChartSourceMetadata> = HashMap::new(); @@ -512,6 +519,7 @@ fn build_versions_list( helm_index_files: &HashMap<&str, ChartSourceMetadata>, ) -> Result, CmdError> { debug!("Building versions list"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut versions_list = IndexMap::new(); @@ -544,6 +552,7 @@ where T: AsRef + std::fmt::Display + std::fmt::Debug, { debug!("Build versions list for operator"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut versions_list = OperatorVersionList(HashMap::new()); let operator_name = operator_name.as_ref(); @@ -566,6 +575,7 @@ where T: AsRef + std::fmt::Display + std::fmt::Debug, { debug!("Listing operator versions from repository"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let chart_name = utils::operator_chart_name(operator_name.as_ref()); diff --git a/rust/stackablectl/src/cmds/release.rs b/rust/stackablectl/src/cmds/release.rs index bbaee551..54167986 100644 --- a/rust/stackablectl/src/cmds/release.rs +++ b/rust/stackablectl/src/cmds/release.rs @@ -3,6 +3,7 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::{ common::list, @@ -14,7 +15,8 @@ use stackable_cockpit::{ }, xfer::{self, cache::Cache}, }; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError}, @@ -130,6 +132,7 @@ pub enum CmdError { impl ReleaseArgs { pub async fn run(&self, cli: &Cli, cache: Cache) -> Result { debug!("Handle release args"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let transfer_client = xfer::Client::new_with(cache); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; @@ -156,7 +159,8 @@ async fn list_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - info!("Listing releases"); + debug!("Listing releases"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -210,7 +214,8 @@ async fn describe_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - info!(release = %args.release, "Describing release"); + debug!(release = %args.release, "Describing release"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let release = release_list.get(&args.release); @@ -271,7 +276,9 @@ async fn install_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - info!(release = %args.release, "Installing release"); + debug!(release = %args.release, "Installing release"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + match release_list.get(&args.release) { Some(release) => { let mut output = cli.result(); @@ -320,6 +327,8 @@ async fn uninstall_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + match release_list.get(&args.release) { Some(release) => { release diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index be78c33a..c9d2c54e 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -3,6 +3,7 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; +use indicatif::ProgressStyle; use snafu::{OptionExt as _, ResultExt, Snafu, ensure}; use stackable_cockpit::{ common::list, @@ -19,7 +20,8 @@ use stackable_cockpit::{ xfer::{self, cache::Cache}, }; use stackable_operator::kvp::{LabelError, Labels}; -use tracing::{debug, info, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError, CommonNamespaceArgs}, @@ -158,9 +160,10 @@ impl StackArgs { let release_branch = match &self.release { Some(release) => { - ensure!(release_list.contains_key(release), NoSuchReleaseSnafu { - release - }); + ensure!( + release_list.contains_key(release), + NoSuchReleaseSnafu { release } + ); if release == "dev" { "main".to_string() @@ -197,7 +200,8 @@ fn list_cmd( cli: &Cli, stack_list: stack::StackList, ) -> Result { - info!("Listing stacks"); + debug!("Listing stacks"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -247,7 +251,8 @@ fn describe_cmd( cli: &Cli, stack_list: stack::StackList, ) -> Result { - info!(stack_name = %args.stack_name, "Describing stack"); + debug!(stack_name = %args.stack_name, "Describing stack"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); match stack_list.get(&args.stack_name) { Some(stack) => match args.output_type { @@ -310,7 +315,8 @@ async fn install_cmd( stack_list: stack::StackList, transfer_client: &xfer::Client, ) -> Result { - info!(stack_name = %args.stack_name, "Installing stack"); + debug!(stack_name = %args.stack_name, "Installing stack"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index 2422f65f..442f926c 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -3,13 +3,15 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; +use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::{ constants::DEFAULT_NAMESPACE, platform::stacklet::{self, get_credentials_for_product, list_stacklets}, utils::k8s::{self, Client, DisplayCondition}, }; -use tracing::{info, instrument}; +use tracing::{Span, debug, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt; use crate::{ args::CommonNamespaceArgs, @@ -91,7 +93,8 @@ impl StackletArgs { #[instrument(skip_all)] async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result { - info!("Listing installed stacklets"); + debug!("Listing installed stacklets"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let client = Client::new().await.context(KubeClientCreateSnafu)?; @@ -204,7 +207,8 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result Result { - info!("Displaying stacklet credentials"); + debug!("Displaying stacklet credentials"); + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let client = Client::new().await.context(KubeClientCreateSnafu)?; diff --git a/rust/stackablectl/src/main.rs b/rust/stackablectl/src/main.rs index 09bc2269..2d3358a0 100644 --- a/rust/stackablectl/src/main.rs +++ b/rust/stackablectl/src/main.rs @@ -1,8 +1,10 @@ use clap::Parser; use dotenvy::dotenv; +use indicatif::ProgressStyle; use stackablectl::cli::{Cli, Error}; -use tracing::metadata::LevelFilter; -use tracing_subscriber::fmt; +use tracing::{Span, metadata::LevelFilter}; +use tracing_indicatif::{IndicatifLayer, span_ext::IndicatifSpanExt}; +use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[snafu::report] #[tokio::main] @@ -16,14 +18,30 @@ async fn main() -> Result<(), Error> { .without_time() .with_target(false); - tracing_subscriber::fmt() - .with_max_level(match app.log_level { - Some(level) => LevelFilter::from_level(level), - None => LevelFilter::WARN, - }) - .event_format(format) - .pretty() - .init(); + let indicatif_layer = IndicatifLayer::new(); + + let level_filter = match app.log_level { + Some(level) => LevelFilter::from_level(level), + None => LevelFilter::INFO, + }; + + if level_filter == LevelFilter::DEBUG { + tracing_subscriber::registry() + .with( + fmt::layer() + .event_format(format) + .pretty() + .with_writer(indicatif_layer.get_stderr_writer()), + ) + .init(); + } else { + tracing_subscriber::registry() + .with(level_filter) + .with(indicatif_layer) + .init(); + + Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + } // Load env vars from optional .env file match dotenv() { diff --git a/rust/xtask/src/openapi.rs b/rust/xtask/src/openapi.rs index 693c3e02..270e64fb 100644 --- a/rust/xtask/src/openapi.rs +++ b/rust/xtask/src/openapi.rs @@ -35,9 +35,12 @@ pub fn generate() -> Result<(), GenOpenapiError> { .write_all(openapi_json.as_bytes()) .context(WriteOpenapiSchemaSnafu)?; let status = codegen.wait().context(ImportOpenapiSchemaRunSnafu)?; - ensure!(status.success(), ImportOpenapiSchemaSnafu { - error_code: status.code() - }); + ensure!( + status.success(), + ImportOpenapiSchemaSnafu { + error_code: status.code() + } + ); Ok(()) } From d1ab01be5006a248539ee3e8cee6ba0027f4dfe8 Mon Sep 17 00:00:00 2001 From: xeniape Date: Fri, 16 May 2025 11:31:53 +0200 Subject: [PATCH 02/18] cleanup progress reporting and add additional information --- .../src/engine/docker/mod.rs | 5 +-- rust/stackable-cockpit/src/engine/kind/mod.rs | 7 +--- .../src/engine/minikube/mod.rs | 7 +--- rust/stackable-cockpit/src/helm.rs | 14 +------- rust/stackable-cockpit/src/oci.rs | 6 +--- .../src/platform/demo/spec.rs | 7 ++-- .../src/platform/manifests.rs | 10 ++++-- .../src/platform/operator/mod.rs | 12 +++---- .../src/platform/release/spec.rs | 30 ++++++---------- .../src/platform/stack/spec.rs | 9 ++--- rust/stackable-cockpit/src/utils/check.rs | 6 +--- .../stackable-cockpit/src/utils/k8s/client.rs | 4 +-- rust/stackablectl/src/cli/mod.rs | 7 ++-- rust/stackablectl/src/cmds/cache.rs | 10 ++---- rust/stackablectl/src/cmds/demo.rs | 22 +++++++----- rust/stackablectl/src/cmds/operator.rs | 36 ++++++++++--------- rust/stackablectl/src/cmds/release.rs | 25 +++++++------ rust/stackablectl/src/cmds/stack.rs | 21 ++++++----- rust/stackablectl/src/cmds/stacklet.rs | 16 +++++---- rust/stackablectl/src/main.rs | 20 +++++++---- 20 files changed, 125 insertions(+), 149 deletions(-) diff --git a/rust/stackable-cockpit/src/engine/docker/mod.rs b/rust/stackable-cockpit/src/engine/docker/mod.rs index be248000..697b0797 100644 --- a/rust/stackable-cockpit/src/engine/docker/mod.rs +++ b/rust/stackable-cockpit/src/engine/docker/mod.rs @@ -1,10 +1,8 @@ use std::process::Stdio; -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use tokio::process::Command; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{debug, instrument}; type Result = std::result::Result; @@ -24,7 +22,6 @@ pub enum Error { #[instrument(skip_all)] pub async fn check_if_docker_is_running() -> Result<()> { debug!("Checking if Docker is running"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if Command::new("docker") .arg("info") diff --git a/rust/stackable-cockpit/src/engine/kind/mod.rs b/rust/stackable-cockpit/src/engine/kind/mod.rs index 4dc7457d..b3f86401 100644 --- a/rust/stackable-cockpit/src/engine/kind/mod.rs +++ b/rust/stackable-cockpit/src/engine/kind/mod.rs @@ -1,10 +1,8 @@ use std::process::Stdio; -use indicatif::ProgressStyle; use snafu::{OptionExt, ResultExt, Snafu, ensure}; use tokio::{io::AsyncWriteExt, process::Command}; -use tracing::{Span, debug, info, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{debug, info, instrument}; use crate::{ engine::{ @@ -69,7 +67,6 @@ impl Cluster { #[instrument(skip_all)] pub async fn create(&self) -> Result<()> { info!("Creating local cluster using kind"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Check if required binaries are present if let Some(binary) = binaries_present_with_name(&["docker", "kind"]) { @@ -115,7 +112,6 @@ impl Cluster { #[instrument(skip_all)] pub async fn create_if_not_exists(&self) -> Result<()> { info!("Creating cluster if it doesn't exist using kind"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if Self::check_if_cluster_exists(&self.name).await? { return Ok(()); @@ -138,7 +134,6 @@ impl Cluster { #[instrument(skip_all)] async fn check_if_cluster_exists(cluster_name: &str) -> Result { debug!("Checking if kind cluster exists"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let output = Command::new("kind") .args(["get", "clusters"]) diff --git a/rust/stackable-cockpit/src/engine/minikube/mod.rs b/rust/stackable-cockpit/src/engine/minikube/mod.rs index 668268f8..dab6e959 100644 --- a/rust/stackable-cockpit/src/engine/minikube/mod.rs +++ b/rust/stackable-cockpit/src/engine/minikube/mod.rs @@ -1,8 +1,6 @@ -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use tokio::process::Command; -use tracing::{Span, debug, info, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{debug, info, instrument}; use crate::{ engine::docker::{self, check_if_docker_is_running}, @@ -46,7 +44,6 @@ impl Cluster { #[instrument(skip_all)] pub async fn create(&self) -> Result<(), Error> { info!("Creating local cluster using Minikube"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Check if required binaries are present if let Some(binary) = binaries_present_with_name(&["docker", "minikube"]) { @@ -76,7 +73,6 @@ impl Cluster { #[instrument(skip_all)] pub async fn create_if_not_exists(&self) -> Result<(), Error> { info!("Creating cluster if it doesn't exist using Minikube"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if Self::check_if_cluster_exists(&self.name).await? { return Ok(()); @@ -99,7 +95,6 @@ impl Cluster { #[instrument(skip_all)] async fn check_if_cluster_exists(cluster_name: &str) -> Result { debug!("Checking if Minikube cluster exists"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let output = Command::new("minikube") .arg("status") diff --git a/rust/stackable-cockpit/src/helm.rs b/rust/stackable-cockpit/src/helm.rs index ede6741f..cd219166 100644 --- a/rust/stackable-cockpit/src/helm.rs +++ b/rust/stackable-cockpit/src/helm.rs @@ -1,11 +1,9 @@ use std::fmt::Display; -use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::block_in_place; -use tracing::{Span, debug, error, info, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{debug, error, info, instrument}; use url::Url; use crate::{ @@ -197,8 +195,6 @@ pub fn install_release_from_repo_or_registry( namespace: &str, suppress_output: bool, ) -> Result { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); - // Ideally, each Helm invocation would spawn_blocking instead in/around helm_sys, // but that requires a larger refactoring block_in_place(|| { @@ -274,8 +270,6 @@ fn install_release( namespace: &str, suppress_output: bool, ) -> Result<(), Error> { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); - let result = helm_sys::install_helm_release( release_name, chart_name, @@ -310,7 +304,6 @@ pub fn uninstall_release( suppress_output: bool, ) -> Result { debug!("Uninstall Helm release"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); if check_release_exists(release_name, namespace)? { let result = helm_sys::uninstall_helm_release(release_name, namespace, suppress_output); @@ -343,7 +336,6 @@ pub fn uninstall_release( #[instrument] pub fn check_release_exists(release_name: &str, namespace: &str) -> Result { debug!("Check if Helm release exists"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // TODO (Techassi): Handle error Ok(helm_sys::check_helm_release_exists(release_name, namespace)) @@ -353,7 +345,6 @@ pub fn check_release_exists(release_name: &str, namespace: &str) -> Result Result, Error> { debug!("List Helm releases"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let result = helm_sys::list_helm_releases(namespace); @@ -373,7 +364,6 @@ pub fn list_releases(namespace: &str) -> Result, Error> { #[instrument] pub fn get_release(release_name: &str, namespace: &str) -> Result, Error> { debug!("Get Helm release"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); Ok(list_releases(namespace)? .into_iter() @@ -384,7 +374,6 @@ pub fn get_release(release_name: &str, namespace: &str) -> Result Result<(), Error> { debug!("Add Helm repo"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let result = helm_sys::add_helm_repository(repository_name, repository_url); @@ -407,7 +396,6 @@ where T: AsRef + std::fmt::Display + std::fmt::Debug, { debug!("Get Helm repo index file"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let url = Url::parse(repo_url.as_ref()).context(UrlParseSnafu)?; let url = url.join(HELM_REPO_INDEX_FILE).context(UrlParseSnafu)?; diff --git a/rust/stackable-cockpit/src/oci.rs b/rust/stackable-cockpit/src/oci.rs index 38a50775..337cc876 100644 --- a/rust/stackable-cockpit/src/oci.rs +++ b/rust/stackable-cockpit/src/oci.rs @@ -1,10 +1,8 @@ use std::collections::HashMap; -use indicatif::ProgressStyle; use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{debug, instrument}; use url::Url; use urlencoding::encode; @@ -122,8 +120,6 @@ impl OciUrlExt for Url { // TODO (@NickLarsenNZ): Look into why a HashMap is used here when the key is inside each entry in the value #[instrument] pub async fn get_oci_index<'a>() -> Result, Error> { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); - let mut source_index_files: HashMap<&str, ChartSourceMetadata> = HashMap::new(); // initialize map diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index b058e0a1..94584013 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -2,7 +2,7 @@ use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; use tracing::{Span, debug, info, instrument, warn}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -100,7 +100,6 @@ impl DemoSpec { #[instrument(skip_all)] pub async fn check_prerequisites(&self, client: &Client, namespace: &str) -> Result<(), Error> { debug!("Checking prerequisites before installing demo"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Returns an error if the demo doesn't support to be installed in the // requested namespace @@ -145,8 +144,6 @@ impl DemoSpec { client: &Client, transfer_client: &xfer::Client, ) -> Result<(), Error> { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); - // Get the stack spec based on the name defined in the demo spec let stack = stack_list.get(&self.stack).context(NoSuchStackSnafu { name: self.stack.clone(), @@ -194,7 +191,7 @@ impl DemoSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").unwrap()); let params = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 423c2fa1..1980ddf4 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -4,7 +4,7 @@ use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_operator::kvp::Labels; use tracing::{Span, debug, info, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ common::manifest::ManifestSpec, @@ -75,7 +75,11 @@ pub trait InstallManifestsExt { transfer_client: &xfer::Client, ) -> Result<(), Error> { debug!("Installing manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + + Span::current().pb_set_style( + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(), + ); + Span::current().pb_set_length(manifests.len() as u64); let mut parameters = parameters.clone(); // We add the NAMESPACE parameter, so that stacks/demos can use that to render e.g. the @@ -148,6 +152,8 @@ pub trait InstallManifestsExt { .context(DeployManifestSnafu)? } } + + Span::current().pb_inc(1); } Ok(()) diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index 44010684..911dbd63 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -4,8 +4,8 @@ use indicatif::ProgressStyle; use semver::Version; use serde::Serialize; use snafu::{ResultExt, Snafu, ensure}; -use tracing::{Span, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{info, instrument, Span}; +use tracing_indicatif::{indicatif_println, span_ext::IndicatifSpanExt}; use crate::{ constants::{ @@ -193,6 +193,7 @@ impl OperatorSpec { namespace: &str, chart_source: &ChartSourceType, ) -> Result<(), helm::Error> { + info!(operator = %self, "Installing operator"); Span::current().pb_set_message(format!("Installing {}-operator", self.name).as_str()); Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").unwrap()); @@ -219,9 +220,6 @@ impl OperatorSpec { true, )?; - Span::current().pb_set_message(format!("{}-operator installed", self.name).as_str()); - Span::current().pb_set_style(&ProgressStyle::with_template("{msg}").unwrap()); - Ok(()) } @@ -231,11 +229,9 @@ impl OperatorSpec { where T: AsRef + std::fmt::Display + std::fmt::Debug, { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); - match helm::uninstall_release(&self.helm_name(), namespace.as_ref(), true) { Ok(status) => { - println!("{status}"); + indicatif_println!("{}", status); Ok(()) } Err(err) => Err(err), diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index cadd6f78..9fc4eb1d 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -4,8 +4,8 @@ use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::JoinError; -use tracing::{Instrument, Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{info, instrument, Instrument, Span}; +use tracing_indicatif::{span_ext::IndicatifSpanExt as _}; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -63,6 +63,11 @@ impl ReleaseSpec { namespace: &str, chart_source: &ChartSourceType, ) -> Result<()> { + info!("Installing release"); + Span::current().pb_set_style( + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(), + ); + include_products.iter().for_each(|product| { Span::current().record("product.included", product); }); @@ -72,9 +77,6 @@ impl ReleaseSpec { let operators = self.filter_products(include_products, exclude_products); - Span::current().pb_set_style( - &ProgressStyle::with_template("Installing Release {wide_bar} {pos}/{len}").unwrap(), - ); Span::current().pb_set_length(operators.len() as u64); let namespace = namespace.to_string(); @@ -90,12 +92,6 @@ impl ReleaseSpec { tokio::spawn( async move { Span::current().record("product_name", &product_name); - Span::current().pb_set_message( - format!("Installing {}-operator", product_name).as_str(), - ); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} {msg}").unwrap(), - ); // Create operator spec let operator = @@ -107,12 +103,6 @@ impl ReleaseSpec { .install(&namespace, &chart_source) .context(HelmInstallSnafu)?; - Span::current().pb_set_message( - format!("{}-operator installed", product_name).as_str(), - ); - Span::current() - .pb_set_style(&ProgressStyle::with_template("{msg}").unwrap()); - Ok(()) } .instrument(task_span), @@ -129,15 +119,15 @@ impl ReleaseSpec { #[instrument(skip_all)] pub fn uninstall(&self, namespace: &str) -> Result<()> { - debug!("Uninstalling release"); + info!("Uninstalling release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Uninstalling Release {wide_bar} {pos}/{len}").unwrap(), + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(), ); Span::current().pb_set_length(self.products.len() as u64); for (product_name, product_spec) in &self.products { - debug!("Uninstalling {product_name}-operator"); + info!("Uninstalling {product_name}-operator"); // Create operator spec let operator = OperatorSpec::new(product_name, Some(product_spec.version.clone())) diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index fb7b650c..ea56abd2 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -2,7 +2,7 @@ use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; use tracing::{Span, debug, info, instrument, log::warn}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -114,7 +114,6 @@ impl StackSpec { #[instrument(skip_all)] pub async fn check_prerequisites(&self, client: &Client, namespace: &str) -> Result<(), Error> { debug!("Checking prerequisites before installing stack"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // Returns an error if the stack doesn't support to be installed in the // requested product namespace. When installing a demo, this check is @@ -163,8 +162,6 @@ impl StackSpec { client: &Client, transfer_client: &xfer::Client, ) -> Result<(), Error> { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); - // First, we check if the prerequisites are met self.check_prerequisites(client, &install_parameters.stack_namespace) .await?; @@ -208,7 +205,7 @@ impl StackSpec { chart_source: &ChartSourceType, ) -> Result<(), Error> { info!(self.release, "Trying to install release"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").unwrap()); // Get the release by name let release = release_list @@ -232,7 +229,7 @@ impl StackSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").unwrap()); let parameters = install_params .parameters diff --git a/rust/stackable-cockpit/src/utils/check.rs b/rust/stackable-cockpit/src/utils/check.rs index 9447f24d..401b01b6 100644 --- a/rust/stackable-cockpit/src/utils/check.rs +++ b/rust/stackable-cockpit/src/utils/check.rs @@ -1,8 +1,6 @@ use std::ffi::OsStr; -use indicatif::ProgressStyle; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{debug, instrument}; use which::which; /// Returns if the binary with `name` is present in the $PATH. @@ -14,7 +12,6 @@ pub fn binary_present>(name: T) -> bool { #[instrument(skip_all)] pub fn binaries_present(names: &[&str]) -> bool { debug!("Checking if required binaries are present on the system"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); for name in names { if !binary_present(name) { @@ -30,7 +27,6 @@ pub fn binaries_present(names: &[&str]) -> bool { #[instrument(skip_all)] pub fn binaries_present_with_name(names: &[&str]) -> Option { debug!("Checking if required binaries are present on the system"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); for name in names { if !binary_present(name) { diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index a3ed2e8f..23e77546 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -14,7 +14,7 @@ use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{commons::listener::Listener, kvp::Labels}; use tokio::sync::RwLock; -use tracing::{debug, info}; +use tracing::{info}; #[cfg(doc)] use crate::utils::k8s::ListParamsExt; @@ -423,7 +423,7 @@ impl Client { /// Creates a new [`Discovery`] object and immediatly runs a discovery. #[tracing::instrument(skip_all)] async fn run_discovery(client: kube::client::Client) -> Result { - debug!("running discovery"); + info!("running discovery"); Discovery::new(client) .run() .await diff --git a/rust/stackablectl/src/cli/mod.rs b/rust/stackablectl/src/cli/mod.rs index 3574f0c4..67ec6dad 100644 --- a/rust/stackablectl/src/cli/mod.rs +++ b/rust/stackablectl/src/cli/mod.rs @@ -2,7 +2,6 @@ use std::env; use clap::{Parser, Subcommand, ValueEnum}; use directories::ProjectDirs; -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::{ constants::{HELM_REPO_NAME_DEV, HELM_REPO_NAME_STABLE, HELM_REPO_NAME_TEST}, @@ -13,8 +12,7 @@ use stackable_cockpit::{ }, xfer::cache::Settings, }; -use tracing::{Level, Span, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{Level, instrument}; use crate::{ args::{CommonFileArgs, CommonRepoArgs}, @@ -137,7 +135,7 @@ impl Cli { /// Adds the default (or custom) Helm repository URLs. Internally this calls the Helm SDK written in Go through the /// `go-helm-wrapper`. pub fn add_helm_repos(&self) -> Result<(), helm::Error> { - tracing::debug!("Add Helm repos"); + tracing::info!("Add Helm repos"); // Stable repository helm::add_repo(HELM_REPO_NAME_STABLE, &self.repos.helm_repo_stable)?; @@ -174,7 +172,6 @@ impl Cli { #[instrument(skip_all)] pub async fn run(&self) -> Result { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); // FIXME (Techassi): There might be a better way to handle this with // the match later in this function. diff --git a/rust/stackablectl/src/cmds/cache.rs b/rust/stackablectl/src/cmds/cache.rs index ec96f9c6..37dc77ee 100644 --- a/rust/stackablectl/src/cmds/cache.rs +++ b/rust/stackablectl/src/cmds/cache.rs @@ -2,11 +2,9 @@ use std::time::Duration; use clap::{Args, Subcommand}; use comfy_table::{ColumnConstraint, Table, Width, presets::UTF8_FULL}; -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::xfer::cache::{self, Cache, DeleteFilter}; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{info, instrument}; use crate::cli::Cli; @@ -54,8 +52,7 @@ impl CacheArgs { #[instrument(skip_all)] async fn list_cmd(cache: Cache, cli: &Cli) -> Result { - debug!("Listing cached files"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Listing cached files"); let files = cache.list().await.context(ListCachedFilesSnafu)?; @@ -91,8 +88,7 @@ async fn list_cmd(cache: Cache, cli: &Cli) -> Result { #[instrument(skip_all)] async fn clean_cmd(args: &CacheCleanArgs, cache: Cache) -> Result { - debug!("Cleaning cached files"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Cleaning cached files"); let delete_filter = if args.only_remove_old_files { DeleteFilter::OnlyExpired diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 0a4a9b38..d3331a1a 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -20,8 +20,8 @@ use stackable_cockpit::{ xfer::{self, cache::Cache}, }; use stackable_operator::kvp::{LabelError, Labels}; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError, CommonNamespaceArgs}, @@ -164,7 +164,6 @@ impl DemoArgs { #[instrument(skip_all, fields(with_cache = !cli.no_cache))] pub async fn run(&self, cli: &Cli, cache: Cache) -> Result { debug!("Handle demo args"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let transfer_client = xfer::Client::new_with(cache); @@ -215,8 +214,10 @@ impl DemoArgs { /// Print out a list of demos, either as a table (plain), JSON or YAML #[instrument(skip_all)] async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result { - debug!("Listing demos"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Listing demos"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching demo information").unwrap(), + ); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -268,8 +269,10 @@ async fn describe_cmd( cli: &Cli, list: demo::List, ) -> Result { - debug!(demo_name = %args.demo_name, "Describing demo"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!(demo_name = %args.demo_name, "Describing demo"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching demo information").unwrap(), + ); let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { name: args.demo_name.clone(), @@ -331,8 +334,9 @@ async fn install_cmd( transfer_client: &xfer::Client, release_branch: &str, ) -> Result { - debug!(demo_name = %args.demo_name, "Installing demo"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!(demo_name = %args.demo_name, "Installing demo"); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing demo").unwrap()); // Init result output and progress output let mut output = cli.result(); diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 4d370f7c..7fd53a5b 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -26,8 +26,8 @@ use stackable_cockpit::{ k8s::{self, Client}, }, }; -use tracing::{Span, debug, info_span, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::{indicatif_println, span_ext::IndicatifSpanExt}; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError}, @@ -191,7 +191,9 @@ impl OperatorArgs { #[instrument(skip_all)] async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result { debug!("Listing operators"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching operator information").unwrap(), + ); // Build map which maps artifacts to a chart source let source_index_files = @@ -249,7 +251,9 @@ async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result Result { debug!(operator_name = %args.operator_name, "Describing operator"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching operator information").unwrap(), + ); // Build map which maps artifacts to a chart source let source_index_files = @@ -308,7 +312,9 @@ async fn describe_cmd(args: &OperatorDescribeArgs, cli: &Cli) -> Result Result { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Installing operator(s)"); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing operator(s)").unwrap()); args.local_cluster .install_if_needed() @@ -331,9 +337,8 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result Result Result { - info_span!("Uninstalling operator(s)"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Uninstalling operator(s)"); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling operator(s)").unwrap()); for operator in &args.operators { operator @@ -389,8 +395,10 @@ fn uninstall_cmd(args: &OperatorUninstallArgs, cli: &Cli) -> Result Result { - debug!("Listing installed operators"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Listing installed operators"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching operator information").unwrap(), + ); type ReleaseList = IndexMap; @@ -465,7 +473,6 @@ async fn build_source_index_file_list<'a>( chart_source: &ChartSourceType, ) -> Result, CmdError> { debug!("Building source index file list"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut source_index_files: HashMap<&str, ChartSourceMetadata> = HashMap::new(); @@ -519,7 +526,6 @@ fn build_versions_list( helm_index_files: &HashMap<&str, ChartSourceMetadata>, ) -> Result, CmdError> { debug!("Building versions list"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut versions_list = IndexMap::new(); @@ -552,7 +558,6 @@ where T: AsRef + std::fmt::Display + std::fmt::Debug, { debug!("Build versions list for operator"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let mut versions_list = OperatorVersionList(HashMap::new()); let operator_name = operator_name.as_ref(); @@ -575,7 +580,6 @@ where T: AsRef + std::fmt::Display + std::fmt::Debug, { debug!("Listing operator versions from repository"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let chart_name = utils::operator_chart_name(operator_name.as_ref()); diff --git a/rust/stackablectl/src/cmds/release.rs b/rust/stackablectl/src/cmds/release.rs index 54167986..788b7200 100644 --- a/rust/stackablectl/src/cmds/release.rs +++ b/rust/stackablectl/src/cmds/release.rs @@ -15,8 +15,8 @@ use stackable_cockpit::{ }, xfer::{self, cache::Cache}, }; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError}, @@ -132,7 +132,6 @@ pub enum CmdError { impl ReleaseArgs { pub async fn run(&self, cli: &Cli, cache: Cache) -> Result { debug!("Handle release args"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); let transfer_client = xfer::Client::new_with(cache); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; @@ -159,8 +158,10 @@ async fn list_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - debug!("Listing releases"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Listing releases"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching release information").unwrap(), + ); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -214,8 +215,10 @@ async fn describe_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - debug!(release = %args.release, "Describing release"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!(release = %args.release, "Describing release"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching release information").unwrap(), + ); let release = release_list.get(&args.release); @@ -276,8 +279,9 @@ async fn install_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - debug!(release = %args.release, "Installing release"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!(release = %args.release, "Installing release"); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing release").unwrap()); match release_list.get(&args.release) { Some(release) => { @@ -327,7 +331,8 @@ async fn uninstall_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling release").unwrap()); match release_list.get(&args.release) { Some(release) => { diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index c9d2c54e..5a30328d 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -20,8 +20,8 @@ use stackable_cockpit::{ xfer::{self, cache::Cache}, }; use stackable_operator::kvp::{LabelError, Labels}; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{Span, debug, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError, CommonNamespaceArgs}, @@ -200,8 +200,10 @@ fn list_cmd( cli: &Cli, stack_list: stack::StackList, ) -> Result { - debug!("Listing stacks"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Listing stacks"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching stack information").unwrap(), + ); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -251,8 +253,10 @@ fn describe_cmd( cli: &Cli, stack_list: stack::StackList, ) -> Result { - debug!(stack_name = %args.stack_name, "Describing stack"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!(stack_name = %args.stack_name, "Describing stack"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching stack information").unwrap(), + ); match stack_list.get(&args.stack_name) { Some(stack) => match args.output_type { @@ -315,8 +319,9 @@ async fn install_cmd( stack_list: stack::StackList, transfer_client: &xfer::Client, ) -> Result { - debug!(stack_name = %args.stack_name, "Installing stack"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!(stack_name = %args.stack_name, "Installing stack"); + Span::current() + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing stack").unwrap()); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index 442f926c..0e046e4b 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -10,8 +10,8 @@ use stackable_cockpit::{ platform::stacklet::{self, get_credentials_for_product, list_stacklets}, utils::k8s::{self, Client, DisplayCondition}, }; -use tracing::{Span, debug, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt; +use tracing::{Span, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ args::CommonNamespaceArgs, @@ -93,8 +93,10 @@ impl StackletArgs { #[instrument(skip_all)] async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result { - debug!("Listing installed stacklets"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Listing installed stacklets"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching stacklet information").unwrap(), + ); let client = Client::new().await.context(KubeClientCreateSnafu)?; @@ -207,8 +209,10 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result Result { - debug!("Displaying stacklet credentials"); - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); + info!("Displaying stacklet credentials"); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Fetching stacklet information").unwrap(), + ); let client = Client::new().await.context(KubeClientCreateSnafu)?; diff --git a/rust/stackablectl/src/main.rs b/rust/stackablectl/src/main.rs index 2d3358a0..11065e22 100644 --- a/rust/stackablectl/src/main.rs +++ b/rust/stackablectl/src/main.rs @@ -2,8 +2,8 @@ use clap::Parser; use dotenvy::dotenv; use indicatif::ProgressStyle; use stackablectl::cli::{Cli, Error}; -use tracing::{Span, metadata::LevelFilter}; -use tracing_indicatif::{IndicatifLayer, span_ext::IndicatifSpanExt}; +use tracing::metadata::LevelFilter; +use tracing_indicatif::{indicatif_println, IndicatifLayer}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[snafu::report] @@ -18,7 +18,17 @@ async fn main() -> Result<(), Error> { .without_time() .with_target(false); - let indicatif_layer = IndicatifLayer::new(); + let indicatif_layer = IndicatifLayer::new() + .with_progress_style(ProgressStyle::with_template("").unwrap()) + .with_max_progress_bars( + 15, + Some( + ProgressStyle::with_template( + "...and {pending_progress_bars} more processes not shown above.", + ) + .unwrap(), + ), + ); let level_filter = match app.log_level { Some(level) => LevelFilter::from_level(level), @@ -39,8 +49,6 @@ async fn main() -> Result<(), Error> { .with(level_filter) .with(indicatif_layer) .init(); - - Span::current().pb_set_style(&ProgressStyle::with_template("").unwrap()); } // Load env vars from optional .env file @@ -48,7 +56,7 @@ async fn main() -> Result<(), Error> { Ok(_) => (), Err(err) => { if !err.not_found() { - println!("{err}") + indicatif_println!("{err}") } } } From d4886ead00c23caae211bf1510da4346c8a99680 Mon Sep 17 00:00:00 2001 From: xeniape Date: Fri, 16 May 2025 14:44:18 +0200 Subject: [PATCH 03/18] cleanup --- rust/stackable-cockpit/src/platform/release/spec.rs | 3 +++ rust/stackable-cockpit/src/utils/k8s/client.rs | 2 +- rust/stackablectl/Cargo.toml | 2 +- rust/stackablectl/src/cli/mod.rs | 1 - 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index 9fc4eb1d..472fc635 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -92,6 +92,7 @@ impl ReleaseSpec { tokio::spawn( async move { Span::current().record("product_name", &product_name); + info!("Installing {product_name}-operator"); // Create operator spec let operator = @@ -103,6 +104,8 @@ impl ReleaseSpec { .install(&namespace, &chart_source) .context(HelmInstallSnafu)?; + info!("Installed {product_name}-operator"); + Ok(()) } .instrument(task_span), diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index 23e77546..48e41735 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -14,7 +14,7 @@ use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{commons::listener::Listener, kvp::Labels}; use tokio::sync::RwLock; -use tracing::{info}; +use tracing::info; #[cfg(doc)] use crate::utils::k8s::ListParamsExt; diff --git a/rust/stackablectl/Cargo.toml b/rust/stackablectl/Cargo.toml index 19e570f9..6d50927f 100644 --- a/rust/stackablectl/Cargo.toml +++ b/rust/stackablectl/Cargo.toml @@ -37,4 +37,4 @@ futures.workspace = true indicatif.workspace = true termion.workspace = true urlencoding.workspace = true -libc.workspace = true \ No newline at end of file +libc.workspace = true diff --git a/rust/stackablectl/src/cli/mod.rs b/rust/stackablectl/src/cli/mod.rs index 67ec6dad..641c8cd4 100644 --- a/rust/stackablectl/src/cli/mod.rs +++ b/rust/stackablectl/src/cli/mod.rs @@ -172,7 +172,6 @@ impl Cli { #[instrument(skip_all)] pub async fn run(&self) -> Result { - // FIXME (Techassi): There might be a better way to handle this with // the match later in this function. From d8f09b289ffcffd1cfbcb361c4d0bdc3ef62e5f3 Mon Sep 17 00:00:00 2001 From: xeniape Date: Sat, 17 May 2025 10:42:07 +0200 Subject: [PATCH 04/18] make regenerate-nix --- Cargo.nix | 244 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 233 insertions(+), 11 deletions(-) diff --git a/Cargo.nix b/Cargo.nix index ef95c5d6..0224a012 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -332,7 +332,7 @@ rec { } { name = "vte"; - packageId = "vte"; + packageId = "vte 0.10.1"; } ]; features = { @@ -492,7 +492,7 @@ rec { }; resolvedDefaultFeatures = [ "derive" "derive_arbitrary" ]; }; - "arrayvec" = rec { + "arrayvec 0.5.2" = rec { crateName = "arrayvec"; version = "0.5.2"; edition = "2018"; @@ -505,6 +505,21 @@ rec { "serde" = [ "dep:serde" ]; }; }; + "arrayvec 0.7.6" = rec { + crateName = "arrayvec"; + version = "0.7.6"; + edition = "2018"; + sha256 = "0l1fz4ccgv6pm609rif37sl5nv5k6lbzi7kkppgzqzh1vwix20kw"; + authors = [ + "bluss" + ]; + features = { + "borsh" = [ "dep:borsh" ]; + "default" = [ "std" ]; + "serde" = [ "dep:serde" ]; + "zeroize" = [ "dep:zeroize" ]; + }; + }; "async-broadcast" = rec { crateName = "async-broadcast"; version = "0.7.1"; @@ -2276,7 +2291,7 @@ rec { } { name = "unicode-width"; - packageId = "unicode-width"; + packageId = "unicode-width 0.1.13"; } ]; features = { @@ -2339,7 +2354,7 @@ rec { } { name = "unicode-width"; - packageId = "unicode-width"; + packageId = "unicode-width 0.1.13"; optional = true; } { @@ -5257,6 +5272,55 @@ rec { }; resolvedDefaultFeatures = [ "default" "serde" "std" ]; }; + "indicatif" = rec { + crateName = "indicatif"; + version = "0.17.11"; + edition = "2021"; + sha256 = "0db2b2r79r9x8x4lysq1ci9xm13c0xg0sqn3z960yh2bk2430fqq"; + dependencies = [ + { + name = "console"; + packageId = "console"; + usesDefaultFeatures = false; + features = [ "ansi-parsing" ]; + } + { + name = "number_prefix"; + packageId = "number_prefix"; + } + { + name = "portable-atomic"; + packageId = "portable-atomic"; + } + { + name = "unicode-width"; + packageId = "unicode-width 0.2.0"; + optional = true; + } + { + name = "vt100"; + packageId = "vt100"; + optional = true; + } + { + name = "web-time"; + packageId = "web-time"; + target = { target, features }: ("wasm32" == target."arch" or null); + } + ]; + features = { + "default" = [ "unicode-width" "console/unicode-width" ]; + "futures" = [ "dep:futures-core" ]; + "improved_unicode" = [ "unicode-segmentation" "unicode-width" "console/unicode-width" ]; + "in_memory" = [ "vt100" ]; + "rayon" = [ "dep:rayon" ]; + "tokio" = [ "dep:tokio" ]; + "unicode-segmentation" = [ "dep:unicode-segmentation" ]; + "unicode-width" = [ "dep:unicode-width" ]; + "vt100" = [ "dep:vt100" ]; + }; + resolvedDefaultFeatures = [ "default" "in_memory" "unicode-width" "vt100" ]; + }; "inout" = rec { crateName = "inout"; version = "0.1.3"; @@ -6214,7 +6278,7 @@ rec { } { name = "windows-targets"; - packageId = "windows-targets 0.48.5"; + packageId = "windows-targets 0.52.6"; target = { target, features }: (target."windows" or false); } ]; @@ -6725,6 +6789,19 @@ rec { }; resolvedDefaultFeatures = [ "proc-macro-crate" "std" ]; }; + "number_prefix" = rec { + crateName = "number_prefix"; + version = "0.4.0"; + edition = "2015"; + sha256 = "1wvh13wvlajqxkb1filsfzbrnq0vrmrw298v2j3sy82z1rm282w3"; + authors = [ + "Benjamin Sago " + ]; + features = { + "default" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; "numtoa" = rec { crateName = "numtoa"; version = "0.1.0"; @@ -7704,6 +7781,19 @@ rec { ]; }; + "portable-atomic" = rec { + crateName = "portable-atomic"; + version = "1.11.0"; + edition = "2018"; + sha256 = "0glb2wngflvfmg789qbf6dbnwcf6ai212fs7n0lf1c66rd49n3im"; + libName = "portable_atomic"; + features = { + "critical-section" = [ "dep:critical-section" ]; + "default" = [ "fallback" ]; + "serde" = [ "dep:serde" ]; + }; + resolvedDefaultFeatures = [ "default" "fallback" ]; + }; "powerfmt" = rec { crateName = "powerfmt"; version = "0.2.0"; @@ -10584,6 +10674,10 @@ rec { packageId = "indexmap 2.5.0"; features = [ "serde" ]; } + { + name = "indicatif"; + packageId = "indicatif"; + } { name = "k8s-openapi"; packageId = "k8s-openapi"; @@ -10651,6 +10745,10 @@ rec { name = "tracing"; packageId = "tracing"; } + { + name = "tracing-indicatif"; + packageId = "tracing-indicatif"; + } { name = "url"; packageId = "url"; @@ -11297,6 +11395,10 @@ rec { packageId = "indexmap 2.5.0"; features = [ "serde" ]; } + { + name = "indicatif"; + packageId = "indicatif"; + } { name = "lazy_static"; packageId = "lazy_static"; @@ -11365,6 +11467,10 @@ rec { name = "tracing"; packageId = "tracing"; } + { + name = "tracing-indicatif"; + packageId = "tracing-indicatif"; + } { name = "tracing-subscriber"; packageId = "tracing-subscriber"; @@ -13123,6 +13229,33 @@ rec { }; resolvedDefaultFeatures = [ "default" "once_cell" "std" ]; }; + "tracing-indicatif" = rec { + crateName = "tracing-indicatif"; + version = "0.3.9"; + edition = "2021"; + sha256 = "188anka0xqrjbd7bzj41854rqvf02qszs9l2jzpr7n0c1r1wl0c2"; + libName = "tracing_indicatif"; + dependencies = [ + { + name = "indicatif"; + packageId = "indicatif"; + features = [ "in_memory" ]; + } + { + name = "tracing"; + packageId = "tracing"; + } + { + name = "tracing-core"; + packageId = "tracing-core"; + } + { + name = "tracing-subscriber"; + packageId = "tracing-subscriber"; + } + ]; + + }; "tracing-log" = rec { crateName = "tracing-log"; version = "0.2.0"; @@ -13712,7 +13845,7 @@ rec { features = { }; }; - "unicode-width" = rec { + "unicode-width 0.1.13" = rec { crateName = "unicode-width"; version = "0.1.13"; edition = "2021"; @@ -13730,6 +13863,25 @@ rec { }; resolvedDefaultFeatures = [ "default" ]; }; + "unicode-width 0.2.0" = rec { + crateName = "unicode-width"; + version = "0.2.0"; + edition = "2021"; + sha256 = "1zd0r5vs52ifxn25rs06gxrgz8cmh4xpra922k0xlmrchib1kj0z"; + libName = "unicode_width"; + authors = [ + "kwantam " + "Manish Goregaokar " + ]; + features = { + "compiler_builtins" = [ "dep:compiler_builtins" ]; + "core" = [ "dep:core" ]; + "default" = [ "cjk" ]; + "rustc-dep-of-std" = [ "std" "core" "compiler_builtins" ]; + "std" = [ "dep:std" ]; + }; + resolvedDefaultFeatures = [ "cjk" "default" ]; + }; "unicode-xid" = rec { crateName = "unicode-xid"; version = "0.2.5"; @@ -14080,7 +14232,41 @@ rec { ]; }; - "vte" = rec { + "vt100" = rec { + crateName = "vt100"; + version = "0.15.2"; + edition = "2021"; + sha256 = "1pklc8y984axmxr0cd363srr2d27wd5rj15xlcmkjznvy0xqdkc4"; + authors = [ + "Jesse Luehrs " + ]; + dependencies = [ + { + name = "itoa"; + packageId = "itoa"; + } + { + name = "log"; + packageId = "log"; + } + { + name = "unicode-width"; + packageId = "unicode-width 0.1.13"; + } + { + name = "vte"; + packageId = "vte 0.11.1"; + } + ]; + devDependencies = [ + { + name = "vte"; + packageId = "vte 0.11.1"; + } + ]; + + }; + "vte 0.10.1" = rec { crateName = "vte"; version = "0.10.1"; edition = "2018"; @@ -14092,7 +14278,7 @@ rec { dependencies = [ { name = "arrayvec"; - packageId = "arrayvec"; + packageId = "arrayvec 0.5.2"; optional = true; usesDefaultFeatures = false; } @@ -14113,6 +14299,42 @@ rec { }; resolvedDefaultFeatures = [ "arrayvec" "default" "no_std" ]; }; + "vte 0.11.1" = rec { + crateName = "vte"; + version = "0.11.1"; + edition = "2021"; + sha256 = "15r1ff4j8ndqj9vsyil3wqwxhhl7jsz5g58f31n0h1wlpxgjn0pm"; + authors = [ + "Joe Wilm " + "Christian Duerr " + ]; + dependencies = [ + { + name = "arrayvec"; + packageId = "arrayvec 0.7.6"; + optional = true; + usesDefaultFeatures = false; + } + { + name = "utf8parse"; + packageId = "utf8parse"; + } + { + name = "vte_generate_state_changes"; + packageId = "vte_generate_state_changes"; + } + ]; + features = { + "ansi" = [ "log" ]; + "arrayvec" = [ "dep:arrayvec" ]; + "default" = [ "no_std" ]; + "log" = [ "dep:log" ]; + "nightly" = [ "utf8parse/nightly" ]; + "no_std" = [ "arrayvec" ]; + "serde" = [ "dep:serde" ]; + }; + resolvedDefaultFeatures = [ "arrayvec" "default" "no_std" ]; + }; "vte_generate_state_changes" = rec { crateName = "vte_generate_state_changes"; version = "0.1.2"; @@ -14999,7 +15221,7 @@ rec { dependencies = [ { name = "windows-sys"; - packageId = "windows-sys 0.48.0"; + packageId = "windows-sys 0.59.0"; target = { target, features }: (target."windows" or false); features = [ "Win32_Foundation" "Win32_Storage_FileSystem" "Win32_System_Console" "Win32_System_SystemInformation" ]; } @@ -15409,7 +15631,7 @@ rec { "Win32_Web" = [ "Win32" ]; "Win32_Web_InternetExplorer" = [ "Win32_Web" ]; }; - resolvedDefaultFeatures = [ "Win32" "Win32_Foundation" "Win32_Globalization" "Win32_Storage" "Win32_Storage_FileSystem" "Win32_System" "Win32_System_Com" "Win32_System_Console" "Win32_System_SystemInformation" "Win32_UI" "Win32_UI_Shell" "default" ]; + resolvedDefaultFeatures = [ "Win32" "Win32_Foundation" "Win32_Globalization" "Win32_System" "Win32_System_Com" "Win32_UI" "Win32_UI_Shell" "default" ]; }; "windows-sys 0.52.0" = rec { crateName = "windows-sys"; @@ -15916,7 +16138,7 @@ rec { "Win32_Web" = [ "Win32" ]; "Win32_Web_InternetExplorer" = [ "Win32_Web" ]; }; - resolvedDefaultFeatures = [ "Win32" "Win32_Foundation" "Win32_Networking" "Win32_Networking_WinSock" "Win32_System" "Win32_System_IO" "default" ]; + resolvedDefaultFeatures = [ "Win32" "Win32_Foundation" "Win32_Networking" "Win32_Networking_WinSock" "Win32_Storage" "Win32_Storage_FileSystem" "Win32_System" "Win32_System_Console" "Win32_System_IO" "Win32_System_SystemInformation" "default" ]; }; "windows-targets 0.48.5" = rec { crateName = "windows-targets"; From 6d80e341512eca4abfc65bc610b112ae5f6fac58 Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 19 May 2025 13:57:09 +0200 Subject: [PATCH 05/18] error handling documentation and print fixes --- rust/stackable-cockpit/src/platform/demo/spec.rs | 2 +- rust/stackable-cockpit/src/platform/manifests.rs | 2 +- rust/stackable-cockpit/src/platform/operator/mod.rs | 4 ++-- rust/stackable-cockpit/src/platform/release/spec.rs | 4 ++-- rust/stackable-cockpit/src/platform/stack/spec.rs | 4 ++-- rust/stackablectl/src/cmds/demo.rs | 6 +++--- rust/stackablectl/src/cmds/operator.rs | 12 ++++++------ rust/stackablectl/src/cmds/release.rs | 8 ++++---- rust/stackablectl/src/cmds/stack.rs | 6 +++--- rust/stackablectl/src/cmds/stacklet.rs | 4 ++-- rust/stackablectl/src/main.rs | 10 +++++----- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 94584013..0c090188 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -191,7 +191,7 @@ impl DemoSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("This is a valid progress template")); let params = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 1980ddf4..f5db6307 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -77,7 +77,7 @@ pub trait InstallManifestsExt { debug!("Installing manifests"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(), + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("This is a valid progress template") ); Span::current().pb_set_length(manifests.len() as u64); diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index 911dbd63..ce0d084c 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -195,7 +195,7 @@ impl OperatorSpec { ) -> Result<(), helm::Error> { info!(operator = %self, "Installing operator"); Span::current().pb_set_message(format!("Installing {}-operator", self.name).as_str()); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("This is a valid progress template")); let version = self.version.as_ref().map(|v| v.to_string()); let helm_name = self.helm_name(); @@ -231,7 +231,7 @@ impl OperatorSpec { { match helm::uninstall_release(&self.helm_name(), namespace.as_ref(), true) { Ok(status) => { - indicatif_println!("{}", status); + indicatif_println!("{status}"); Ok(()) } Err(err) => Err(err), diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index 472fc635..6f51d057 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -65,7 +65,7 @@ impl ReleaseSpec { ) -> Result<()> { info!("Installing release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(), + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("This is a valid progress template") ); include_products.iter().for_each(|product| { @@ -125,7 +125,7 @@ impl ReleaseSpec { info!("Uninstalling release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").unwrap(), + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("This is a valid progress template") ); Span::current().pb_set_length(self.products.len() as u64); diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index ea56abd2..53dc088f 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -205,7 +205,7 @@ impl StackSpec { chart_source: &ChartSourceType, ) -> Result<(), Error> { info!(self.release, "Trying to install release"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").expect("This is a valid progress template")); // Get the release by name let release = release_list @@ -229,7 +229,7 @@ impl StackSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").unwrap()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("This is a valid progress template")); let parameters = install_params .parameters diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index d3331a1a..94445f74 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -216,7 +216,7 @@ impl DemoArgs { async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result { info!("Listing demos"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching demo information").expect("This is a valid progress template") ); match args.output_type { @@ -271,7 +271,7 @@ async fn describe_cmd( ) -> Result { info!(demo_name = %args.demo_name, "Describing demo"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching demo information").expect("This is a valid progress template") ); let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { @@ -336,7 +336,7 @@ async fn install_cmd( ) -> Result { info!(demo_name = %args.demo_name, "Installing demo"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing demo").unwrap()); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing demo").expect("This is a valid progress template")); // Init result output and progress output let mut output = cli.result(); diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 7fd53a5b..2b4576e3 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -192,7 +192,7 @@ impl OperatorArgs { async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result { debug!("Listing operators"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching operator information").expect("This is a valid progress template") ); // Build map which maps artifacts to a chart source @@ -252,7 +252,7 @@ async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result Result { debug!(operator_name = %args.operator_name, "Describing operator"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching operator information").expect("This is a valid progress template") ); // Build map which maps artifacts to a chart source @@ -314,7 +314,7 @@ async fn describe_cmd(args: &OperatorDescribeArgs, cli: &Cli) -> Result Result { info!("Installing operator(s)"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing operator(s)").unwrap()); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing operator(s)").expect("This is a valid progress template")); args.local_cluster .install_if_needed() @@ -338,7 +338,7 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result Result Result { info!("Uninstalling operator(s)"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling operator(s)").unwrap()); + .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling operator(s)").expect("This is a valid progress template")); for operator in &args.operators { operator @@ -397,7 +397,7 @@ fn uninstall_cmd(args: &OperatorUninstallArgs, cli: &Cli) -> Result Result { info!("Listing installed operators"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching operator information").expect("This is a valid progress template") ); type ReleaseList = IndexMap; diff --git a/rust/stackablectl/src/cmds/release.rs b/rust/stackablectl/src/cmds/release.rs index 788b7200..2db56a83 100644 --- a/rust/stackablectl/src/cmds/release.rs +++ b/rust/stackablectl/src/cmds/release.rs @@ -160,7 +160,7 @@ async fn list_cmd( ) -> Result { info!("Listing releases"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching release information").expect("This is a valid progress template") ); match args.output_type { @@ -217,7 +217,7 @@ async fn describe_cmd( ) -> Result { info!(release = %args.release, "Describing release"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching release information").expect("This is a valid progress template") ); let release = release_list.get(&args.release); @@ -281,7 +281,7 @@ async fn install_cmd( ) -> Result { info!(release = %args.release, "Installing release"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing release").unwrap()); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing release").expect("This is a valid progress template")); match release_list.get(&args.release) { Some(release) => { @@ -332,7 +332,7 @@ async fn uninstall_cmd( release_list: release::ReleaseList, ) -> Result { Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling release").unwrap()); + .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling release").expect("This is a valid progress template")); match release_list.get(&args.release) { Some(release) => { diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index 5a30328d..8afb73b3 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -202,7 +202,7 @@ fn list_cmd( ) -> Result { info!("Listing stacks"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching stack information").expect("This is a valid progress template") ); match args.output_type { @@ -255,7 +255,7 @@ fn describe_cmd( ) -> Result { info!(stack_name = %args.stack_name, "Describing stack"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching stack information").expect("This is a valid progress template") ); match stack_list.get(&args.stack_name) { @@ -321,7 +321,7 @@ async fn install_cmd( ) -> Result { info!(stack_name = %args.stack_name, "Installing stack"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing stack").unwrap()); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing stack").expect("This is a valid progress template")); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index 0e046e4b..db733827 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -95,7 +95,7 @@ impl StackletArgs { async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result { info!("Listing installed stacklets"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("This is a valid progress template") ); let client = Client::new().await.context(KubeClientCreateSnafu)?; @@ -211,7 +211,7 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result Result { info!("Displaying stacklet credentials"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information").unwrap(), + &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("This is a valid progress template") ); let client = Client::new().await.context(KubeClientCreateSnafu)?; diff --git a/rust/stackablectl/src/main.rs b/rust/stackablectl/src/main.rs index 11065e22..a73a6715 100644 --- a/rust/stackablectl/src/main.rs +++ b/rust/stackablectl/src/main.rs @@ -3,7 +3,7 @@ use dotenvy::dotenv; use indicatif::ProgressStyle; use stackablectl::cli::{Cli, Error}; use tracing::metadata::LevelFilter; -use tracing_indicatif::{indicatif_println, IndicatifLayer}; +use tracing_indicatif::{indicatif_eprintln, IndicatifLayer}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[snafu::report] @@ -19,14 +19,14 @@ async fn main() -> Result<(), Error> { .with_target(false); let indicatif_layer = IndicatifLayer::new() - .with_progress_style(ProgressStyle::with_template("").unwrap()) + .with_progress_style(ProgressStyle::with_template("").expect("This is a valid progress template")) .with_max_progress_bars( 15, Some( ProgressStyle::with_template( - "...and {pending_progress_bars} more processes not shown above.", + "...and {pending_progress_bars} more processes not shown above." ) - .unwrap(), + .expect("This is a valid progress template") ), ); @@ -56,7 +56,7 @@ async fn main() -> Result<(), Error> { Ok(_) => (), Err(err) => { if !err.not_found() { - indicatif_println!("{err}") + indicatif_eprintln!("{err}") } } } From d03f5482e528b960c27762a94246771725c4d297 Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 19 May 2025 14:39:18 +0200 Subject: [PATCH 06/18] refactor subscriber init --- rust/stackable-cockpit/src/platform/demo/spec.rs | 2 +- rust/stackable-cockpit/src/platform/manifests.rs | 2 +- .../src/platform/operator/mod.rs | 2 +- .../src/platform/release/spec.rs | 4 ++-- .../stackable-cockpit/src/platform/stack/spec.rs | 4 ++-- rust/stackablectl/src/cmds/demo.rs | 6 +++--- rust/stackablectl/src/cmds/operator.rs | 10 +++++----- rust/stackablectl/src/cmds/release.rs | 8 ++++---- rust/stackablectl/src/cmds/stack.rs | 6 +++--- rust/stackablectl/src/cmds/stacklet.rs | 4 ++-- rust/stackablectl/src/main.rs | 16 ++++++---------- 11 files changed, 30 insertions(+), 34 deletions(-) diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 0c090188..423772a8 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -191,7 +191,7 @@ impl DemoSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("This is a valid progress template")); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("valid progress template")); let params = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index f5db6307..aa2df022 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -77,7 +77,7 @@ pub trait InstallManifestsExt { debug!("Installing manifests"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("This is a valid progress template") + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template") ); Span::current().pb_set_length(manifests.len() as u64); diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index ce0d084c..f23d44d5 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -195,7 +195,7 @@ impl OperatorSpec { ) -> Result<(), helm::Error> { info!(operator = %self, "Installing operator"); Span::current().pb_set_message(format!("Installing {}-operator", self.name).as_str()); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("This is a valid progress template")); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template")); let version = self.version.as_ref().map(|v| v.to_string()); let helm_name = self.helm_name(); diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index 6f51d057..a80a73b8 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -65,7 +65,7 @@ impl ReleaseSpec { ) -> Result<()> { info!("Installing release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("This is a valid progress template") + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template") ); include_products.iter().for_each(|product| { @@ -125,7 +125,7 @@ impl ReleaseSpec { info!("Uninstalling release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("This is a valid progress template") + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template") ); Span::current().pb_set_length(self.products.len() as u64); diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index 53dc088f..6a679b98 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -205,7 +205,7 @@ impl StackSpec { chart_source: &ChartSourceType, ) -> Result<(), Error> { info!(self.release, "Trying to install release"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").expect("This is a valid progress template")); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").expect("valid progress template")); // Get the release by name let release = release_list @@ -229,7 +229,7 @@ impl StackSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("This is a valid progress template")); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("valid progress template")); let parameters = install_params .parameters diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 94445f74..533211e8 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -216,7 +216,7 @@ impl DemoArgs { async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result { info!("Listing demos"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching demo information").expect("valid progress template") ); match args.output_type { @@ -271,7 +271,7 @@ async fn describe_cmd( ) -> Result { info!(demo_name = %args.demo_name, "Describing demo"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching demo information").expect("valid progress template") ); let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { @@ -336,7 +336,7 @@ async fn install_cmd( ) -> Result { info!(demo_name = %args.demo_name, "Installing demo"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing demo").expect("This is a valid progress template")); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing demo").expect("valid progress template")); // Init result output and progress output let mut output = cli.result(); diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 2b4576e3..3a941a68 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -192,7 +192,7 @@ impl OperatorArgs { async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result { debug!("Listing operators"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching operator information").expect("valid progress template") ); // Build map which maps artifacts to a chart source @@ -252,7 +252,7 @@ async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result Result { debug!(operator_name = %args.operator_name, "Describing operator"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching operator information").expect("valid progress template") ); // Build map which maps artifacts to a chart source @@ -314,7 +314,7 @@ async fn describe_cmd(args: &OperatorDescribeArgs, cli: &Cli) -> Result Result { info!("Installing operator(s)"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing operator(s)").expect("This is a valid progress template")); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing operator(s)").expect("valid progress template")); args.local_cluster .install_if_needed() @@ -365,7 +365,7 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result Result { info!("Uninstalling operator(s)"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling operator(s)").expect("This is a valid progress template")); + .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling operator(s)").expect("valid progress template")); for operator in &args.operators { operator @@ -397,7 +397,7 @@ fn uninstall_cmd(args: &OperatorUninstallArgs, cli: &Cli) -> Result Result { info!("Listing installed operators"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching operator information").expect("valid progress template") ); type ReleaseList = IndexMap; diff --git a/rust/stackablectl/src/cmds/release.rs b/rust/stackablectl/src/cmds/release.rs index 2db56a83..8d1da1e4 100644 --- a/rust/stackablectl/src/cmds/release.rs +++ b/rust/stackablectl/src/cmds/release.rs @@ -160,7 +160,7 @@ async fn list_cmd( ) -> Result { info!("Listing releases"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching release information").expect("valid progress template") ); match args.output_type { @@ -217,7 +217,7 @@ async fn describe_cmd( ) -> Result { info!(release = %args.release, "Describing release"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching release information").expect("valid progress template") ); let release = release_list.get(&args.release); @@ -281,7 +281,7 @@ async fn install_cmd( ) -> Result { info!(release = %args.release, "Installing release"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing release").expect("This is a valid progress template")); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing release").expect("valid progress template")); match release_list.get(&args.release) { Some(release) => { @@ -332,7 +332,7 @@ async fn uninstall_cmd( release_list: release::ReleaseList, ) -> Result { Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling release").expect("This is a valid progress template")); + .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling release").expect("valid progress template")); match release_list.get(&args.release) { Some(release) => { diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index 8afb73b3..c80569f5 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -202,7 +202,7 @@ fn list_cmd( ) -> Result { info!("Listing stacks"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stack information").expect("valid progress template") ); match args.output_type { @@ -255,7 +255,7 @@ fn describe_cmd( ) -> Result { info!(stack_name = %args.stack_name, "Describing stack"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stack information").expect("valid progress template") ); match stack_list.get(&args.stack_name) { @@ -321,7 +321,7 @@ async fn install_cmd( ) -> Result { info!(stack_name = %args.stack_name, "Installing stack"); Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing stack").expect("This is a valid progress template")); + .pb_set_style(&ProgressStyle::with_template("{spinner} Installing stack").expect("valid progress template")); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index db733827..bf148b8d 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -95,7 +95,7 @@ impl StackletArgs { async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result { info!("Listing installed stacklets"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("valid progress template") ); let client = Client::new().await.context(KubeClientCreateSnafu)?; @@ -211,7 +211,7 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result Result { info!("Displaying stacklet credentials"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("This is a valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("valid progress template") ); let client = Client::new().await.context(KubeClientCreateSnafu)?; diff --git a/rust/stackablectl/src/main.rs b/rust/stackablectl/src/main.rs index a73a6715..e2d24226 100644 --- a/rust/stackablectl/src/main.rs +++ b/rust/stackablectl/src/main.rs @@ -2,7 +2,7 @@ use clap::Parser; use dotenvy::dotenv; use indicatif::ProgressStyle; use stackablectl::cli::{Cli, Error}; -use tracing::metadata::LevelFilter; +use tracing::{metadata::LevelFilter, Level}; use tracing_indicatif::{indicatif_eprintln, IndicatifLayer}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; @@ -19,23 +19,18 @@ async fn main() -> Result<(), Error> { .with_target(false); let indicatif_layer = IndicatifLayer::new() - .with_progress_style(ProgressStyle::with_template("").expect("This is a valid progress template")) + .with_progress_style(ProgressStyle::with_template("").expect("valid progress template")) .with_max_progress_bars( 15, Some( ProgressStyle::with_template( "...and {pending_progress_bars} more processes not shown above." ) - .expect("This is a valid progress template") + .expect("valid progress template") ), ); - let level_filter = match app.log_level { - Some(level) => LevelFilter::from_level(level), - None => LevelFilter::INFO, - }; - - if level_filter == LevelFilter::DEBUG { + if let Some(level) = app.log_level { tracing_subscriber::registry() .with( fmt::layer() @@ -43,10 +38,11 @@ async fn main() -> Result<(), Error> { .pretty() .with_writer(indicatif_layer.get_stderr_writer()), ) + .with(LevelFilter::from_level(level)) .init(); } else { tracing_subscriber::registry() - .with(level_filter) + .with(LevelFilter::from_level(Level::INFO)) .with(indicatif_layer) .init(); } From 1f2c9196e2891f328b63dd0abd19b85e5349e496 Mon Sep 17 00:00:00 2001 From: Xenia Date: Mon, 19 May 2025 15:06:53 +0200 Subject: [PATCH 07/18] Update rust/stackable-cockpit/src/platform/operator/mod.rs Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --- rust/stackable-cockpit/src/platform/operator/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index f23d44d5..9ee0dbd5 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -194,7 +194,7 @@ impl OperatorSpec { chart_source: &ChartSourceType, ) -> Result<(), helm::Error> { info!(operator = %self, "Installing operator"); - Span::current().pb_set_message(format!("Installing {}-operator", self.name).as_str()); + Span::current().pb_set_message(format!("Installing {name}-operator", name = self.name).as_str()); Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template")); let version = self.version.as_ref().map(|v| v.to_string()); From 3a37410e72ee8e75fce3089137425129fea6b0c5 Mon Sep 17 00:00:00 2001 From: Xenia Date: Mon, 19 May 2025 15:07:15 +0200 Subject: [PATCH 08/18] Update rust/stackable-cockpit/src/platform/operator/mod.rs Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com> --- rust/stackable-cockpit/src/platform/operator/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index 9ee0dbd5..0b0d40b5 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -65,9 +65,9 @@ impl Display for OperatorSpec { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, - "{}{}", - self.name, - match &self.version { + "{name}{version_selector}", + name = self.name, + version_selector = match &self.version { Some(v) => format!("={v}"), None => "".into(), } From ba37ff76772d9439449fe6fe6ed04919b86b45dc Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 19 May 2025 19:39:23 +0200 Subject: [PATCH 09/18] add progress indication for installing manifests --- .../src/platform/manifests.rs | 144 ++++++++++-------- 1 file changed, 78 insertions(+), 66 deletions(-) diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index aa2df022..018706de 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_operator::kvp::Labels; -use tracing::{Span, debug, info, instrument}; +use tracing::{debug, info, info_span, instrument, Instrument as _, Span}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ @@ -87,74 +87,86 @@ pub trait InstallManifestsExt { parameters.insert("NAMESPACE".to_owned(), namespace.to_owned()); for manifest in manifests { - match manifest { - ManifestSpec::HelmChart(helm_file) => { - debug!(helm_file, "Installing manifest from Helm chart"); - - // Read Helm chart YAML and apply templating - let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { - path_or_url: helm_file.clone(), - })?; - - let helm_chart: helm::Chart = transfer_client - .get(&helm_file, &Template::new(¶meters).then(Yaml::new())) - .await - .context(FileTransferSnafu)?; - - info!(helm_chart.name, helm_chart.version, "Installing Helm chart",); - - // Assumption: that all manifest helm charts refer to repos not registries - helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context( - AddHelmRepositorySnafu { - repo_name: helm_chart.repo.name.clone(), - }, - )?; - - // Serialize chart options to string - let values_yaml = serde_yaml::to_string(&helm_chart.options) - .context(SerializeOptionsSnafu)?; - - // Install the Helm chart using the Helm wrapper - helm::install_release_from_repo_or_registry( - &helm_chart.release_name, - helm::ChartVersion { - chart_source: &helm_chart.repo.name, - chart_name: &helm_chart.name, - chart_version: Some(&helm_chart.version), - }, - Some(&values_yaml), - namespace, - true, - ) - .context(InstallHelmReleaseSnafu { - release_name: helm_chart.release_name, - })?; + let span = info_span!("install_manifests_iter"); + + let parameters = parameters.clone(); + let labels = labels.clone(); + async move { + match manifest { + ManifestSpec::HelmChart(helm_file) => { + debug!(helm_file, "Installing manifest from Helm chart"); + + // Read Helm chart YAML and apply templating + let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { + path_or_url: helm_file.clone(), + })?; + + let helm_chart: helm::Chart = transfer_client + .get(&helm_file, &Template::new(¶meters).then(Yaml::new())) + .await + .context(FileTransferSnafu)?; + + info!(helm_chart.name, helm_chart.version, "Installing Helm chart",); + Span::current().pb_set_message(format!("Installing {name} Helm chart", name = helm_chart.name).as_str()); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template")); + + // Assumption: that all manifest helm charts refer to repos not registries + helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context( + AddHelmRepositorySnafu { + repo_name: helm_chart.repo.name.clone(), + }, + )?; + + // Serialize chart options to string + let values_yaml = serde_yaml::to_string(&helm_chart.options) + .context(SerializeOptionsSnafu)?; + + // Install the Helm chart using the Helm wrapper + helm::install_release_from_repo_or_registry( + &helm_chart.release_name, + helm::ChartVersion { + chart_source: &helm_chart.repo.name, + chart_name: &helm_chart.name, + chart_version: Some(&helm_chart.version), + }, + Some(&values_yaml), + namespace, + true, + ) + .context(InstallHelmReleaseSnafu { + release_name: helm_chart.release_name, + })?; + } + ManifestSpec::PlainYaml(manifest_file) => { + debug!(manifest_file, "Installing YAML manifest"); + Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing YAML manifest").expect("valid progress template")); + + // Read YAML manifest and apply templating + let path_or_url = + manifest_file + .into_path_or_url() + .context(ParsePathOrUrlSnafu { + path_or_url: manifest_file.clone(), + })?; + + let manifests = transfer_client + .get(&path_or_url, &Template::new(¶meters)) + .await + .context(FileTransferSnafu)?; + + client + .deploy_manifests(&manifests, namespace, labels.clone()) + .await + .context(DeployManifestSnafu)?; + } } - ManifestSpec::PlainYaml(manifest_file) => { - debug!(manifest_file, "Installing YAML manifest"); - - // Read YAML manifest and apply templating - let path_or_url = - manifest_file - .into_path_or_url() - .context(ParsePathOrUrlSnafu { - path_or_url: manifest_file.clone(), - })?; - - let manifests = transfer_client - .get(&path_or_url, &Template::new(¶meters)) - .await - .context(FileTransferSnafu)?; - - client - .deploy_manifests(&manifests, namespace, labels.clone()) - .await - .context(DeployManifestSnafu)? - } - } + + Ok::<(), Error>(()) + + }.instrument(span).await?; Span::current().pb_inc(1); - } + }; Ok(()) } From 591d3934ce74e57bdb8e0447ca5392d026b72ac5 Mon Sep 17 00:00:00 2001 From: xeniape Date: Mon, 19 May 2025 19:41:00 +0200 Subject: [PATCH 10/18] remove semicolon --- rust/stackable-cockpit/src/platform/manifests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 018706de..f74d5525 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -166,7 +166,7 @@ pub trait InstallManifestsExt { }.instrument(span).await?; Span::current().pb_inc(1); - }; + } Ok(()) } From ed760d59b94f70fc9ca2c22a1b484556b4687906 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Tue, 20 May 2025 14:34:22 +0200 Subject: [PATCH 11/18] chore: cargo fmt ```shell cargo +nightly-2025-01-15 fmt --all ``` --- rust/stackable-cockpit/src/engine/kind/mod.rs | 9 +-- rust/stackable-cockpit/src/oci.rs | 9 +-- .../src/platform/demo/spec.rs | 5 +- .../src/platform/manifests.rs | 32 +++++++---- .../src/platform/operator/mod.rs | 16 +++--- .../src/platform/release/spec.rs | 10 ++-- .../src/platform/stack/spec.rs | 10 +++- .../src/platform/stacklet/mod.rs | 13 ++--- .../stackable-cockpit/src/utils/k8s/client.rs | 13 ++--- rust/stackable-cockpit/src/utils/params.rs | 55 +++++++------------ rust/stackable-cockpitd/src/handlers/ui.rs | 13 ++--- rust/stackablectl/src/cmds/demo.rs | 19 ++++--- rust/stackablectl/src/cmds/operator.rs | 21 ++++--- rust/stackablectl/src/cmds/release.rs | 18 ++++-- rust/stackablectl/src/cmds/stack.rs | 19 ++++--- rust/stackablectl/src/cmds/stacklet.rs | 6 +- rust/stackablectl/src/main.rs | 8 +-- rust/xtask/src/openapi.rs | 9 +-- 18 files changed, 149 insertions(+), 136 deletions(-) diff --git a/rust/stackable-cockpit/src/engine/kind/mod.rs b/rust/stackable-cockpit/src/engine/kind/mod.rs index b3f86401..eabe318e 100644 --- a/rust/stackable-cockpit/src/engine/kind/mod.rs +++ b/rust/stackable-cockpit/src/engine/kind/mod.rs @@ -141,12 +141,9 @@ impl Cluster { .await .context(CommandFailedToRunSnafu)?; - ensure!( - output.status.success(), - CommandErroredOutSnafu { - error: String::from_utf8_lossy(&output.stderr) - } - ); + ensure!(output.status.success(), CommandErroredOutSnafu { + error: String::from_utf8_lossy(&output.stderr) + }); let output = String::from_utf8_lossy(&output.stdout); Ok(output.lines().any(|name| name == cluster_name)) diff --git a/rust/stackable-cockpit/src/oci.rs b/rust/stackable-cockpit/src/oci.rs index 337cc876..5e350bd3 100644 --- a/rust/stackable-cockpit/src/oci.rs +++ b/rust/stackable-cockpit/src/oci.rs @@ -128,12 +128,9 @@ pub async fn get_oci_index<'a>() -> Result HELM_REPO_NAME_TEST, HELM_REPO_NAME_DEV, ] { - source_index_files.insert( - repo_name, - ChartSourceMetadata { - entries: HashMap::new(), - }, - ); + source_index_files.insert(repo_name, ChartSourceMetadata { + entries: HashMap::new(), + }); } let base_url = format!("https://{HELM_OCI_BASE}/api/v2.0"); diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 423772a8..2ac9d3c1 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -191,7 +191,10 @@ impl DemoSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing manifests") + .expect("valid progress template"), + ); let params = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index f74d5525..68d4a6db 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_operator::kvp::Labels; -use tracing::{debug, info, info_span, instrument, Instrument as _, Span}; +use tracing::{Instrument as _, Span, debug, info, info_span, instrument}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ @@ -77,7 +77,8 @@ pub trait InstallManifestsExt { debug!("Installing manifests"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template") + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}") + .expect("valid progress template"), ); Span::current().pb_set_length(manifests.len() as u64); @@ -97,9 +98,10 @@ pub trait InstallManifestsExt { debug!(helm_file, "Installing manifest from Helm chart"); // Read Helm chart YAML and apply templating - let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { - path_or_url: helm_file.clone(), - })?; + let helm_file = + helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { + path_or_url: helm_file.clone(), + })?; let helm_chart: helm::Chart = transfer_client .get(&helm_file, &Template::new(¶meters).then(Yaml::new())) @@ -107,8 +109,14 @@ pub trait InstallManifestsExt { .context(FileTransferSnafu)?; info!(helm_chart.name, helm_chart.version, "Installing Helm chart",); - Span::current().pb_set_message(format!("Installing {name} Helm chart", name = helm_chart.name).as_str()); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template")); + Span::current().pb_set_message( + format!("Installing {name} Helm chart", name = helm_chart.name) + .as_str(), + ); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} {msg}") + .expect("valid progress template"), + ); // Assumption: that all manifest helm charts refer to repos not registries helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context( @@ -139,7 +147,10 @@ pub trait InstallManifestsExt { } ManifestSpec::PlainYaml(manifest_file) => { debug!(manifest_file, "Installing YAML manifest"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing YAML manifest").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing YAML manifest") + .expect("valid progress template"), + ); // Read YAML manifest and apply templating let path_or_url = @@ -162,8 +173,9 @@ pub trait InstallManifestsExt { } Ok::<(), Error>(()) - - }.instrument(span).await?; + } + .instrument(span) + .await?; Span::current().pb_inc(1); } diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index 0b0d40b5..376122c1 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -4,7 +4,7 @@ use indicatif::ProgressStyle; use semver::Version; use serde::Serialize; use snafu::{ResultExt, Snafu, ensure}; -use tracing::{info, instrument, Span}; +use tracing::{Span, info, instrument}; use tracing_indicatif::{indicatif_println, span_ext::IndicatifSpanExt}; use crate::{ @@ -93,10 +93,9 @@ impl FromStr for OperatorSpec { ensure!(len <= 2, InvalidEqualSignCountSnafu); // Check if the provided operator name is in the list of valid operators - ensure!( - VALID_OPERATORS.contains(&parts[0]), - InvalidNameSnafu { name: parts[0] } - ); + ensure!(VALID_OPERATORS.contains(&parts[0]), InvalidNameSnafu { + name: parts[0] + }); // If there is only one part, the input didn't include // the optional version identifier @@ -194,8 +193,11 @@ impl OperatorSpec { chart_source: &ChartSourceType, ) -> Result<(), helm::Error> { info!(operator = %self, "Installing operator"); - Span::current().pb_set_message(format!("Installing {name}-operator", name = self.name).as_str()); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template")); + Span::current() + .pb_set_message(format!("Installing {name}-operator", name = self.name).as_str()); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template"), + ); let version = self.version.as_ref().map(|v| v.to_string()); let helm_name = self.helm_name(); diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index a80a73b8..12dd00d3 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -4,8 +4,8 @@ use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::JoinError; -use tracing::{info, instrument, Instrument, Span}; -use tracing_indicatif::{span_ext::IndicatifSpanExt as _}; +use tracing::{Instrument, Span, info, instrument}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(feature = "openapi")] use utoipa::ToSchema; @@ -65,7 +65,8 @@ impl ReleaseSpec { ) -> Result<()> { info!("Installing release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template") + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}") + .expect("valid progress template"), ); include_products.iter().for_each(|product| { @@ -125,7 +126,8 @@ impl ReleaseSpec { info!("Uninstalling release"); Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}").expect("valid progress template") + &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}") + .expect("valid progress template"), ); Span::current().pb_set_length(self.products.len() as u64); diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index 6a679b98..4fd47f66 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -205,7 +205,10 @@ impl StackSpec { chart_source: &ChartSourceType, ) -> Result<(), Error> { info!(self.release, "Trying to install release"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing operators").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing operators") + .expect("valid progress template"), + ); // Get the release by name let release = release_list @@ -229,7 +232,10 @@ impl StackSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); - Span::current().pb_set_style(&ProgressStyle::with_template("{spinner} Installing manifests").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing manifests") + .expect("valid progress template"), + ); let parameters = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/stacklet/mod.rs b/rust/stackable-cockpit/src/platform/stacklet/mod.rs index 6f7a3e0d..7c6e6d20 100644 --- a/rust/stackable-cockpit/src/platform/stacklet/mod.rs +++ b/rust/stackable-cockpit/src/platform/stacklet/mod.rs @@ -170,14 +170,11 @@ fn build_products_gvk_list<'a>(product_names: &[&'a str]) -> IndexMap<&'a str, G for product_name in product_names { // Why? Just why? Can we please make this consistent? if *product_name == "spark-history-server" { - map.insert( - *product_name, - GroupVersionKind { - group: "spark.stackable.tech".into(), - version: "v1alpha1".into(), - kind: "SparkHistoryServer".into(), - }, - ); + map.insert(*product_name, GroupVersionKind { + group: "spark.stackable.tech".into(), + version: "v1alpha1".into(), + kind: "SparkHistoryServer".into(), + }); continue; } diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index 48e41735..c87b7118 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -354,16 +354,13 @@ impl Client { pub async fn create_namespace(&self, name: String) -> Result<()> { let namespace_api: Api = Api::all(self.client.clone()); namespace_api - .create( - &PostParams::default(), - &Namespace { - metadata: ObjectMeta { - name: Some(name), - ..Default::default() - }, + .create(&PostParams::default(), &Namespace { + metadata: ObjectMeta { + name: Some(name), ..Default::default() }, - ) + ..Default::default() + }) .await .context(KubeClientPatchSnafu)?; diff --git a/rust/stackable-cockpit/src/utils/params.rs b/rust/stackable-cockpit/src/utils/params.rs index 65299350..623aeac4 100644 --- a/rust/stackable-cockpit/src/utils/params.rs +++ b/rust/stackable-cockpit/src/utils/params.rs @@ -281,23 +281,17 @@ mod test { let p = iter.next(); assert!(p.is_some()); - assert_eq!( - p.unwrap(), - &RawParameter { - name: "param1".into(), - value: "value1".into() - } - ); + assert_eq!(p.unwrap(), &RawParameter { + name: "param1".into(), + value: "value1".into() + }); let p = iter.next(); assert!(p.is_some()); - assert_eq!( - p.unwrap(), - &RawParameter { - name: "param2".into(), - value: "value2".into() - } - ); + assert_eq!(p.unwrap(), &RawParameter { + name: "param2".into(), + value: "value2".into() + }); let p = iter.next(); assert!(p.is_none()); @@ -315,23 +309,17 @@ mod test { let p = iter.next(); assert!(p.is_some()); - assert_eq!( - p.unwrap(), - &RawParameter { - name: "param1".into(), - value: "value1".into() - } - ); + assert_eq!(p.unwrap(), &RawParameter { + name: "param1".into(), + value: "value1".into() + }); let p = iter.next(); assert!(p.is_some()); - assert_eq!( - p.unwrap(), - &RawParameter { - name: "param2".into(), - value: "value2".into() - } - ); + assert_eq!(p.unwrap(), &RawParameter { + name: "param2".into(), + value: "value2".into() + }); let p = iter.next(); assert!(p.is_none()); @@ -379,13 +367,10 @@ mod test { match input.into_params(valid_parameters) { Ok(validated) => panic!("SHOULD FAIL: {validated:?}"), - Err(err) => assert_eq!( - err, - IntoParametersError::InvalidParameter { - parameter: "param2".into(), - expected: "param1".into() - } - ), + Err(err) => assert_eq!(err, IntoParametersError::InvalidParameter { + parameter: "param2".into(), + expected: "param1".into() + }), } } } diff --git a/rust/stackable-cockpitd/src/handlers/ui.rs b/rust/stackable-cockpitd/src/handlers/ui.rs index e250e0bb..9abdb02b 100644 --- a/rust/stackable-cockpitd/src/handlers/ui.rs +++ b/rust/stackable-cockpitd/src/handlers/ui.rs @@ -18,14 +18,11 @@ async fn ui() -> Html<&'static str> { } async fn asset(Path(name): Path) -> impl IntoResponse { ( - [( - CONTENT_TYPE, - match name.rsplit_once('.') { - Some((_, "js")) => HeaderValue::from_static("text/javascript"), - Some((_, "css")) => HeaderValue::from_static("text/css"), - _ => HeaderValue::from_static("application/octet-stream"), - }, - )], + [(CONTENT_TYPE, match name.rsplit_once('.') { + Some((_, "js")) => HeaderValue::from_static("text/javascript"), + Some((_, "css")) => HeaderValue::from_static("text/css"), + _ => HeaderValue::from_static("application/octet-stream"), + })], stackable_cockpit_web::ASSETS[&name], ) } diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 533211e8..e99b5860 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -174,10 +174,9 @@ impl DemoArgs { let release_branch = match &self.release { Some(release) => { - ensure!( - release_list.contains_key(release), - NoSuchReleaseSnafu { release } - ); + ensure!(release_list.contains_key(release), NoSuchReleaseSnafu { + release + }); if release == "dev" { "main".to_string() @@ -216,7 +215,8 @@ impl DemoArgs { async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result { info!("Listing demos"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching demo information") + .expect("valid progress template"), ); match args.output_type { @@ -271,7 +271,8 @@ async fn describe_cmd( ) -> Result { info!(demo_name = %args.demo_name, "Describing demo"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching demo information") + .expect("valid progress template"), ); let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { @@ -335,8 +336,10 @@ async fn install_cmd( release_branch: &str, ) -> Result { info!(demo_name = %args.demo_name, "Installing demo"); - Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing demo").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing demo") + .expect("valid progress template"), + ); // Init result output and progress output let mut output = cli.result(); diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index 3a941a68..a70b21ca 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -192,7 +192,8 @@ impl OperatorArgs { async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result { debug!("Listing operators"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching operator information") + .expect("valid progress template"), ); // Build map which maps artifacts to a chart source @@ -252,7 +253,8 @@ async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result Result { debug!(operator_name = %args.operator_name, "Describing operator"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching operator information") + .expect("valid progress template"), ); // Build map which maps artifacts to a chart source @@ -313,8 +315,10 @@ async fn describe_cmd(args: &OperatorDescribeArgs, cli: &Cli) -> Result Result { info!("Installing operator(s)"); - Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing operator(s)").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing operator(s)") + .expect("valid progress template"), + ); args.local_cluster .install_if_needed() @@ -364,8 +368,10 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result Result { info!("Uninstalling operator(s)"); - Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling operator(s)").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Uninstalling operator(s)") + .expect("valid progress template"), + ); for operator in &args.operators { operator @@ -397,7 +403,8 @@ fn uninstall_cmd(args: &OperatorUninstallArgs, cli: &Cli) -> Result Result { info!("Listing installed operators"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching operator information") + .expect("valid progress template"), ); type ReleaseList = IndexMap; diff --git a/rust/stackablectl/src/cmds/release.rs b/rust/stackablectl/src/cmds/release.rs index 8d1da1e4..f400f64a 100644 --- a/rust/stackablectl/src/cmds/release.rs +++ b/rust/stackablectl/src/cmds/release.rs @@ -160,7 +160,8 @@ async fn list_cmd( ) -> Result { info!("Listing releases"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching release information") + .expect("valid progress template"), ); match args.output_type { @@ -217,7 +218,8 @@ async fn describe_cmd( ) -> Result { info!(release = %args.release, "Describing release"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching release information") + .expect("valid progress template"), ); let release = release_list.get(&args.release); @@ -280,8 +282,10 @@ async fn install_cmd( release_list: release::ReleaseList, ) -> Result { info!(release = %args.release, "Installing release"); - Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing release").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing release") + .expect("valid progress template"), + ); match release_list.get(&args.release) { Some(release) => { @@ -331,8 +335,10 @@ async fn uninstall_cmd( cli: &Cli, release_list: release::ReleaseList, ) -> Result { - Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Uninstalling release").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Uninstalling release") + .expect("valid progress template"), + ); match release_list.get(&args.release) { Some(release) => { diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index c80569f5..f0393672 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -160,10 +160,9 @@ impl StackArgs { let release_branch = match &self.release { Some(release) => { - ensure!( - release_list.contains_key(release), - NoSuchReleaseSnafu { release } - ); + ensure!(release_list.contains_key(release), NoSuchReleaseSnafu { + release + }); if release == "dev" { "main".to_string() @@ -202,7 +201,8 @@ fn list_cmd( ) -> Result { info!("Listing stacks"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stack information") + .expect("valid progress template"), ); match args.output_type { @@ -255,7 +255,8 @@ fn describe_cmd( ) -> Result { info!(stack_name = %args.stack_name, "Describing stack"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stack information") + .expect("valid progress template"), ); match stack_list.get(&args.stack_name) { @@ -320,8 +321,10 @@ async fn install_cmd( transfer_client: &xfer::Client, ) -> Result { info!(stack_name = %args.stack_name, "Installing stack"); - Span::current() - .pb_set_style(&ProgressStyle::with_template("{spinner} Installing stack").expect("valid progress template")); + Span::current().pb_set_style( + &ProgressStyle::with_template("{spinner} Installing stack") + .expect("valid progress template"), + ); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index bf148b8d..3ba85018 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -95,7 +95,8 @@ impl StackletArgs { async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result { info!("Listing installed stacklets"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stacklet information") + .expect("valid progress template"), ); let client = Client::new().await.context(KubeClientCreateSnafu)?; @@ -211,7 +212,8 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result Result { info!("Displaying stacklet credentials"); Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information").expect("valid progress template") + &ProgressStyle::with_template("{spinner} Fetching stacklet information") + .expect("valid progress template"), ); let client = Client::new().await.context(KubeClientCreateSnafu)?; diff --git a/rust/stackablectl/src/main.rs b/rust/stackablectl/src/main.rs index e2d24226..ca324ba5 100644 --- a/rust/stackablectl/src/main.rs +++ b/rust/stackablectl/src/main.rs @@ -2,8 +2,8 @@ use clap::Parser; use dotenvy::dotenv; use indicatif::ProgressStyle; use stackablectl::cli::{Cli, Error}; -use tracing::{metadata::LevelFilter, Level}; -use tracing_indicatif::{indicatif_eprintln, IndicatifLayer}; +use tracing::{Level, metadata::LevelFilter}; +use tracing_indicatif::{IndicatifLayer, indicatif_eprintln}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; #[snafu::report] @@ -24,9 +24,9 @@ async fn main() -> Result<(), Error> { 15, Some( ProgressStyle::with_template( - "...and {pending_progress_bars} more processes not shown above." + "...and {pending_progress_bars} more processes not shown above.", ) - .expect("valid progress template") + .expect("valid progress template"), ), ); diff --git a/rust/xtask/src/openapi.rs b/rust/xtask/src/openapi.rs index 270e64fb..693c3e02 100644 --- a/rust/xtask/src/openapi.rs +++ b/rust/xtask/src/openapi.rs @@ -35,12 +35,9 @@ pub fn generate() -> Result<(), GenOpenapiError> { .write_all(openapi_json.as_bytes()) .context(WriteOpenapiSchemaSnafu)?; let status = codegen.wait().context(ImportOpenapiSchemaRunSnafu)?; - ensure!( - status.success(), - ImportOpenapiSchemaSnafu { - error_code: status.code() - } - ); + ensure!(status.success(), ImportOpenapiSchemaSnafu { + error_code: status.code() + }); Ok(()) } From 487df5a18e23e5772536c36a4626dd730f189ede Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Tue, 20 May 2025 14:36:24 +0200 Subject: [PATCH 12/18] chore: Make progress bar template reusable through a LazyLock --- rust/stackable-cockpit/src/lib.rs | 11 +++++++++++ rust/stackable-cockpit/src/platform/manifests.rs | 6 ++---- rust/stackable-cockpit/src/platform/release/spec.rs | 13 +++---------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/rust/stackable-cockpit/src/lib.rs b/rust/stackable-cockpit/src/lib.rs index e572b560..41489329 100644 --- a/rust/stackable-cockpit/src/lib.rs +++ b/rust/stackable-cockpit/src/lib.rs @@ -1,3 +1,7 @@ +use std::sync::LazyLock; + +use indicatif::ProgressStyle; + pub mod common; pub mod constants; pub mod engine; @@ -6,3 +10,10 @@ pub mod oci; pub mod platform; pub mod utils; pub mod xfer; + +pub(crate) static PROGRESS_BAR_STYLE: LazyLock = LazyLock::new(|| { + ProgressStyle::with_template( + "{span_child_prefix} Progress {msg}: {wide_bar:.magenta/cyan} {pos}/{len}", + ) + .expect("valid progress template") +}); diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 68d4a6db..6ed1618d 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -7,6 +7,7 @@ use tracing::{Instrument as _, Span, debug, info, info_span, instrument}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ + PROGRESS_BAR_STYLE, common::manifest::ManifestSpec, helm, utils::{ @@ -76,10 +77,7 @@ pub trait InstallManifestsExt { ) -> Result<(), Error> { debug!("Installing manifests"); - Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}") - .expect("valid progress template"), - ); + Span::current().pb_set_style(&PROGRESS_BAR_STYLE); Span::current().pb_set_length(manifests.len() as u64); let mut parameters = parameters.clone(); diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index 12dd00d3..b2d48d44 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -1,6 +1,5 @@ use futures::{StreamExt as _, TryStreamExt}; use indexmap::IndexMap; -use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::JoinError; @@ -10,7 +9,7 @@ use tracing_indicatif::span_ext::IndicatifSpanExt as _; use utoipa::ToSchema; use crate::{ - helm, + PROGRESS_BAR_STYLE, helm, platform::{ operator::{self, ChartSourceType, OperatorSpec}, product, @@ -64,10 +63,7 @@ impl ReleaseSpec { chart_source: &ChartSourceType, ) -> Result<()> { info!("Installing release"); - Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}") - .expect("valid progress template"), - ); + Span::current().pb_set_style(&PROGRESS_BAR_STYLE); include_products.iter().for_each(|product| { Span::current().record("product.included", product); @@ -125,10 +121,7 @@ impl ReleaseSpec { pub fn uninstall(&self, namespace: &str) -> Result<()> { info!("Uninstalling release"); - Span::current().pb_set_style( - &ProgressStyle::with_template("Progress: {wide_bar} {pos}/{len}") - .expect("valid progress template"), - ); + Span::current().pb_set_style(&PROGRESS_BAR_STYLE); Span::current().pb_set_length(self.products.len() as u64); for (product_name, product_spec) in &self.products { From f85cf1e9163df9dfccc797aebd1e0fff9366f18e Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Tue, 20 May 2025 15:37:25 +0200 Subject: [PATCH 13/18] chore: Make progress spinner template reusable through a LazyLock, and use span filtering toc ontrol indicatif output NOTE: Use `fields(indicatif.pb_show = true)` on instrumented functions that should have progress reporting --- rust/stackable-cockpit/src/lib.rs | 9 +++++++-- rust/stackablectl/src/main.rs | 33 ++++++++++++++++++------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/rust/stackable-cockpit/src/lib.rs b/rust/stackable-cockpit/src/lib.rs index 41489329..0ee6da4e 100644 --- a/rust/stackable-cockpit/src/lib.rs +++ b/rust/stackable-cockpit/src/lib.rs @@ -11,9 +11,14 @@ pub mod platform; pub mod utils; pub mod xfer; -pub(crate) static PROGRESS_BAR_STYLE: LazyLock = LazyLock::new(|| { +pub static PROGRESS_BAR_STYLE: LazyLock = LazyLock::new(|| { ProgressStyle::with_template( - "{span_child_prefix} Progress {msg}: {wide_bar:.magenta/cyan} {pos}/{len}", + "{span_child_prefix_indent}Progress: {wide_bar:.magenta/cyan} {pos}/{len}", ) .expect("valid progress template") }); + +pub static PROGRESS_SPINNER_STYLE: LazyLock = LazyLock::new(|| { + ProgressStyle::with_template("{span_child_prefix_indent}{spinner} {msg}") + .expect("valid progress template") +}); diff --git a/rust/stackablectl/src/main.rs b/rust/stackablectl/src/main.rs index ca324ba5..9ad159d2 100644 --- a/rust/stackablectl/src/main.rs +++ b/rust/stackablectl/src/main.rs @@ -1,10 +1,19 @@ use clap::Parser; use dotenvy::dotenv; -use indicatif::ProgressStyle; +use stackable_cockpit::PROGRESS_SPINNER_STYLE; use stackablectl::cli::{Cli, Error}; use tracing::{Level, metadata::LevelFilter}; -use tracing_indicatif::{IndicatifLayer, indicatif_eprintln}; -use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt}; +use tracing_indicatif::{ + IndicatifLayer, + filter::{IndicatifFilter, hide_indicatif_span_fields}, + indicatif_eprintln, +}; +use tracing_subscriber::{ + Layer as _, + fmt::{self, format::DefaultFields}, + layer::SubscriberExt, + util::SubscriberInitExt, +}; #[snafu::report] #[tokio::main] @@ -19,16 +28,12 @@ async fn main() -> Result<(), Error> { .with_target(false); let indicatif_layer = IndicatifLayer::new() - .with_progress_style(ProgressStyle::with_template("").expect("valid progress template")) - .with_max_progress_bars( - 15, - Some( - ProgressStyle::with_template( - "...and {pending_progress_bars} more processes not shown above.", - ) - .expect("valid progress template"), - ), - ); + .with_span_field_formatter( + // If the `{span_fields}` interpolation is used in a template, then we want to hide the + // indicatif control fields "indicatif.pb_show" and "indicatif.pb_hide" + hide_indicatif_span_fields(DefaultFields::new()), + ) + .with_progress_style(PROGRESS_SPINNER_STYLE.clone()); if let Some(level) = app.log_level { tracing_subscriber::registry() @@ -43,7 +48,7 @@ async fn main() -> Result<(), Error> { } else { tracing_subscriber::registry() .with(LevelFilter::from_level(Level::INFO)) - .with(indicatif_layer) + .with(indicatif_layer.with_filter(IndicatifFilter::new(false))) .init(); } From 7a9e870ac0ca56cf362dc140402fbe4d69db4e3d Mon Sep 17 00:00:00 2001 From: xeniape Date: Tue, 20 May 2025 17:25:01 +0200 Subject: [PATCH 14/18] refactor progress messages setup --- rust/stackable-cockpit/src/helm.rs | 12 +- rust/stackable-cockpit/src/lib.rs | 4 +- .../src/platform/demo/spec.rs | 7 +- .../src/platform/manifests.rs | 148 ++++++++---------- .../src/platform/operator/mod.rs | 5 +- .../src/platform/release/spec.rs | 3 +- .../src/platform/stack/spec.rs | 15 +- .../stackable-cockpit/src/utils/k8s/client.rs | 6 +- rust/stackablectl/src/cmds/demo.rs | 23 +-- rust/stackablectl/src/cmds/operator.rs | 36 ++--- rust/stackablectl/src/cmds/release.rs | 29 +--- rust/stackablectl/src/cmds/stack.rs | 22 +-- rust/stackablectl/src/cmds/stacklet.rs | 15 +- 13 files changed, 124 insertions(+), 201 deletions(-) diff --git a/rust/stackable-cockpit/src/helm.rs b/rust/stackable-cockpit/src/helm.rs index cd219166..b3df1daa 100644 --- a/rust/stackable-cockpit/src/helm.rs +++ b/rust/stackable-cockpit/src/helm.rs @@ -3,7 +3,8 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::block_in_place; -use tracing::{debug, error, info, instrument}; +use tracing::{debug, error, info, instrument, Span}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; use url::Url; use crate::{ @@ -183,7 +184,7 @@ pub struct ChartVersion<'a> { /// /// This function expects the fully qualified Helm release name. In case of our /// operators this is: `-operator`. -#[instrument(skip(values_yaml), fields(with_values = values_yaml.is_some()))] +#[instrument(skip(values_yaml), fields(with_values = values_yaml.is_some(), indicatif.pb_show = true))] pub fn install_release_from_repo_or_registry( release_name: &str, ChartVersion { @@ -199,6 +200,10 @@ pub fn install_release_from_repo_or_registry( // but that requires a larger refactoring block_in_place(|| { debug!("Install Helm release from repo"); + Span::current().pb_set_message( + format!("Installing {name} Helm chart", name = chart_name) + .as_str(), + ); if check_release_exists(release_name, namespace)? { let release = get_release(release_name, namespace)?.ok_or(Error::InstallRelease { @@ -297,13 +302,14 @@ fn install_release( /// /// This function expects the fully qualified Helm release name. In case of our /// operators this is: `-operator`. -#[instrument] +#[instrument(fields(indicatif.pb_show = true))] pub fn uninstall_release( release_name: &str, namespace: &str, suppress_output: bool, ) -> Result { debug!("Uninstall Helm release"); + Span::current().pb_set_message(format!("Uninstalling {name}-operator", name = release_name).as_str()); if check_release_exists(release_name, namespace)? { let result = helm_sys::uninstall_helm_release(release_name, namespace, suppress_output); diff --git a/rust/stackable-cockpit/src/lib.rs b/rust/stackable-cockpit/src/lib.rs index 0ee6da4e..d079307b 100644 --- a/rust/stackable-cockpit/src/lib.rs +++ b/rust/stackable-cockpit/src/lib.rs @@ -13,12 +13,12 @@ pub mod xfer; pub static PROGRESS_BAR_STYLE: LazyLock = LazyLock::new(|| { ProgressStyle::with_template( - "{span_child_prefix_indent}Progress: {wide_bar:.magenta/cyan} {pos}/{len}", + "{span_child_prefix}Progress: {wide_bar:.magenta/cyan} {pos}/{len}", ) .expect("valid progress template") }); pub static PROGRESS_SPINNER_STYLE: LazyLock = LazyLock::new(|| { - ProgressStyle::with_template("{span_child_prefix_indent}{spinner} {msg}") + ProgressStyle::with_template("{span_child_prefix}{spinner} {msg}") .expect("valid progress template") }); diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 2ac9d3c1..e2903516 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -1,4 +1,3 @@ -use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; use tracing::{Span, debug, info, instrument, warn}; @@ -183,6 +182,7 @@ impl DemoSpec { stack_name = %self.stack, operator_namespace = %install_params.operator_namespace, demo_namespace = %install_params.demo_namespace, + indicatif.pb_show = true ))] async fn prepare_manifests( &self, @@ -191,10 +191,7 @@ impl DemoSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing manifests") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing manifests"); let params = install_params .parameters diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 6ed1618d..6fe6ff70 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -1,9 +1,8 @@ use std::collections::HashMap; -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_operator::kvp::Labels; -use tracing::{Instrument as _, Span, debug, info, info_span, instrument}; +use tracing::{Span, debug, info, instrument}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; use crate::{ @@ -65,7 +64,7 @@ pub enum Error { pub trait InstallManifestsExt { // TODO (Techassi): This step shouldn't care about templating the manifests nor fetching them from remote - #[instrument(skip_all, fields(%namespace))] + #[instrument(skip_all, fields(%namespace, indicatif.pb_show = true))] #[allow(async_fn_in_trait)] async fn install_manifests( manifests: &[ManifestSpec], @@ -86,94 +85,75 @@ pub trait InstallManifestsExt { parameters.insert("NAMESPACE".to_owned(), namespace.to_owned()); for manifest in manifests { - let span = info_span!("install_manifests_iter"); - let parameters = parameters.clone(); let labels = labels.clone(); - async move { - match manifest { - ManifestSpec::HelmChart(helm_file) => { - debug!(helm_file, "Installing manifest from Helm chart"); - - // Read Helm chart YAML and apply templating - let helm_file = - helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { - path_or_url: helm_file.clone(), - })?; - let helm_chart: helm::Chart = transfer_client - .get(&helm_file, &Template::new(¶meters).then(Yaml::new())) - .await - .context(FileTransferSnafu)?; - - info!(helm_chart.name, helm_chart.version, "Installing Helm chart",); - Span::current().pb_set_message( - format!("Installing {name} Helm chart", name = helm_chart.name) - .as_str(), - ); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} {msg}") - .expect("valid progress template"), - ); - - // Assumption: that all manifest helm charts refer to repos not registries - helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context( - AddHelmRepositorySnafu { - repo_name: helm_chart.repo.name.clone(), - }, - )?; - - // Serialize chart options to string - let values_yaml = serde_yaml::to_string(&helm_chart.options) - .context(SerializeOptionsSnafu)?; - - // Install the Helm chart using the Helm wrapper - helm::install_release_from_repo_or_registry( - &helm_chart.release_name, - helm::ChartVersion { - chart_source: &helm_chart.repo.name, - chart_name: &helm_chart.name, - chart_version: Some(&helm_chart.version), - }, - Some(&values_yaml), - namespace, - true, - ) - .context(InstallHelmReleaseSnafu { - release_name: helm_chart.release_name, + match manifest { + ManifestSpec::HelmChart(helm_file) => { + debug!(helm_file, "Installing manifest from Helm chart"); + + // Read Helm chart YAML and apply templating + let helm_file = + helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { + path_or_url: helm_file.clone(), })?; - } - ManifestSpec::PlainYaml(manifest_file) => { - debug!(manifest_file, "Installing YAML manifest"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing YAML manifest") - .expect("valid progress template"), - ); - - // Read YAML manifest and apply templating - let path_or_url = - manifest_file - .into_path_or_url() - .context(ParsePathOrUrlSnafu { - path_or_url: manifest_file.clone(), - })?; - - let manifests = transfer_client - .get(&path_or_url, &Template::new(¶meters)) - .await - .context(FileTransferSnafu)?; - - client - .deploy_manifests(&manifests, namespace, labels.clone()) - .await - .context(DeployManifestSnafu)?; - } + + let helm_chart: helm::Chart = transfer_client + .get(&helm_file, &Template::new(¶meters).then(Yaml::new())) + .await + .context(FileTransferSnafu)?; + + info!(helm_chart.name, helm_chart.version, "Installing Helm chart",); + + // Assumption: that all manifest helm charts refer to repos not registries + helm::add_repo(&helm_chart.repo.name, &helm_chart.repo.url).context( + AddHelmRepositorySnafu { + repo_name: helm_chart.repo.name.clone(), + }, + )?; + + // Serialize chart options to string + let values_yaml = serde_yaml::to_string(&helm_chart.options) + .context(SerializeOptionsSnafu)?; + + // Install the Helm chart using the Helm wrapper + helm::install_release_from_repo_or_registry( + &helm_chart.release_name, + helm::ChartVersion { + chart_source: &helm_chart.repo.name, + chart_name: &helm_chart.name, + chart_version: Some(&helm_chart.version), + }, + Some(&values_yaml), + namespace, + true, + ) + .context(InstallHelmReleaseSnafu { + release_name: helm_chart.release_name, + })?; } + ManifestSpec::PlainYaml(manifest_file) => { + debug!(manifest_file, "Installing YAML manifest"); + + // Read YAML manifest and apply templating + let path_or_url = + manifest_file + .into_path_or_url() + .context(ParsePathOrUrlSnafu { + path_or_url: manifest_file.clone(), + })?; + + let manifests = transfer_client + .get(&path_or_url, &Template::new(¶meters)) + .await + .context(FileTransferSnafu)?; - Ok::<(), Error>(()) + client + .deploy_manifests(&manifests, namespace, labels.clone()) + .await + .context(DeployManifestSnafu)?; + } } - .instrument(span) - .await?; Span::current().pb_inc(1); } diff --git a/rust/stackable-cockpit/src/platform/operator/mod.rs b/rust/stackable-cockpit/src/platform/operator/mod.rs index 376122c1..55d4f692 100644 --- a/rust/stackable-cockpit/src/platform/operator/mod.rs +++ b/rust/stackable-cockpit/src/platform/operator/mod.rs @@ -1,6 +1,5 @@ use std::{fmt::Display, str::FromStr}; -use indicatif::ProgressStyle; use semver::Version; use serde::Serialize; use snafu::{ResultExt, Snafu, ensure}; @@ -186,6 +185,7 @@ impl OperatorSpec { // display for the inner type if it exists. Otherwise we gte the Debug // impl for the whole Option. version = self.version.as_ref().map(tracing::field::display), + indicatif.pb_show = true ))] pub fn install( &self, @@ -195,9 +195,6 @@ impl OperatorSpec { info!(operator = %self, "Installing operator"); Span::current() .pb_set_message(format!("Installing {name}-operator", name = self.name).as_str()); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} {msg}").expect("valid progress template"), - ); let version = self.version.as_ref().map(|v| v.to_string()); let helm_name = self.helm_name(); diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index b2d48d44..82e954f1 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -54,6 +54,7 @@ impl ReleaseSpec { %namespace, product.included = tracing::field::Empty, product.excluded = tracing::field::Empty, + indicatif.pb_show = true ))] pub async fn install( &self, @@ -117,7 +118,7 @@ impl ReleaseSpec { .await } - #[instrument(skip_all)] + #[instrument(skip_all, fields(indicatif.pb_show = true))] pub fn uninstall(&self, namespace: &str) -> Result<()> { info!("Uninstalling release"); diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index 4fd47f66..e95fb628 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -1,4 +1,3 @@ -use indicatif::ProgressStyle; use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; use tracing::{Span, debug, info, instrument, log::warn}; @@ -196,7 +195,7 @@ impl StackSpec { .await } - #[instrument(skip_all, fields(release = %self.release, %operator_namespace))] + #[instrument(skip_all, fields(release = %self.release, %operator_namespace, indicatif.pb_show = true))] pub async fn install_release( &self, release_list: release::ReleaseList, @@ -205,10 +204,7 @@ impl StackSpec { chart_source: &ChartSourceType, ) -> Result<(), Error> { info!(self.release, "Trying to install release"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing operators") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing operators"); // Get the release by name let release = release_list @@ -224,7 +220,7 @@ impl StackSpec { .context(InstallReleaseSnafu) } - #[instrument(skip_all)] + #[instrument(skip_all, fields(indicatif.pb_show = true))] pub async fn prepare_manifests( &self, install_params: StackInstallParameters, @@ -232,10 +228,7 @@ impl StackSpec { transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing manifests") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing manifests"); let parameters = install_params .parameters diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index c87b7118..5e98b974 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -14,7 +14,8 @@ use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{commons::listener::Listener, kvp::Labels}; use tokio::sync::RwLock; -use tracing::info; +use tracing::{info, instrument, Span}; +use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(doc)] use crate::utils::k8s::ListParamsExt; @@ -98,12 +99,15 @@ impl Client { /// Deploys manifests defined the in raw `manifests` YAML string. This /// method will fail if it is unable to parse the manifests, unable to /// resolve GVKs or unable to patch the dynamic objects. + #[instrument(skip_all, fields(indicatif.pb_show = true))] pub async fn deploy_manifests( &self, manifests: &str, namespace: &str, labels: Labels, ) -> Result<()> { + Span::current().pb_set_message("Installing YAML manifest"); + // TODO (Techassi): Impl IntoIterator for Labels let labels: BTreeMap = labels.into(); diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index e99b5860..9480e3dd 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -3,7 +3,6 @@ use comfy_table::{ ContentArrangement, Row, Table, presets::{NOTHING, UTF8_FULL}, }; -use indicatif::ProgressStyle; use snafu::{OptionExt as _, ResultExt, Snafu, ensure}; use stackable_cockpit::{ common::list, @@ -211,13 +210,10 @@ impl DemoArgs { } /// Print out a list of demos, either as a table (plain), JSON or YAML -#[instrument(skip_all)] +#[instrument(skip_all, fields(indicatif.pb_show = true))] async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result { info!("Listing demos"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching demo information"); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -263,17 +259,14 @@ async fn list_cmd(args: &DemoListArgs, cli: &Cli, list: demo::List) -> Result Result { info!(demo_name = %args.demo_name, "Describing demo"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching demo information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching demo information"); let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { name: args.demo_name.clone(), @@ -326,7 +319,8 @@ async fn describe_cmd( #[instrument(skip_all, fields( demo_name = %args.demo_name, skip_release = args.skip_release, - %release_branch + %release_branch, + indicatif.pb_show = true ))] async fn install_cmd( args: &DemoInstallArgs, @@ -336,10 +330,7 @@ async fn install_cmd( release_branch: &str, ) -> Result { info!(demo_name = %args.demo_name, "Installing demo"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing demo") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing demo"); // Init result output and progress output let mut output = cli.result(); diff --git a/rust/stackablectl/src/cmds/operator.rs b/rust/stackablectl/src/cmds/operator.rs index a70b21ca..84c269cd 100644 --- a/rust/stackablectl/src/cmds/operator.rs +++ b/rust/stackablectl/src/cmds/operator.rs @@ -6,7 +6,6 @@ use comfy_table::{ presets::{NOTHING, UTF8_FULL}, }; use indexmap::IndexMap; -use indicatif::ProgressStyle; use semver::Version; use serde::Serialize; use snafu::{ResultExt, Snafu}; @@ -188,13 +187,10 @@ impl OperatorArgs { } } -#[instrument(skip_all)] +#[instrument(skip_all, fields(indicatif.pb_show = true))] async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result { debug!("Listing operators"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching operator information"); // Build map which maps artifacts to a chart source let source_index_files = @@ -249,13 +245,10 @@ async fn list_cmd(args: &OperatorListArgs, cli: &Cli) -> Result Result { debug!(operator_name = %args.operator_name, "Describing operator"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching operator information"); // Build map which maps artifacts to a chart source let source_index_files = @@ -312,13 +305,10 @@ async fn describe_cmd(args: &OperatorDescribeArgs, cli: &Cli) -> Result Result { info!("Installing operator(s)"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing operator(s)") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing operator(s)"); args.local_cluster .install_if_needed() @@ -365,13 +355,10 @@ async fn install_cmd(args: &OperatorInstallArgs, cli: &Cli) -> Result Result { info!("Uninstalling operator(s)"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Uninstalling operator(s)") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Uninstalling operator(s)"); for operator in &args.operators { operator @@ -399,13 +386,10 @@ fn uninstall_cmd(args: &OperatorUninstallArgs, cli: &Cli) -> Result Result { info!("Listing installed operators"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching operator information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching operator information"); type ReleaseList = IndexMap; diff --git a/rust/stackablectl/src/cmds/release.rs b/rust/stackablectl/src/cmds/release.rs index f400f64a..fc2e68e8 100644 --- a/rust/stackablectl/src/cmds/release.rs +++ b/rust/stackablectl/src/cmds/release.rs @@ -3,7 +3,6 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::{ common::list, @@ -152,17 +151,14 @@ impl ReleaseArgs { } } -#[instrument(skip(cli, release_list))] +#[instrument(skip(cli, release_list), fields(indicatif.pb_show = true))] async fn list_cmd( args: &ReleaseListArgs, cli: &Cli, release_list: release::ReleaseList, ) -> Result { info!("Listing releases"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching release information"); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -210,17 +206,14 @@ async fn list_cmd( } } -#[instrument(skip(cli, release_list))] +#[instrument(skip(cli, release_list), fields(indicatif.pb_show = true))] async fn describe_cmd( args: &ReleaseDescribeArgs, cli: &Cli, release_list: release::ReleaseList, ) -> Result { info!(release = %args.release, "Describing release"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching release information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching release information"); let release = release_list.get(&args.release); @@ -275,17 +268,14 @@ async fn describe_cmd( } } -#[instrument(skip(cli, release_list))] +#[instrument(skip(cli, release_list), fields(indicatif.pb_show = true))] async fn install_cmd( args: &ReleaseInstallArgs, cli: &Cli, release_list: release::ReleaseList, ) -> Result { info!(release = %args.release, "Installing release"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing release") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing release"); match release_list.get(&args.release) { Some(release) => { @@ -329,16 +319,13 @@ async fn install_cmd( } } -#[instrument(skip(cli, release_list))] +#[instrument(skip(cli, release_list), fields(indicatif.pb_show = true))] async fn uninstall_cmd( args: &ReleaseUninstallArgs, cli: &Cli, release_list: release::ReleaseList, ) -> Result { - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Uninstalling release") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Uninstalling release"); match release_list.get(&args.release) { Some(release) => { diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index f0393672..01816929 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -3,7 +3,6 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; -use indicatif::ProgressStyle; use snafu::{OptionExt as _, ResultExt, Snafu, ensure}; use stackable_cockpit::{ common::list, @@ -193,17 +192,14 @@ impl StackArgs { } } -#[instrument(skip_all)] +#[instrument(skip_all, fields(indicatif.pb_show = true))] fn list_cmd( args: &StackListArgs, cli: &Cli, stack_list: stack::StackList, ) -> Result { info!("Listing stacks"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching stack information"); match args.output_type { OutputType::Plain | OutputType::Table => { @@ -247,17 +243,14 @@ fn list_cmd( } } -#[instrument(skip_all)] +#[instrument(skip_all, fields(indicatif.pb_show = true))] fn describe_cmd( args: &StackDescribeArgs, cli: &Cli, stack_list: stack::StackList, ) -> Result { info!(stack_name = %args.stack_name, "Describing stack"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stack information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching stack information"); match stack_list.get(&args.stack_name) { Some(stack) => match args.output_type { @@ -313,7 +306,7 @@ fn describe_cmd( } } -#[instrument(skip(cli, stack_list, transfer_client))] +#[instrument(skip(cli, stack_list, transfer_client), fields(indicatif.pb_show = true))] async fn install_cmd( args: &StackInstallArgs, cli: &Cli, @@ -321,10 +314,7 @@ async fn install_cmd( transfer_client: &xfer::Client, ) -> Result { info!(stack_name = %args.stack_name, "Installing stack"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Installing stack") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Installing stack"); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index 3ba85018..332d45a0 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -3,7 +3,6 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; -use indicatif::ProgressStyle; use snafu::{ResultExt, Snafu}; use stackable_cockpit::{ constants::DEFAULT_NAMESPACE, @@ -91,13 +90,10 @@ impl StackletArgs { } } -#[instrument(skip_all)] +#[instrument(skip_all, fields(indicatif.pb_show = true))] async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result { info!("Listing installed stacklets"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching stacklet information"); let client = Client::new().await.context(KubeClientCreateSnafu)?; @@ -208,13 +204,10 @@ async fn list_cmd(args: &StackletListArgs, cli: &Cli) -> Result Result { info!("Displaying stacklet credentials"); - Span::current().pb_set_style( - &ProgressStyle::with_template("{spinner} Fetching stacklet information") - .expect("valid progress template"), - ); + Span::current().pb_set_message("Fetching stacklet information"); let client = Client::new().await.context(KubeClientCreateSnafu)?; From ed6f34aa3d52bd724c6de89f5ff3afcf5d3b768d Mon Sep 17 00:00:00 2001 From: xeniape Date: Tue, 20 May 2025 17:42:08 +0200 Subject: [PATCH 15/18] update format strings --- rust/stackable-cockpit/src/helm.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/stackable-cockpit/src/helm.rs b/rust/stackable-cockpit/src/helm.rs index b3df1daa..3a7d8e8d 100644 --- a/rust/stackable-cockpit/src/helm.rs +++ b/rust/stackable-cockpit/src/helm.rs @@ -201,7 +201,7 @@ pub fn install_release_from_repo_or_registry( block_in_place(|| { debug!("Install Helm release from repo"); Span::current().pb_set_message( - format!("Installing {name} Helm chart", name = chart_name) + format!("Installing {chart_name} Helm chart") .as_str(), ); @@ -309,7 +309,7 @@ pub fn uninstall_release( suppress_output: bool, ) -> Result { debug!("Uninstall Helm release"); - Span::current().pb_set_message(format!("Uninstalling {name}-operator", name = release_name).as_str()); + Span::current().pb_set_message(format!("Uninstalling {release_name}-operator").as_str()); if check_release_exists(release_name, namespace)? { let result = helm_sys::uninstall_helm_release(release_name, namespace, suppress_output); From 634589b4362fb70b8c62b66f726831ec9d4c9982 Mon Sep 17 00:00:00 2001 From: xeniape Date: Fri, 23 May 2025 11:10:13 +0200 Subject: [PATCH 16/18] add changelog entry --- rust/stackable-cockpit/src/helm.rs | 7 ++----- rust/stackable-cockpit/src/platform/manifests.rs | 7 +++---- rust/stackable-cockpit/src/utils/k8s/client.rs | 2 +- rust/stackablectl/CHANGELOG.md | 2 ++ 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/rust/stackable-cockpit/src/helm.rs b/rust/stackable-cockpit/src/helm.rs index 3a7d8e8d..c43578d3 100644 --- a/rust/stackable-cockpit/src/helm.rs +++ b/rust/stackable-cockpit/src/helm.rs @@ -3,7 +3,7 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; use snafu::{ResultExt, Snafu}; use tokio::task::block_in_place; -use tracing::{debug, error, info, instrument, Span}; +use tracing::{Span, debug, error, info, instrument}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; use url::Url; @@ -200,10 +200,7 @@ pub fn install_release_from_repo_or_registry( // but that requires a larger refactoring block_in_place(|| { debug!("Install Helm release from repo"); - Span::current().pb_set_message( - format!("Installing {chart_name} Helm chart") - .as_str(), - ); + Span::current().pb_set_message(format!("Installing {chart_name} Helm chart").as_str()); if check_release_exists(release_name, namespace)? { let release = get_release(release_name, namespace)?.ok_or(Error::InstallRelease { diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 6fe6ff70..c1b3a566 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -93,10 +93,9 @@ pub trait InstallManifestsExt { debug!(helm_file, "Installing manifest from Helm chart"); // Read Helm chart YAML and apply templating - let helm_file = - helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { - path_or_url: helm_file.clone(), - })?; + let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { + path_or_url: helm_file.clone(), + })?; let helm_chart: helm::Chart = transfer_client .get(&helm_file, &Template::new(¶meters).then(Yaml::new())) diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index 5e98b974..629aa9e4 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -14,7 +14,7 @@ use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{commons::listener::Listener, kvp::Labels}; use tokio::sync::RwLock; -use tracing::{info, instrument, Span}; +use tracing::{Span, info, instrument}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(doc)] diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index 8daf172d..05f8d199 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file. - Pass the stack/demo namespace as a templating variable `NAMESPACE` to manifests. This should unblock demos to run in all namespaces, as they can template the namespace e.g. for the FQDN of services ([#355]). +- Add progress reporting ([#376]). ### Changed @@ -20,6 +21,7 @@ All notable changes to this project will be documented in this file. [#368]: https://github.com/stackabletech/stackable-cockpit/pull/368 [#373]: https://github.com/stackabletech/stackable-cockpit/pull/373 +[#376]: https://github.com/stackabletech/stackable-cockpit/pull/376 ## [25.3.0] - 2025-03-27 From 727f1a59914124a68f0e8baba9c7932ff9b7eb6a Mon Sep 17 00:00:00 2001 From: xeniape Date: Fri, 23 May 2025 13:38:04 +0200 Subject: [PATCH 17/18] move span into childspan on info level --- rust/stackable-cockpit/src/platform/release/spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/stackable-cockpit/src/platform/release/spec.rs b/rust/stackable-cockpit/src/platform/release/spec.rs index 82e954f1..e17120d2 100644 --- a/rust/stackable-cockpit/src/platform/release/spec.rs +++ b/rust/stackable-cockpit/src/platform/release/spec.rs @@ -81,7 +81,7 @@ impl ReleaseSpec { futures::stream::iter(operators) .map(|(product_name, product)| { let task_span = - tracing::debug_span!("install_operator", product_name = tracing::field::Empty); + tracing::info_span!("install_operator", product_name = tracing::field::Empty); let namespace = namespace.clone(); let chart_source = chart_source.clone(); From abc56b93cd8b3c16e30ff4d28af9c97684029568 Mon Sep 17 00:00:00 2001 From: xeniape Date: Fri, 23 May 2025 14:32:17 +0200 Subject: [PATCH 18/18] remove progress bar color --- rust/stackable-cockpit/src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/rust/stackable-cockpit/src/lib.rs b/rust/stackable-cockpit/src/lib.rs index d079307b..ef1b50b4 100644 --- a/rust/stackable-cockpit/src/lib.rs +++ b/rust/stackable-cockpit/src/lib.rs @@ -12,10 +12,8 @@ pub mod utils; pub mod xfer; pub static PROGRESS_BAR_STYLE: LazyLock = LazyLock::new(|| { - ProgressStyle::with_template( - "{span_child_prefix}Progress: {wide_bar:.magenta/cyan} {pos}/{len}", - ) - .expect("valid progress template") + ProgressStyle::with_template("{span_child_prefix}Progress: {wide_bar} {pos}/{len}") + .expect("valid progress template") }); pub static PROGRESS_SPINNER_STYLE: LazyLock = LazyLock::new(|| {