From 57faba0958e168c7e1ff2e92c5df34ea492937d7 Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 29 Aug 2024 20:38:39 +0200 Subject: [PATCH] Improve validation requests in "wasmer deploy" Closes RUN-416 --- lib/cli/src/commands/app/deploy.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/cli/src/commands/app/deploy.rs b/lib/cli/src/commands/app/deploy.rs index 6f229520247..eb9592c03dd 100644 --- a/lib/cli/src/commands/app/deploy.rs +++ b/lib/cli/src/commands/app/deploy.rs @@ -692,7 +692,13 @@ pub async fn wait_app( tokio::time::sleep(Duration::from_secs(2)).await; let start = tokio::time::Instant::now(); - let client = reqwest::Client::new(); + let client = reqwest::Client::builder() + .connect_timeout(Duration::from_secs(10)) + .timeout(Duration::from_secs(90)) + // Should not follow redirects. + .redirect(reqwest::redirect::Policy::none()) + .build() + .unwrap(); let check_url = if make_default { &app.url } else { &version.url }; @@ -717,6 +723,7 @@ pub async fn wait_app( let request_start = tokio::time::Instant::now(); + tracing::debug!(%check_url, "checking health of app"); match client.get(check_url).send().await { Ok(res) => { let header = res @@ -725,12 +732,24 @@ pub async fn wait_app( .and_then(|x| x.to_str().ok()) .unwrap_or_default(); + tracing::debug!( + %check_url, + status=res.status().as_u16(), + app_version_header=%header, + "app request response received", + ); + if header == version.id.inner() { if !quiet { eprintln!(); } if !(res.status().is_success() || res.status().is_redirection()) { - eprintln!("{}",format!("The app version was deployed correctly, but fails with a non-success status code of {}", res.status()).yellow()); + eprintln!( + "{}", + format!( + "The app version was deployed correctly, but fails with a non-success status code of {}", + res.status()).yellow() + ); } else { eprintln!("{} Deployment complete", "ð–¥”".yellow().bold()); } @@ -749,6 +768,8 @@ pub async fn wait_app( } }; + // Increase the sleep time between requests, up + // to a reasonable maximum. let elapsed: u64 = request_start .elapsed() .as_millis()