-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENH] Make the error messages out of chroma-load decipherable. (#3316)
Staring was failing with a 400 that was really a 404. This PR changes that case to a 404 instead of 400 and prints the body in the chroma-load-start tool. Also, a tool to stop all workloads.
- Loading branch information
Showing
3 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//! Stop all workloads on the chroma-load server. | ||
//! | ||
//! If you are looking to stop traffic for a SEV, see chroma-load-inhibit. | ||
use clap::Parser; | ||
|
||
use chroma_load::rest::StopRequest; | ||
|
||
#[derive(Parser, Debug)] | ||
struct Args { | ||
#[arg(long)] | ||
host: String, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let args = Args::parse(); | ||
let client = reqwest::Client::new(); | ||
match client | ||
.get(format!("{}/", args.host)) | ||
.header(reqwest::header::ACCEPT, "application/json") | ||
.send() | ||
.await | ||
{ | ||
Ok(resp) => { | ||
let resp = resp.error_for_status().expect("Failed to get status"); | ||
let resp = resp | ||
.json::<chroma_load::rest::Status>() | ||
.await | ||
.expect("Failed to parse status"); | ||
for workload in resp.running { | ||
let req = StopRequest { | ||
uuid: workload.uuid, | ||
}; | ||
match client | ||
.post(format!("{}/stop", args.host)) | ||
.json(&req) | ||
.send() | ||
.await | ||
{ | ||
Ok(resp) => { | ||
if resp.status().is_success() { | ||
println!("Stopped workload on {}", args.host); | ||
} else { | ||
eprintln!( | ||
"Failed to stop workload on {}: {}", | ||
args.host, | ||
resp.status() | ||
); | ||
} | ||
} | ||
Err(e) => eprintln!("Failed to stop workload on {}: {}", args.host, e), | ||
} | ||
} | ||
} | ||
Err(e) => { | ||
eprintln!("Failed to get status: {}", e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters