Skip to content

Commit

Permalink
Improve validation requests in "wasmer deploy"
Browse files Browse the repository at this point in the history
Closes RUN-416
  • Loading branch information
theduke committed Aug 29, 2024
1 parent f187f77 commit 57faba0
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions lib/cli/src/commands/app/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

Expand All @@ -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
Expand All @@ -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());
}
Expand All @@ -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()
Expand Down

0 comments on commit 57faba0

Please sign in to comment.