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

feat: while jobset-wait retry on hydra failures #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
41 changes: 29 additions & 12 deletions hydra-cli/src/ops/jobset_wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,34 @@ fn jobset_find(
client: &dyn HydraClient,
project_name: &str,
jobset_name: &str,
max_retries: u8,
sleep: Duration,
) -> Result<JobsetOverview, OpError> {
let jobsets = client.jobset_overview(project_name)?;
jobsets
.into_iter()
.find(|j| j.name == jobset_name)
.ok_or_else(|| {
OpError::Error(format!(
"Project {} doesn't have a jobset {}",
project_name, jobset_name
))
})
match client.jobset_overview(project_name) {
Err(e) => {
if max_retries > 0 {
thread::sleep(sleep);
jobset_find(
client,
project_name,
jobset_name,
max_retries - 1,
sleep * 2,
)
} else {
Err(e.into())
}
}
Ok(jobsets) => jobsets
.into_iter()
.find(|j| j.name == jobset_name)
.ok_or_else(|| {
OpError::Error(format!(
"Project {} doesn't have a jobset {}",
project_name, jobset_name
))
}),
}
}

// To know if a jobset has been successfully built, five steps are required:
Expand Down Expand Up @@ -101,6 +118,7 @@ pub fn run(
let mut start = SystemTime::now();
let timeout_start = start;
let mut nrscheduled = 0;
let max_retries = 5;

println!(
"waiting for jobset {}/{} ({}/jobset/{}/{})",
Expand All @@ -117,8 +135,7 @@ pub fn run(
}
_ => {}
}

match jobset_find(client, project_name, jobset_name) {
match jobset_find(client, project_name, jobset_name, max_retries, sleep) {
Err(_) => {
// The jobset should not disappear if it has already been seen!
if state != State::WaitingForJobset {
Expand Down