Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve validation requests in "wasmer deploy" #5056

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading