Skip to content

Commit f301c91

Browse files
committed
add progress reporting to upgrade
1 parent 476d56e commit f301c91

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

rust/stackable-cockpit/src/platform/release/spec.rs

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl ReleaseSpec {
134134
/// Upgrades a release by upgrading individual operators.
135135
#[instrument(skip_all, fields(
136136
%namespace,
137+
indicatif.pb_show = true
137138
))]
138139
pub async fn upgrade_crds(
139140
&self,
@@ -143,6 +144,7 @@ impl ReleaseSpec {
143144
k8s_client: &Client,
144145
) -> Result<()> {
145146
info!("Upgrading CRDs for release");
147+
Span::current().pb_set_style(&PROGRESS_BAR_STYLE);
146148

147149
include_products.iter().for_each(|product| {
148150
Span::current().record("product.included", product);
@@ -154,38 +156,50 @@ impl ReleaseSpec {
154156
let client = reqwest::Client::new();
155157
let operators = self.filter_products(include_products, exclude_products);
156158

159+
Span::current().pb_set_length(operators.len() as u64);
160+
157161
for (product_name, product) in operators {
158162
info!("Upgrading CRDs for {product_name}-operator");
163+
let iter_span = tracing::info_span!("upgrade_crds_iter", indicatif.pb_show = true);
164+
165+
let client = client.clone();
166+
async move {
167+
Span::current().pb_set_message(format!("Ugrading CRDs for {product_name}-operator").as_str());
168+
169+
let release_branch = match product.version.pre.as_str() {
170+
"dev" => "main".to_string(),
171+
_ => {
172+
format!("{}", product.version)
173+
}
174+
};
159175

160-
let release_branch = match product.version.pre.as_str() {
161-
"dev" => "main".to_string(),
162-
_ => {
163-
format!("{}", product.version)
164-
}
165-
};
166-
167-
let request_url = format!(
168-
"https://raw.githubusercontent.com/stackabletech/{product_name}-operator/{release_branch}/deploy/helm/{product_name}-operator/crds/crds.yaml"
169-
);
170-
171-
// Get CRD manifests from request_url
172-
let response = client
173-
.get(request_url)
174-
.send()
175-
.await
176-
.context(ConstructRequestSnafu)?
177-
.error_for_status()
178-
.context(AccessCRDsSnafu)?;
179-
180-
let crd_manifests = response.text().await.context(ReadManifestsSnafu)?;
181-
182-
// Upgrade CRDs
183-
k8s_client
184-
.replace_crds(&crd_manifests)
185-
.await
186-
.context(DeployManifestSnafu)?;
187-
188-
info!("Upgraded {product_name}-operator CRDs");
176+
let request_url = format!(
177+
"https://raw.githubusercontent.com/stackabletech/{product_name}-operator/{release_branch}/deploy/helm/{product_name}-operator/crds/crds.yaml"
178+
);
179+
180+
// Get CRD manifests from request_url
181+
let response = client
182+
.get(request_url)
183+
.send()
184+
.await
185+
.context(ConstructRequestSnafu)?
186+
.error_for_status()
187+
.context(AccessCRDsSnafu)?;
188+
189+
let crd_manifests = response.text().await.context(ReadManifestsSnafu)?;
190+
191+
// Upgrade CRDs
192+
k8s_client
193+
.replace_crds(&crd_manifests)
194+
.await
195+
.context(DeployManifestSnafu)?;
196+
197+
info!("Upgraded {product_name}-operator CRDs");
198+
199+
Ok::<(), Error>(())
200+
}.instrument(iter_span).await?;
201+
202+
Span::current().pb_inc(1);
189203
}
190204

191205
Ok(())

rust/stackablectl/src/cmds/release.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,14 @@ async fn install_cmd(
354354
}
355355
}
356356

357-
#[instrument(skip(cli, release_list))]
357+
#[instrument(skip(cli, release_list), fields(indicatif.pb_show = true))]
358358
async fn upgrade_cmd(
359359
args: &ReleaseUpgradeArgs,
360360
cli: &Cli,
361361
release_list: release::ReleaseList,
362362
) -> Result<String, CmdError> {
363363
info!(release = %args.release, "Upgrading release");
364+
Span::current().pb_set_message("Upgrading release");
364365

365366
match release_list.get(&args.release) {
366367
Some(release) => {

0 commit comments

Comments
 (0)