Do not panick on healthcheck connection error (#2145)

* Handle unhappy flow

Fix the healthcheck to handle not only the happy flow, but also errors like "connection refused" or "host unreachable".

* Fix Typo in variable
This commit is contained in:
Codekloeppler 2025-09-11 12:21:08 +02:00 committed by GitHub
parent 15762fba2b
commit 058208992a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -116,22 +116,27 @@ impl ServerCommands {
format!("{}/healthz/{}",
client.url,
check.unwrap_or("ready".to_string()))
)
.await
.unwrap();
match response.status() {
StatusCode::OK => {
eprintln!("Success")
},
_ => {
eprintln!(
"Request failed: {}",
response.text().await.unwrap_result("fetch text")
);
std::process::exit(1);
).await;
match response {
Ok(resp) => {
match resp.status() {
StatusCode::OK => {
eprintln!("Success")
},
_ => {
eprintln!(
"Request failed: {}",
resp.text().await.unwrap_result("fetch text")
);
std::process::exit(1);
}
}
}
}
Err(err) => {
eprintln!("Request failed: {}", err);
std::process::exit(1);
}
}
}
}
}