Skip to content

Commit

Permalink
Merge pull request #60 from nlewo/jobset-wait-error-msg
Browse files Browse the repository at this point in the history
jobset-wait: provide link to the jobset on failure
  • Loading branch information
nlewo authored Nov 15, 2020
2 parents 75e2013 + 67da507 commit 1310a3f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ FLAGS:
-V, --version Prints version information
OPTIONS:
--timeout <timeout> Maximum time to wait for (in seconds)
--timeout <timeout> Maximum time to wait for (in seconds and infinite by default)
ARGS:
<project> The project of the jobset to wait for
Expand Down
3 changes: 3 additions & 0 deletions src/hydra/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ pub trait HydraClient {
/// Authenticates with the server using username and password provided by `Creds`
fn login(&self, creds: Creds) -> Result<(), ClientError>;

/// Returns the Hydra host
fn host(&self) -> String;

/// Searches the host for the nix store path `query`
fn search(&self, query: &str) -> Result<Search, ClientError>;

Expand Down
3 changes: 3 additions & 0 deletions src/hydra/reqwest_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ impl HydraClient for Client {
}
}

fn host(&self) -> String {
self.host.clone()
}
fn projects(&self) -> Result<Vec<Project>, ClientError> {
get_json(&self.client, &self.host)
}
Expand Down
25 changes: 19 additions & 6 deletions src/ops/jobset_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,25 @@ fn is_evaluation_finished_after(jobset: &JobsetOverview, start: SystemTime) -> b
}
}

fn is_jobset_built(jobset: &JobsetOverview) -> Result<bool, OpError> {
fn is_jobset_built(client: &dyn HydraClient, jobset: &JobsetOverview) -> Result<bool, OpError> {
if jobset.haserrormsg.unwrap_or(false) {
println!();
Err(OpError::Error(format!(
"evaluation of jobset {} failed",
"evaluation of jobset {} failed; for details: {}/jobset/{}/{}",
jobset.name,
client.host(),
jobset.project,
jobset.name
)))
} else if jobset.nrfailed != 0 {
println!();
Err(OpError::Error(format!(
"Jobset {} has {} failed jobs",
"Jobset {} has {} failed jobs; for details: {}/jobset/{}/{}",
jobset.name,
jobset.nrfailed.to_string()
jobset.nrfailed.to_string(),
client.host(),
jobset.project,
jobset.name
)))
} else if jobset.nrsucceeded == jobset.nrtotal {
println!(
Expand Down Expand Up @@ -96,7 +102,14 @@ pub fn run(
let timeout_start = start;
let mut nrscheduled = 0;

println!("waiting for jobset {}/{}", project_name, jobset_name);
println!(
"waiting for jobset {}/{} ({}/jobset/{}/{})",
project_name,
jobset_name,
client.host(),
project_name,
jobset_name
);
loop {
match timeout {
Some(t) if SystemTime::now().duration_since(timeout_start).unwrap() > t => {
Expand Down Expand Up @@ -148,7 +161,7 @@ pub fn run(
}
}
State::Building => {
if is_jobset_built(&jobset)? {
if is_jobset_built(client, &jobset)? {
break;
} else if nrscheduled != jobset.nrscheduled {
nrscheduled = jobset.nrscheduled;
Expand Down

0 comments on commit 1310a3f

Please sign in to comment.