Skip to content

Commit 9413995

Browse files
author
Inkedstinct
committed
feat(jobs): Switch jobs to 'UnknownState' when results are not available or checksum failed
1 parent 19220a2 commit 9413995

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/jobs.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ impl OARState {
7575
OARState::UnknownState => "UnknownState",
7676
}
7777
}
78+
79+
fn is_terminal(&self) -> bool {
80+
self == &OARState::Terminated || self == &OARState::Failed || self == &OARState::UnknownState
81+
}
7882
}
7983

8084
impl TryFrom<&str> for OARState {
@@ -144,7 +148,7 @@ impl Job {
144148
}
145149

146150
fn finished(&self) -> bool {
147-
self.state == OARState::Terminated || self.state == OARState::Failed
151+
self.state.is_terminal()
148152
}
149153

150154
pub async fn submit_job(&mut self) -> JobResult {
@@ -207,13 +211,16 @@ impl Job {
207211
}
208212

209213
pub async fn job_terminated(&mut self) -> JobResult {
210-
rsync_results(
214+
if let Err(rsync_result) = rsync_results(
211215
&self.site,
212216
self.node.cluster.as_deref().unwrap(),
213217
&self.node.uid,
214-
)?;
218+
) {
219+
self.state = OARState::UnknownState;
220+
}
215221
Ok(())
216222
}
223+
217224
}
218225

219226
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -388,6 +395,7 @@ pub fn rsync_results(site: &str, cluster: &str, node: &str) -> JobResult {
388395
debug!("Rsync with site {} done.\n{:?}", site, out);
389396
} else {
390397
debug!("Rsync with site {} failed.\n{:?} ; {:?}", site, out, err);
398+
return Err(JobError::UnknownState("Rsync failed".to_string()))
391399
}
392400
} else {
393401
p.terminate()?;
@@ -408,6 +416,7 @@ pub fn rsync_results(site: &str, cluster: &str, node: &str) -> JobResult {
408416
debug!("Checksum success.\n{:?}", out);
409417
} else {
410418
debug!("Checksum fail.\n{:?} ; {:?}", out, err);
419+
return Err(JobError::UnknownState("Checksum failed".to_string()))
411420
}
412421
} else {
413422
p.terminate()?;

0 commit comments

Comments
 (0)